Skip to content
Open
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
6 changes: 5 additions & 1 deletion lib/ControlSystemsBase/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
ImplicitDifferentiation = "57b37032-215b-411a-8a7c-41a003a55207"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"

[extensions]
ControlSystemsBaseDSPExt = ["DSP"]
ControlSystemsBaseImplicitDifferentiationExt = ["ImplicitDifferentiation", "ComponentArrays"]
ControlSystemsBaseMakieExt = ["Makie"]
ControlSystemsBaseMonteCarloMeasurementsExt = ["MonteCarloMeasurements"]

[compat]
Aqua = "0.5"
Expand All @@ -42,6 +44,7 @@ MacroTools = "0.5"
Makie = "0.22, 0.23, 0.24"
MatrixEquations = "1, 2.1, 3"
MatrixPencils = "1.8.3, 2"
MonteCarloMeasurements = "1"
Polynomials = "3.0, 4.0"
PrecompileTools = "1"
Printf = "<0.0.1, 1"
Expand All @@ -62,10 +65,11 @@ GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
GenericSchur = "c145ed77-6b09-5dd9-b285-bf645a82121e"
ImplicitDifferentiation = "57b37032-215b-411a-8a7c-41a003a55207"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Aqua", "ComponentArrays", "Documenter", "DSP", "FiniteDifferences", "ImplicitDifferentiation", "Makie", "CairoMakie", "GenericSchur", "GR", "Plots", "SparseArrays", "StaticArrays"]
test = ["Test", "Aqua", "ComponentArrays", "Documenter", "DSP", "FiniteDifferences", "ImplicitDifferentiation", "Makie", "CairoMakie", "MonteCarloMeasurements", "GenericSchur", "GR", "Plots", "SparseArrays", "StaticArrays"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module ControlSystemsBaseMonteCarloMeasurementsExt
using ControlSystemsBase
using ControlSystemsBase: Polynomials
using MonteCarloMeasurements: AbstractParticles

# The roots of a polynomial with particle coefficients are computed for each particle
# separately. Without sorting, the order of the roots returned by LAPACK may differ
# between particles, so that a particle-valued root combines different roots and the
# particle-valued roots no longer form exact conjugate pairs. Sorting by real and
# imaginary part places the members of each conjugate pair at the same adjacent
# positions in every particle.
ControlSystemsBase.roots(p::Polynomials.AbstractPolynomial{<:AbstractParticles}; kwargs...) =
Polynomials.roots(p; kwargs...)

end
1 change: 1 addition & 0 deletions lib/ControlSystemsBase/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ my_tests = [
"test_implicit_diff",
"test_rootlocus",
"test_root_locus_matrix",
"test_monte_carlo_measurements",
]

@testset "All Tests" begin
Expand Down
18 changes: 18 additions & 0 deletions lib/ControlSystemsBase/test/test_monte_carlo_measurements.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# MonteCarloMeasurements depends on GenericSchur, so this file must run after the tests that require generic linear algebra to be unavailable.
import MonteCarloMeasurements as MCM
@testset "MonteCarloMeasurements interoperability" begin
@info "Testing MonteCarloMeasurements interoperability"
# The roots of a polynomial with particle coefficients must be ordered consistently
# over the particles so that the particle-valued roots form conjugate pairs.
ω = MCM.:..(4, 12)
ζ = MCM.:..(0.054, 0.084)
G = tf([2*ζ/ω, 1], [1/ω^2, 2*ζ/ω, 1, 0, 0])
C = tf([1.0, 1], [0.1, 1])
Gc = feedback(C*G, 1)
Z = zpk(Gc)
p = Z.matrix[1].p
@test length(p) == 5
@test count(x -> !iszero(imag(x)), p) == 4
w = exp10.(range(-1, 2, length=20))
@test MCM.pmean.(bode(Z, w)[1]) ≈ MCM.pmean.(bode(Gc, w)[1]) rtol=1e-6
end
Loading