Skip to content

Commit

Permalink
Merge pull request #717 from JuliaControl/C_I
Browse files Browse the repository at this point in the history
`ctrb` can take vector `B`
  • Loading branch information
baggepinnen authored Jul 12, 2022
2 parents db603a6 + 56849cf commit 3c14fd0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/freqresp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ end
mag = bodemag!(ws::BodemagWorkspace, sys::LTISystem, w::AbstractVector)
Compute the Bode magnitude operating in-place on an instance of [`BodemagWorkspace`](@ref). Note that the returned magnitude array is aliased with `ws.mag`.
The output array `mag` is ∈ 𝐑(ny, nu, nω) as opposed from the result of [`bode`](@ref) which has the frequency-dimension first. [`bodemag!`](@ref) is optimized for performance.
The output array `mag` is ∈ 𝐑(ny, nu, nω).
"""
function bodemag!(ws::BodemagWorkspace, sys::LTISystem, w::AbstractVector)
freqresp!(ws.R, sys, w)
Expand Down
2 changes: 1 addition & 1 deletion src/matrix_comps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Compute the controllability matrix for the system described by `(A, B)` or
Note that checking for controllability by computing the rank from
`ctrb` is not the most numerically accurate way, a better method is
checking if `gram(sys, :c)` is positive definite."""
function ctrb(A::AbstractMatrix, B::AbstractMatrix)
function ctrb(A::AbstractMatrix, B::AbstractVecOrMat)
T = promote_type(eltype(A), eltype(B))
n = size(A, 1)
nu = size(B, 2)
Expand Down
3 changes: 3 additions & 0 deletions test/test_linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ D_static = ss([0.704473 1.56483; -1.6661 -2.16041], 0.07)
@test gram(D_222,:o) [5.301899187768763 -3.2250358337314955
-3.2250358337314955 4.777830864787395]


C_111 = C_222[1,1]
@test obsv(C_222) == [1 0; 0 1; -5 -3; 2 -9]
@test ctrb(C_222) == [1 0 -5 -6; 0 2 2 -18]
@test ctrb(C_111.A, C_111.B) == ctrb(C_111.A, vec(C_111.B)) # 452
@test obsv(C_212) == [1 0; 0 1; -5 -3; 2 -9]
@test ctrb(C_212) == [1 -11; 2 -16]
@test norm(C_222) 0.5773502691896258
Expand Down

0 comments on commit 3c14fd0

Please sign in to comment.