11using StochasticDiffEq, LinearAlgebra, SparseArrays, Random, LinearSolve, Test
22using StochasticDiffEq. OrdinaryDiffEq: WOperator, calc_W!, calc_W
33using StochasticDiffEq. SciMLOperators: MatrixOperator
4+ using OrdinaryDiffEq
45
6+ # horid nasty hack to deal with temporary calc_W refactor
7+ # if there is a method that takes a W_transform argument, define the version that doesn't to set W_transform to true
8+ if hasmethod (calc_W, (Any, Any, Any, Any, Any))
9+ OrdinaryDiffEq. calc_W (integ, nlsolver, dgamma, repeat_step:: Bool ) = OrdinaryDiffEq. calc_W (integ, nlsolver, dgamma, repeat_step, true )
10+ OrdinaryDiffEq. calc_W! (integ, nlsolver, cache, dgamma, repeat_step:: Bool ) = OrdinaryDiffEq. calc_W (integ, nlsolver, dgamma, cacherepeat_step, true )
11+ end
512@testset " Derivative Utilities" begin
613 @testset " calc_W!" begin
714 A = [- 1.0 0.0 ; 0.0 - 0.5 ]; σ = [0.9 0.0 ; 0.0 0.8 ]
@@ -17,7 +24,7 @@ using StochasticDiffEq.SciMLOperators: MatrixOperator
1724 jac= (u,p,t) -> A)
1825 prob = SDEProblem (fun, u0, tspan)
1926 integrator = init (prob, ImplicitEM (theta= 1 ); adaptive= false , dt= dt)
20- W = calc_W (integrator, integrator. cache. nlsolver, dtgamma, #= repeat_step=# false , #= W_transform =# true )
27+ W = calc_W (integrator, integrator. cache. nlsolver, dtgamma, #= repeat_step=# false )
2128 @test convert (AbstractMatrix, W) ≈ concrete_W
2229 @test W \ u0 ≈ concrete_W \ u0
2330
@@ -29,7 +36,7 @@ using StochasticDiffEq.SciMLOperators: MatrixOperator
2936 prob = SDEProblem (fun, u0, tspan)
3037 integrator = init (prob, ImplicitEM (theta= 1 ); adaptive= false , dt= dt)
3138 W = integrator. cache. nlsolver. cache. W
32- calc_W! (W, integrator, integrator. cache. nlsolver, integrator. cache, dtgamma, #= repeat_step=# false , #= W_transform =# true )
39+ calc_W! (W, integrator, integrator. cache. nlsolver, integrator. cache, dtgamma, #= repeat_step=# false )
3340
3441 # Did not update because it's an array operator
3542 # We don't want to build Jacobians when we have operators!
0 commit comments