Skip to content

Commit cc5756b

Browse files
committed
debug nint_ym parameter with 0 values
1 parent 89dee6a commit cc5756b

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/state_estim.jl

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,19 @@ function init_estimstoch(i_ym, nint_ym)
110110
end
111111
any(nint_ym .< 0) && error("nint_ym values should be ≥ 0")
112112
nxs = sum(nint_ym)
113+
Asm, Csm = zeros(nxs, nxs), zeros(nym, nxs)
113114
if nxs 0 # construct stochastic model state-space matrices (integrators) :
114-
Asm = zeros(nxs, nxs)
115-
i_Asm = 1
115+
i_Asm, i_Csm = 1, 1
116116
for iym = 1:nym
117117
nint = nint_ym[iym]
118-
Asm[i_Asm:i_Asm + nint - 1, i_Asm:i_Asm + nint - 1] =
119-
Bidiagonal(ones(nint), ones(nint-1), :L)
120-
i_Asm += nint
121-
end
122-
Csm = zeros(nym, nxs);
123-
i_Csm = 1;
124-
for iym = 1:nym
125-
nint = nint_ym[iym];
126118
if nint 0
127-
Csm[iym, i_Csm+nint-1] = 1;
128-
i_Csm += nint;
129-
end
119+
rows_Asm = (i_Asm):(i_Asm + nint - 1)
120+
Asm[rows_Asm, rows_Asm] = Bidiagonal(ones(nint), ones(nint-1), :L)
121+
Csm[iym, i_Csm+nint-1] = 1
122+
i_Asm += nint
123+
i_Csm += nint
124+
end
130125
end
131-
else # no stochastic model :
132-
Asm, Csm = zeros(0, 0), zeros(nym, 0)
133126
end
134127
return Asm, Csm, nint_ym
135128
end

0 commit comments

Comments
 (0)