@@ -92,6 +92,13 @@ for (op, f) in ( (:+, :add), (:-, :sub), (:*, :mul), (:/, :div) )
92
92
end
93
93
end
94
94
95
+ # inv and sqrt:
96
+
97
+ # inv(::IntervalRounding{:tight}, a::T, r::RoundingMode) where T<:Union{Float32, Float64} = inv_round(a, r)
98
+ #
99
+ # sqrt(::IntervalRounding{:tight}, a::T, r::RoundingMode) where T<:Union{Float32, Float64} = sqrt_round(a, r)
100
+
101
+
95
102
for T in (Float32, Float64)
96
103
for mode in (:Down , :Up )
97
104
@@ -103,7 +110,7 @@ for T in (Float32, Float64)
103
110
@eval inv (:: IntervalRounding{:tight} ,
104
111
a:: $T , $ mode1) = inv_round (a, $ mode2)
105
112
106
- @eval sqrt (:: IntervalRounding{:tight} ,
113
+ @eval sqrt (:: IntervalRounding{:tight} ,
107
114
a:: $T , $ mode1) = sqrt_round (a, $ mode2)
108
115
end
109
116
end
@@ -175,13 +182,19 @@ for mode in (:Down, :Up)
175
182
# functions not in CRlibm:
176
183
for f in (:sqrt , :inv , :tanh , :asinh , :acosh , :atanh )
177
184
185
+
178
186
@eval function $f (:: IntervalRounding{:slow} ,
179
187
a:: T , $ mode1) where T<: AbstractFloat
180
188
setrounding (T, $ mode2) do
181
189
$ f (a)
182
190
end
183
191
end
184
192
193
+ @eval function $f (:: IntervalRounding{:tight} ,
194
+ a:: T , $ mode1) where T<: AbstractFloat
195
+ $ f (IntervalRounding {:slow} (), a, $ mode2)
196
+ end
197
+
185
198
186
199
@eval $ f (:: IntervalRounding{:accurate} ,
187
200
a:: T , $ mode1) where {T<: AbstractFloat } = $ directed ($ f (a))
@@ -229,10 +242,18 @@ function _setrounding(::Type{Interval}, rounding_type::Symbol)
229
242
@eval $ f (a:: T , b:: T , r:: RoundingMode ) where {T<: AbstractFloat } = $ f ($ roundtype, a, b, r)
230
243
end
231
244
245
+ # unary functions:
246
+
247
+ for f in (:sqrt , :inv )
248
+ @eval $ f (a:: T , r:: RoundingMode ) where {T<: AbstractFloat } = $ f ($ roundtype, a, r)
249
+ end
250
+
251
+
232
252
if rounding_type == :tight # for remaining functions, use CRlibm
233
253
roundtype = IntervalRounding {:slow} ()
234
254
end
235
255
256
+
236
257
for f in (:^ , :atan )
237
258
238
259
@eval $ f (a:: T , b:: T , r:: RoundingMode ) where {T<: AbstractFloat } = $ f ($ roundtype, a, b, r)
@@ -242,7 +263,7 @@ function _setrounding(::Type{Interval}, rounding_type::Symbol)
242
263
243
264
# unary functions:
244
265
for f in vcat (CRlibm. functions,
245
- [ :sqrt , :inv , :tanh , :asinh , :acosh , :atanh ])
266
+ [ :tanh , :asinh , :acosh , :atanh ])
246
267
247
268
@eval $ f (a:: T , r:: RoundingMode ) where {T<: AbstractFloat } = $ f ($ roundtype, a, r)
248
269
0 commit comments