@@ -332,7 +332,7 @@ each control period ``k``, see [`initpred!`](@ref) and [`linconstraint!`](@ref).
332332 \m athbf{Ĉ}\m athbf{Â}^{2} \\
333333 \v dots \\
334334 \m athbf{Ĉ}\m athbf{Â}^{H_p} \e nd{bmatrix} \\
335- \m athbf{V} &= Q (0, H_p) \\
335+ \m athbf{V} &= \m athbf{Q} (0, H_p) \\
336336 \m athbf{B} &= \b egin{bmatrix}
337337 \m athbf{Ĉ W}(0) \\
338338 \m athbf{Ĉ W}(1) \\
@@ -376,9 +376,16 @@ function init_predmat(
376376 end
377377 # Apow_csum 3D array : Apow_csum[:,:,1] = A^0, Apow_csum[:,:,2] = A^1 + A^0, ...
378378 Âpow_csum = cumsum (Âpow, dims= 3 )
379- # two helper functions to improve code clarity and be similar to eqs. in docstring:
379+ # three helper functions to improve code clarity and be similar to eqs. in docstring:
380380 getpower (array3D, power) = @views array3D[:,:, power+ 1 ]
381381 W (m) = @views Âpow_csum[:,:, m+ 1 ]
382+ function Q! (Q, i, j)
383+ for ℓ= 1 : j
384+ iRows = (1 : ny) .+ ny* (ℓ- 1 )
385+ Q[iRows, :] = Ĉ* W (i+ ℓ- 1 )* B̂u
386+ end
387+ return Q
388+ end
382389 # --- current state estimates x̂0 ---
383390 kx̂ = getpower (Âpow, Hp)
384391 K = Matrix {NT} (undef, Hp* ny, nx̂)
@@ -387,7 +394,7 @@ function init_predmat(
387394 K[iRow,:] = Ĉ* getpower (Âpow, j)
388395 end
389396 # --- previous manipulated inputs lastu0 ---
390- vx̂ = W (H_p - 1 )* B̂u
397+ vx̂ = W (Hp - 1 )* B̂u
391398 V = Matrix {NT} (undef, Hp* ny, nu)
392399 for j= 1 : Hp
393400 iRow = (1 : ny) .+ ny* (j- 1 )
0 commit comments