Skip to content

Commit

Permalink
cleanup comments, check for scalar before diag
Browse files Browse the repository at this point in the history
  • Loading branch information
MasonProtter authored and ChrisRackauckas committed Jul 22, 2024
1 parent dc284af commit e2ec9c7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/systems/systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,16 @@ function __structural_simplify(sys::AbstractSystem, io = nothing; simplify = fal
@views copyto!(sorted_g_rows[i, :], g[g_row, :])
end
# Fix for https://github.com/SciML/ModelingToolkit.jl/issues/2490
if isdiag(sorted_g_rows)
# If the noise matrix is diagonal, then we just give solver just takes a vector column of equations
if sorted_g_rows isa AbstractMatrix && size(sorted_g_rows, 2) == 1
# If there's only one brownian variable referenced across all the equations,
# we get a Nx1 matrix of noise equations, which is a special case known as scalar noise
noise_eqs = sorted_g_rows[:, 1]
is_scalar_noise = true
elseif isdiag(sorted_g_rows)
# If the noise matrix is diagonal, then the solver just takes a vector column of equations
# and it interprets that as diagonal noise.
noise_eqs = diag(sorted_g_rows)
is_scalar_noise = false
elseif sorted_g_rows isa AbstractMatrix && size(sorted_g_rows, 2) == 1
noise_eqs = sorted_g_rows[:, 1]
is_scalar_noise = true
else
noise_eqs = sorted_g_rows
is_scalar_noise = false
Expand Down

0 comments on commit e2ec9c7

Please sign in to comment.