Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ControlSystemsBase/src/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ end
count_integrators(P)

Count the number of poles in the origin by finding the maximum value of `n` for which the number of poles within a circle of radius `(n+1)*eps(numeric_type(sys))^(1/n)` arount the origin (1 in discrete time) equals `n`.

See also [`integrator_excess`](@ref).
"""
function count_integrators(P::LTISystem)
p = poles(P)
Expand Down
6 changes: 6 additions & 0 deletions lib/ControlSystemsBase/src/freqresp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ function bodemag!(ws::BodemagWorkspace, sys::LTISystem, w::AbstractVector)
ws.mag
end

function bodemag_nohess!(ws::BodemagWorkspace, sys::LTISystem, w::AbstractVector)
freqresp_nohess!(ws.R, sys, w)
@. ws.mag = abs(ws.R)
ws.mag
end

"""
re, im, w = nyquist(sys[, w])

Expand Down
2 changes: 1 addition & 1 deletion lib/ControlSystemsBase/src/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ to_abstract_matrix(A::AbstractVector) = reshape(A, length(A), 1)
to_abstract_matrix(A::Number) = fill(A, 1, 1)

# Do no sorting of eigenvalues
eigvalsnosort(args...; kwargs...) = eigvals(args...; sortby=nothing, kwargs...)
eigvalsnosort(A, args...; kwargs...)::Vector{Complex{real(float(eltype(A)))}} = eigvals(A, args...; sortby=nothing, kwargs...)
eigvalsnosort(A::StaticArraysCore.StaticMatrix; kwargs...) = eigvalsnosort(Matrix(A); kwargs...)
roots(args...; kwargs...) = Polynomials.roots(args...; sortby=nothing, kwargs...)

Expand Down
1 change: 1 addition & 0 deletions lib/ControlSystemsBase/test/test_freqresp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Base.isapprox(t1::Tuple, t2::Tuple) = t1[1] ≈ t2[1] && t1[2] ≈ t2[2]
@test bode(sys, ws)[1:2] ≈ (abs.(resp), rad2deg.(angle.(resp)))
workspace = BodemagWorkspace(sys, ws)
@test bode(sys, ws)[1] == bodemag!(workspace, sys, ws)
@test bode(sys, ws)[1] ≈ ControlSystemsBase.bodemag_nohess!(workspace, ss(sys), ws)
@test nyquist(sys, ws)[1:2] ≈ (real(resp), imag(resp))
sigs = Array{Float64}(undef, 2, 50)
for i in eachindex(ws)
Expand Down
3 changes: 2 additions & 1 deletion lib/ControlSystemsBase/test/test_matrix_comps.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Test, LinearAlgebra
@testset "test_matrix_comps" begin
A = [-0.21 0.2; 0.2 -0.21]
B = 0.01*[1 0; 0 1]
Expand All @@ -8,7 +9,7 @@ sysr, G = balreal(sys)

@test gram(sysr, :c) ≈ diagm(G)
@test gram(sysr, :o) ≈ diagm(G)
@test sort(poles(sysr)) ≈ sort(poles(sys))
@test sort(poles(sysr), by=real) ≈ sort(poles(sys), by=real)

sysb,T = ControlSystemsBase.balance_statespace(sys)
@test similarity_transform(sysb, T) ≈ sys
Expand Down
Loading