Skip to content

Commit ab6f03f

Browse files
committedApr 12, 2024
added: allow C=I in LinModel constructor with 6 args
1 parent 6ea9907 commit ab6f03f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
 

‎src/model/linmodel.jl

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ struct LinModel{NT<:Real} <: SimModel{NT}
1414
yop::Vector{NT}
1515
dop::Vector{NT}
1616
function LinModel{NT}(A, Bu, C, Bd, Dd, Ts) where {NT<:Real}
17-
A, Bu, C = to_mat(A, 1, 1), to_mat(Bu, 1, 1), to_mat(C, 1, 1)
18-
nu, nx, ny = size(Bu, 2), size(A, 2), size(C, 1)
17+
A, Bu = to_mat(A, 1, 1), to_mat(Bu, 1, 1)
18+
nu, nx = size(Bu, 2), size(A, 2)
19+
(C == I) && (C = Matrix{NT}(I, nx, nx))
20+
C = to_mat(C, 1, 1)
21+
ny = size(C, 1)
1922
Bd = to_mat(Bd, nx, Bd 0)
2023
nd = size(Bd, 2)
2124
Dd = to_mat(Dd, ny, nd)

‎test/test_sim_model.jl

+5-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ Gss2 = c2d(sys_ss[:,1:2], 0.5Ts, :zoh)
7373
@test isa(linmodel10, LinModel{Float64})
7474
@test linmodel10.nd == 0
7575

76-
linmodel11 = LinModel{Float32}(Gss.A, Gss.B, Gss.C, zeros(2, 0), zeros(2, 0), Ts)
77-
@test isa(linmodel11, LinModel{Float32})
76+
linmodel11 = LinModel(Gss.A, Gss.B, I, 0, 0, Ts)
77+
@test linmodel11.ny == linmodel11.nx
78+
79+
linmodel12 = LinModel{Float32}(Gss.A, Gss.B, Gss.C, zeros(2, 0), zeros(2, 0), Ts)
80+
@test isa(linmodel12, LinModel{Float32})
7881

7982

8083
@test_throws ErrorException LinModel(sys)

0 commit comments

Comments
 (0)
Please sign in to comment.