Skip to content

Commit 891156c

Browse files
committed
changed: similar function in init_predmat_mhe
1 parent 4cc02a3 commit 891156c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/estimator/mhe/construct.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,21 +1249,23 @@ function init_predmat_mhe(
12491249
# --- state x̂op and state update f̂op operating points ---
12501250
# Apow_csum 3D array : Apow_csum[:,:,1] = A^0, Apow_csum[:,:,2] = A^1 + A^0, ...
12511251
Âpow_csum = cumsum(Âpow3D, dims=3)
1252+
# helper function to improve code clarity and be similar to eqs. in docstring:
1253+
S(j) = @views Âpow_csum[:,:, j+1]
12521254
f̂_op_n_x̂op = (f̂op - x̂op)
12531255
coef_B = zeros(NT, nym*He, nx̂)
12541256
row_begin = iszero(p) ? 0 : 1
12551257
row_end = iszero(p) ? He-1 : He-2
12561258
j=0
12571259
for i=row_begin:row_end
12581260
iRow = (1:nym) .+ nym*i
1259-
coef_B[iRow,:] = -Ĉm*getpower(Âpow_csum, j)
1261+
coef_B[iRow,:] = -Ĉm*S(j)
12601262
j+=1
12611263
end
12621264
B = coef_B*f̂_op_n_x̂op
12631265
coef_Bx̂ = Matrix{NT}(undef, nx̂*He, nx̂)
12641266
for j=0:He-1
12651267
iRow = (1:nx̂) .+ nx̂*j
1266-
coef_Bx̂[iRow,:] = getpower(Âpow_csum, j)
1268+
coef_Bx̂[iRow,:] = S(j)
12671269
end
12681270
Bx̂ = coef_Bx̂*f̂_op_n_x̂op
12691271
return E, G, J, B, ex̄, Ex̂, Gx̂, Jx̂, Bx̂

0 commit comments

Comments
 (0)