Skip to content

Commit e2ec9c7

Browse files
MasonProtterChrisRackauckas
authored andcommitted
cleanup comments, check for scalar before diag
1 parent dc284af commit e2ec9c7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/systems/systems.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,16 @@ function __structural_simplify(sys::AbstractSystem, io = nothing; simplify = fal
128128
@views copyto!(sorted_g_rows[i, :], g[g_row, :])
129129
end
130130
# Fix for https://github.com/SciML/ModelingToolkit.jl/issues/2490
131-
if isdiag(sorted_g_rows)
132-
# If the noise matrix is diagonal, then we just give solver just takes a vector column of equations
131+
if sorted_g_rows isa AbstractMatrix && size(sorted_g_rows, 2) == 1
132+
# If there's only one brownian variable referenced across all the equations,
133+
# we get a Nx1 matrix of noise equations, which is a special case known as scalar noise
134+
noise_eqs = sorted_g_rows[:, 1]
135+
is_scalar_noise = true
136+
elseif isdiag(sorted_g_rows)
137+
# If the noise matrix is diagonal, then the solver just takes a vector column of equations
133138
# and it interprets that as diagonal noise.
134139
noise_eqs = diag(sorted_g_rows)
135140
is_scalar_noise = false
136-
elseif sorted_g_rows isa AbstractMatrix && size(sorted_g_rows, 2) == 1
137-
noise_eqs = sorted_g_rows[:, 1]
138-
is_scalar_noise = true
139141
else
140142
noise_eqs = sorted_g_rows
141143
is_scalar_noise = false

0 commit comments

Comments
 (0)