Skip to content

Commit b712a12

Browse files
committed
cleanup comments, check for scalar before diag
1 parent 1c8751f commit b712a12

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
@@ -126,14 +126,16 @@ function __structural_simplify(sys::AbstractSystem, io = nothing; simplify = fal
126126
@views copyto!(sorted_g_rows[i, :], g[g_row, :])
127127
end
128128
# Fix for https://github.com/SciML/ModelingToolkit.jl/issues/2490
129-
if isdiag(sorted_g_rows)
130-
# If the noise matrix is diagonal, then we just give solver just takes a vector column of equations
129+
if sorted_g_rows isa AbstractMatrix && size(sorted_g_rows, 2) == 1
130+
# If there's only one brownian variable referenced across all the equations,
131+
# we get a Nx1 matrix of noise equations, which is a special case known as scalar noise
132+
noise_eqs = sorted_g_rows[:, 1]
133+
is_scalar_noise = true
134+
elseif isdiag(sorted_g_rows)
135+
# If the noise matrix is diagonal, then the solver just takes a vector column of equations
131136
# and it interprets that as diagonal noise.
132137
noise_eqs = diag(sorted_g_rows)
133138
is_scalar_noise = false
134-
elseif sorted_g_rows isa AbstractMatrix && size(sorted_g_rows, 2) == 1
135-
noise_eqs = sorted_g_rows[:, 1]
136-
is_scalar_noise = true
137139
else
138140
noise_eqs = sorted_g_rows
139141
is_scalar_noise = false

0 commit comments

Comments
 (0)