Skip to content

Commit 82a5014

Browse files
authored
Merge pull request #955 from JuliaControl/bodemagnohess
add `bodemag_nohess!`
2 parents f5892f0 + a54405e commit 82a5014

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

lib/ControlSystemsBase/src/analysis.jl

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ end
5656
count_integrators(P)
5757
5858
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`.
59+
60+
See also [`integrator_excess`](@ref).
5961
"""
6062
function count_integrators(P::LTISystem)
6163
p = poles(P)

lib/ControlSystemsBase/src/freqresp.jl

+6
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ function bodemag!(ws::BodemagWorkspace, sys::LTISystem, w::AbstractVector)
339339
ws.mag
340340
end
341341

342+
function bodemag_nohess!(ws::BodemagWorkspace, sys::LTISystem, w::AbstractVector)
343+
freqresp_nohess!(ws.R, sys, w)
344+
@. ws.mag = abs(ws.R)
345+
ws.mag
346+
end
347+
342348
"""
343349
re, im, w = nyquist(sys[, w])
344350

lib/ControlSystemsBase/src/utilities.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ to_abstract_matrix(A::AbstractVector) = reshape(A, length(A), 1)
3434
to_abstract_matrix(A::Number) = fill(A, 1, 1)
3535

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

lib/ControlSystemsBase/test/test_freqresp.jl

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Base.isapprox(t1::Tuple, t2::Tuple) = t1[1] ≈ t2[1] && t1[2] ≈ t2[2]
120120
@test bode(sys, ws)[1:2] (abs.(resp), rad2deg.(angle.(resp)))
121121
workspace = BodemagWorkspace(sys, ws)
122122
@test bode(sys, ws)[1] == bodemag!(workspace, sys, ws)
123+
@test bode(sys, ws)[1] ControlSystemsBase.bodemag_nohess!(workspace, ss(sys), ws)
123124
@test nyquist(sys, ws)[1:2] (real(resp), imag(resp))
124125
sigs = Array{Float64}(undef, 2, 50)
125126
for i in eachindex(ws)

lib/ControlSystemsBase/test/test_matrix_comps.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Test, LinearAlgebra
12
@testset "test_matrix_comps" begin
23
A = [-0.21 0.2; 0.2 -0.21]
34
B = 0.01*[1 0; 0 1]
@@ -8,7 +9,7 @@ sysr, G = balreal(sys)
89

910
@test gram(sysr, :c) diagm(G)
1011
@test gram(sysr, :o) diagm(G)
11-
@test sort(poles(sysr)) sort(poles(sys))
12+
@test sort(poles(sysr), by=real) sort(poles(sys), by=real)
1213

1314
sysb,T = ControlSystemsBase.balance_statespace(sys)
1415
@test similarity_transform(sysb, T) sys

0 commit comments

Comments
 (0)