# DifferentialEquations.jl: complex-value matrix equations without in-place update

**URL:** <https://discourse.julialang.org/t/differentialequations-jl-complex-value-matrix-equations-without-in-place-update/20110>\
**Category:** Numerics\
**Created:** [January 25, 2019, 7:57pm UTC](https://discourse.julialang.org/t/differentialequations-jl-complex-value-matrix-equations-without-in-place-update/20110 "2019-01-25T19:57:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Egwene\_al\_Vere](https://avatars.discourse-cdn.com/v4/letter/e/df788c/32.png) [@Egwene\_al\_Vere](https://discourse.julialang.org/u/Egwene_al_Vere)\
**Post date:** [January 25, 2019, 7:57pm UTC](https://discourse.julialang.org/t/differentialequations-jl-complex-value-matrix-equations-without-in-place-update/20110/1 "2019-01-25T19:57:28Z")

</div>

To solve a stiff complex-value matrix equation, I’m using the Rosenbrock23() solver. As a minimum working example, (may not be stiff, just to illustrate the error I got)

With in-place du, (function taking 4 arguments: du,u,p,t)

```julia
using DifferentialEquations
using LinearAlgebra

sz=[1 0;0 -1];

function rhs(du,u,p,t)
 du.=-(.3+.5im)*u+sz
end

hdim=2
tf=30.0
ft0=zeros(Complex{Float64}, hdim, hdim);
tspan=(0.0,tf)

prob = ODEProblem(rhs,ft0,tspan)

sol = solve(prob,Rosenbrock23(autodiff=false))
sol.retcode

```

works fine; however, the function that just returns du (taking 3 arguments: u,p,t)

```julia
using DifferentialEquations
using LinearAlgebra

sz=[1 0;0 -1];

function rhs(u,p,t)
 du=-(.3+.5im)*u+sz
end

hdim=2
tf=30.0
ft0=zeros(Complex{Float64}, hdim, hdim);
tspan=(0.0,tf)

prob = ODEProblem(rhs,ft0,tspan)

sol = solve(prob,Rosenbrock23(autodiff=false))
sol.retcode

```

fails with

> DimensionMismatch(“diagonal matrix is 4 by 4 but right hand side has 2 rows”)

note that for this case, `sol = solve(prob)` works fine, but for my complicated stiff equation I need `Rosenbrock23(autodiff=false)`. Is it a bug to be reported or did I do something wrong here? Thanks!

---

<div class="post-metadata">

**Author:** ![Egwene\_al\_Vere](https://avatars.discourse-cdn.com/v4/letter/e/df788c/32.png) [@Egwene\_al\_Vere](https://discourse.julialang.org/u/Egwene_al_Vere)\
**Post date:** [February 7, 2019, 2:49pm UTC](https://discourse.julialang.org/t/differentialequations-jl-complex-value-matrix-equations-without-in-place-update/20110/2 "2019-02-07T14:49:30Z")

</div>

update: it’s a bug fixed in [here](https://github.com/JuliaDiffEq/OrdinaryDiffEq.jl/pull/632)
