File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -2,16 +2,26 @@ module DiffEqBaseGTPSAExt
2
2
3
3
if isdefined (Base, :get_extension )
4
4
using DiffEqBase
5
- import DiffEqBase: value
5
+ import DiffEqBase: value, ODE_DEFAULT_NORM
6
6
using GTPSA
7
7
else
8
8
using .. DiffEqBase
9
- import .. DiffEqBase: value
9
+ import .. DiffEqBase: value, ODE_DEFAULT_NORM
10
10
using .. GTPSA
11
11
end
12
12
13
- value (x:: TPS ) = scalar (x);
13
+ value (x:: TPS ) = scalar (x)
14
14
value (:: Type{TPS{T}} ) where {T} = T
15
15
16
+ ODE_DEFAULT_NORM (u:: TPS , t) = @fastmath abs (value (u))
17
+ ODE_DEFAULT_NORM (f:: F , u:: TPS , t) where {F} = @fastmath abs (f (value (u)))
18
+
19
+ function ODE_DEFAULT_NORM (u:: AbstractArray{TPS{T}} , t) where {T <: Union{AbstractFloat, Complex} }
20
+ x = zero (real (T))
21
+ @inbounds @fastmath for ui in u
22
+ x += abs2 (value (ui))
23
+ end
24
+ Base. FastMath. sqrt_fast (x / max (length (u), 1 ))
25
+ end
16
26
17
27
end
You can’t perform that action at this time.
0 commit comments