diff --git a/src/freqresp.jl b/src/freqresp.jl index 0ff48139d..be4ea845d 100644 --- a/src/freqresp.jl +++ b/src/freqresp.jl @@ -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) diff --git a/src/matrix_comps.jl b/src/matrix_comps.jl index 693454238..dd3069995 100644 --- a/src/matrix_comps.jl +++ b/src/matrix_comps.jl @@ -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) diff --git a/test/test_linalg.jl b/test/test_linalg.jl index 32238bcd4..0ada4299e 100644 --- a/test/test_linalg.jl +++ b/test/test_linalg.jl @@ -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