Skip to content

Commit f5c1cd2

Browse files
fix zeroing issues
1 parent f12b090 commit f5c1cd2

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

src/caches/basic_method_caches.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
struct EMConstantCache <: StochasticDiffEqConstantCache end
2-
struct EMCache{uType,rateType,rateNoiseType,rateNoiseCollectionType} <: StochasticDiffEqMutableCache
2+
struct EMCache{uType,rateType,rateNoiseType,rateNoiseCollectionType,randType} <: StochasticDiffEqMutableCache
33
u::uType
44
uprev::uType
5-
tmp::uType
5+
tmp::randType
66
rtmp1::rateType
77
rtmp2::rateNoiseType
88
rtmp3::rateNoiseCollectionType
@@ -25,10 +25,10 @@ function alg_cache(alg::EM,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_prototype,
2525
end
2626

2727
struct SplitEMConstantCache <: StochasticDiffEqConstantCache end
28-
struct SplitEMCache{uType,rateType,rateNoiseType,rateNoiseCollectionType} <: StochasticDiffEqMutableCache
28+
struct SplitEMCache{uType,rateType,rateNoiseType,rateNoiseCollectionType,randType} <: StochasticDiffEqMutableCache
2929
u::uType
3030
uprev::uType
31-
tmp::uType
31+
tmp::randType
3232
rtmp1::rateType
3333
rtmp2::rateNoiseType
3434
rtmp3::rateNoiseCollectionType
@@ -51,10 +51,10 @@ function alg_cache(alg::SplitEM,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_proto
5151
end
5252

5353
struct EulerHeunConstantCache <: StochasticDiffEqConstantCache end
54-
struct EulerHeunCache{uType,rateType,rateNoiseType,rateNoiseCollectionType} <: StochasticDiffEqMutableCache
54+
struct EulerHeunCache{uType,rateType,rateNoiseType,rateNoiseCollectionType,randType} <: StochasticDiffEqMutableCache
5555
u::uType
5656
uprev::uType
57-
tmp::uType
57+
tmp::randType
5858
ftmp1::rateType
5959
ftmp2::rateType
6060
nrtmp::rateNoiseCollectionType
@@ -75,10 +75,10 @@ function alg_cache(alg::EulerHeun,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_pro
7575
end
7676

7777
struct RandomEMConstantCache <: StochasticDiffEqConstantCache end
78-
struct RandomEMCache{uType,rateType} <: StochasticDiffEqMutableCache
78+
struct RandomEMCache{uType,rateType,randType} <: StochasticDiffEqMutableCache
7979
u::uType
8080
uprev::uType
81-
tmp::uType
81+
tmp::randType
8282
rtmp::rateType
8383
end
8484

@@ -93,13 +93,13 @@ function alg_cache(alg::RandomEM,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_prot
9393
end
9494

9595
struct RKMilConstantCache <: StochasticDiffEqConstantCache end
96-
struct RKMilCache{uType,rateType} <: StochasticDiffEqMutableCache
96+
struct RKMilCache{uType,rateType,randType} <: StochasticDiffEqMutableCache
9797
u::uType
9898
uprev::uType
9999
du1::rateType
100100
du2::rateType
101101
K::rateType
102-
tmp::uType
102+
tmp::randType
103103
L::rateType
104104
end
105105

src/caches/iif_caches.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ end
3434

3535
function alg_cache(alg::IIF1M,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_prototype,uEltypeNoUnits,uBottomEltype,tTypeNoUnits,uprev,f,t,::Type{Val{true}})
3636

37-
tmp = zeros(u,indices(u)); rtmp1 = zeros(rate_prototype)
37+
tmp = similar(u,indices(u)); rtmp1 = zeros(rate_prototype)
3838
dual_cache = DiffCache(u,Val{determine_chunksize(u,get_chunksize(alg.nlsolve))})
3939
uhold = vec(u) # this makes uhold the same values as integrator.u
4040
rhs = RHS_IIF1(f,tmp,t,t,dual_cache,size(u),p)
@@ -85,7 +85,7 @@ end
8585

8686
function alg_cache(alg::IIF2M,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_prototype,uEltypeNoUnits,uBottomEltype,tTypeNoUnits,uprev,f,t,::Type{Val{true}})
8787

88-
tmp = zeros(u,indices(u)); rtmp1 = zeros(rate_prototype)
88+
tmp = similar(u,indices(u)); rtmp1 = zeros(rate_prototype)
8989
dual_cache = DiffCache(u,Val{determine_chunksize(u,get_chunksize(alg.nlsolve))})
9090
uhold = vec(u) # this makes uhold the same values as integrator.u
9191
rhs = RHS_IIF2(f,tmp,t,t,dual_cache,size(u),p)
@@ -136,7 +136,7 @@ function alg_cache(alg::IIF1Mil,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_proto
136136
end
137137

138138
function alg_cache(alg::IIF1Mil,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_prototype,uEltypeNoUnits,uBottomEltype,tTypeNoUnits,uprev,f,t,::Type{Val{true}})
139-
tmp = zeros(u,indices(u)); rtmp1 = zeros(rate_prototype)
139+
tmp = similar(u,indices(u)); rtmp1 = zeros(rate_prototype)
140140
dual_cache = DiffCache(u,Val{determine_chunksize(u,get_chunksize(alg.nlsolve))})
141141
uhold = vec(u) # this makes uhold the same values as integrator.u
142142
rhs = RHS_IIF1(f,tmp,t,t,dual_cache,size(u))

src/caches/kencarp_caches.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ function alg_cache(alg::SKenCarp,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_prot
7373
du1 = zeros(rate_prototype)
7474
J = zeros(uEltypeNoUnits,length(u),length(u)) # uEltype?
7575
W = zeros(J)
76-
z₁ = zeros(u,indices(u)); z₂ = zeros(u,indices(u))
77-
z₃ = zeros(u,indices(u)); z₄ = zeros(u,indices(u))
78-
dz = zeros(u,indices(u))
76+
z₁ = similar(u,indices(u)); z₂ = similar(u,indices(u))
77+
z₃ = similar(u,indices(u)); z₄ = similar(u,indices(u))
78+
dz = similar(u,indices(u))
7979
fsalfirst = zeros(rate_prototype)
8080
k = zeros(rate_prototype)
81-
tmp = zeros(ΔW); b = zeros(u,indices(u));
81+
tmp = zeros(ΔW); b = similar(u,indices(u));
8282
atmp = zeros(u,uEltypeNoUnits,indices(u))
8383

8484
if typeof(f) <: SplitFunction
85-
k1 = zeros(u,indices(u)); k2 = zeros(u,indices(u))
86-
k3 = zeros(u,indices(u)); k4 = zeros(u,indices(u))
85+
k1 = zeros(u); k2 = zeros(u)
86+
k3 = zeros(u); k4 = zeros(u)
8787
uf = DiffEqDiffTools.UJacobianWrapper(f.f1,t,p)
8888
else
8989
k1 = nothing; k2 = nothing

0 commit comments

Comments
 (0)