@@ -4,9 +4,9 @@ using TaylorSeries
4
4
5
5
import Base: ^ , log, asin, acos, acosh, atanh, power_by_squaring
6
6
7
- import TaylorSeries: evaluate, _evaluate, normalize_taylor, square
7
+ import TaylorSeries: evaluate, _evaluate, normalize_taylor, aff_normalize, square
8
8
9
- isdefined (Base, :get_extension ) ? ( using IntervalArithmetic) : ( using .. IntervalArithmetic)
9
+ using IntervalArithmetic
10
10
11
11
for T in (:Taylor1 , :TaylorN )
12
12
@eval begin
@@ -188,16 +188,11 @@ function evaluate(a::Taylor1, dx::Interval{S}) where {S<:Real}
188
188
return sum_even + sum_odd* dx
189
189
end
190
190
191
- function evaluate (a:: TaylorN , dx:: IntervalBox{N,T} ) where {T<: Real ,N}
192
- @assert N == get_numvars ()
193
- a_length = length (a)
194
- suma = zero (constant_term (a)) + Interval {T} (0 , 0 )
195
- @inbounds for homPol in reverse (eachindex (a))
196
- suma += evaluate (a[homPol], dx)
197
- end
191
+ evaluate (a:: Taylor1{TaylorN{T}} , dx:: IntervalBox{N,S} ) where {T<: Real , N, S} =
192
+ evaluate (a, dx. v)
198
193
199
- return suma
200
- end
194
+ evaluate (a :: TaylorN{T} , dx :: IntervalBox{N,S} ) where {T <: Real , N, S} =
195
+ evaluate (a, dx . v)
201
196
202
197
function evaluate (a:: HomogeneousPolynomial , dx:: IntervalBox{N,T} ) where {T<: Real ,N}
203
198
@assert N == get_numvars ()
@@ -261,29 +256,28 @@ are mapped by an affine transformation to the intervals `-1..1`
261
256
normalize_taylor (a:: TaylorN , I:: IntervalBox{N,T} , symI:: Bool = true ) where {T<: Real ,N} =
262
257
_normalize (a, I, Val (symI))
263
258
259
+ aff_normalize (x, I:: Interval , :: Val{true} ) = mid (I) + x* radius (I)
260
+ aff_normalize (x, I:: Interval , :: Val{false} ) = inf (I) + x* diam (I)
261
+
264
262
# I -> -1..1
265
263
function _normalize (a:: Taylor1 , I:: Interval{T} , :: Val{true} ) where {T<: Real }
266
- order = get_order (a)
267
- t = Taylor1 (T, order)
268
- tnew = mid (I) + t* radius (I)
269
- return a (tnew)
264
+ t = Taylor1 (T, get_order (a))
265
+ return a (aff_normalize (t, I, Val (true )))
270
266
end
271
267
272
268
# I -> 0..1
273
269
function _normalize (a:: Taylor1 , I:: Interval{T} , :: Val{false} ) where {T<: Real }
274
- order = get_order (a)
275
- t = Taylor1 (T, order)
276
- tnew = inf (I) + t* diam (I)
277
- return a (tnew)
270
+ t = Taylor1 (T, get_order (a))
271
+ return a (aff_normalize (t, I, Val (false )))
278
272
end
279
273
280
274
# I -> IntervalBox(-1..1, Val(N))
281
275
function _normalize (a:: TaylorN , I:: IntervalBox{N,T} , :: Val{true} ) where {T<: Real ,N}
282
276
order = get_order (a)
283
277
x = Vector {typeof(a)} (undef, N)
284
278
for ind in eachindex (x)
285
- x[ind] = mid (I[ind]) + TaylorN (ind, order= order)* radius ( I[ind])
286
- end
279
+ x[ind] = aff_normalize ( TaylorN (ind, order= order), I[ind], Val ( true ) )
280
+ end
287
281
return a (x)
288
282
end
289
283
@@ -292,7 +286,7 @@ function _normalize(a::TaylorN, I::IntervalBox{N,T}, ::Val{false}) where {T<:Rea
292
286
order = get_order (a)
293
287
x = Vector {typeof(a)} (undef, N)
294
288
for ind in eachindex (x)
295
- x[ind] = inf (I[ind]) + TaylorN (ind, order= order)* diam ( I[ind])
289
+ x[ind] = aff_normalize ( TaylorN (ind, order= order), I[ind], Val ( false ) )
296
290
end
297
291
return a (x)
298
292
end
0 commit comments