Non-diagonal noise

How am I supposed to use non-diagonal noise when du is a matrix? When I run the example below I get:

BoundsError: attempt to access 2-element Array{Float64,1} at index [1, 2]
using DifferentialEquations, LinearAlgebra
f(du,u,p,t) = (du.=1.01*u)
function g(du,u,p,t)
  du[1,1] = u[1]
  du[1,2] = u[1]
  du[2,1] = u[2]
  du[2,2] = u[2]

Γ = zeros(4,4)
Γ[diagind(Γ)] .= 1
Γ[1,2] = .99
Γ[2,1] = .99
noise = CorrelatedWienerProcess!(Γ,0.,zeros(4),zeros(4))
prob = SDEProblem(f,g,ones(2),(0.,1.),[],noise=noise)
sol = solve(prob,EM(),dt=1/1000)

The error here is because your u₀ is initialized as ones(2), a one-dimensional array and you index it with two indices in g.

I tried creating u₀ as ones(2,2), that causes an error as well. Perhaps you could try unrolling u to be length 4 instead of 2x2.

@contradict thanks for answering a lot lately, it’s been very helpful.