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
22
33if isdefined (Base, :get_extension )
44 using DiffEqBase
5- import DiffEqBase: value
5+ import DiffEqBase: value, ODE_DEFAULT_NORM
66 using GTPSA
77else
88 using .. DiffEqBase
9- import .. DiffEqBase: value
9+ import .. DiffEqBase: value, ODE_DEFAULT_NORM
1010 using .. GTPSA
1111end
1212
13- value (x:: TPS ) = scalar (x);
13+ value (x:: TPS ) = scalar (x)
1414value (:: Type{TPS{T}} ) where {T} = T
1515
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
1626
1727end
You can’t perform that action at this time.
0 commit comments