Skip to content

Commit 9fec5de

Browse files
authored
Merge pull request #236 from JuliaControl/release-0.5.4-option2
Release 0.5.4
2 parents 1e113ca + 8ee528b commit 9fec5de

File tree

10 files changed

+35
-66
lines changed

10 files changed

+35
-66
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: julia
22
julia:
33
- 1.0
44
- 1.1
5+
- 1.2
56
- nightly
67
matrix:
78
allow_failures:

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "ControlSystems"
22
uuid = "a6e380b2-a6ca-5380-bf3e-84a91bcd477e"
33
authors = ["Dept. Automatic Control, Lund University"]
44
repo = "https://github.com/JuliaControl/ControlSystems.jl.git"
5-
version = "0.5.3"
5+
version = "0.5.4"
66

77
[deps]
88
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
@@ -20,4 +20,4 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2020
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2121

2222
[compat]
23-
Polynomials = "0.5.3"
23+
Polynomials = "0.6.0"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Pkg.add("ControlSystems")
1717
```
1818

1919
## News
20+
### 2019-11-03
21+
- Poles and zeros are "not sorted" as in Julia versions < 1.2, even on newer versions of Julia. This should imply that complex conjugates are kept together.
22+
2023
### 2019-05-28
2124
#### Delay systems
2225
- We now support systems with time delays. Example:

src/ControlSystems.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ export LTISystem,
8181

8282

8383
# QUESTION: are these used? LaTeXStrings, Requires, IterTools
84-
using Polynomials, Plots, LaTeXStrings, LinearAlgebra
84+
using Plots, LaTeXStrings, LinearAlgebra
85+
import Polynomials
86+
import Polynomials: Poly, coeffs, polyval
8587
using OrdinaryDiffEq, DelayDiffEq
8688
export Plots
8789
import Base: +, -, *, /, (==), (!=), isapprox, convert, promote_op
@@ -99,7 +101,6 @@ include("types/SisoTf.jl")
99101

100102
# Transfer functions and tranfer function elemements
101103
include("types/TransferFunction.jl")
102-
include("types/SisoTfTypes/polyprint.jl")
103104
include("types/SisoTfTypes/SisoZpk.jl")
104105
include("types/SisoTfTypes/SisoRational.jl")
105106
include("types/SisoTfTypes/promotion.jl")

src/analysis.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""`pole(sys)`
22
33
Compute the poles of system `sys`."""
4-
pole(sys::AbstractStateSpace) = eigvals(sys.A)
4+
pole(sys::AbstractStateSpace) = eigvalsnosort(sys.A)
55
pole(sys::SisoTf) = error("pole is not implemented for type $(typeof(sys))")
66

77
# Seems to have a lot of rounding problems if we run the full thing with sisorational,
@@ -224,7 +224,7 @@ function tzero(A::AbstractMatrix{T}, B::AbstractMatrix{T}, C::AbstractMatrix{T},
224224
m = size(D_rc, 2)
225225
Af = ([A_rc B_rc] * W)[1:nf, 1:nf]
226226
Bf = ([Matrix{T}(I, nf, nf) zeros(nf, m)] * W)[1:nf, 1:nf]
227-
zs = eigvals(Af, Bf)
227+
zs = eigvalsnosort(Af, Bf)
228228
_fix_conjugate_pairs!(zs) # Generalized eigvals does not return exact conj. pairs
229229
else
230230
zs = complex(T)[]

src/matrix_comps.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ function dare(A, B, Q, R)
4747
if (!isposdef(R))
4848
error("R must be positive definite.");
4949
end
50-
50+
5151
n = size(A, 1);
52-
52+
5353
E = [
5454
Matrix{Float64}(I, n, n) B/R*B';
5555
zeros(size(A)) A'
@@ -58,10 +58,10 @@ function dare(A, B, Q, R)
5858
A zeros(size(A));
5959
-Q Matrix{Float64}(I, n, n)
6060
];
61-
61+
6262
QZ = schur(F, E);
6363
QZ = ordschur(QZ, abs.(QZ.alpha./QZ.beta) .< 1);
64-
64+
6565
return QZ.Z[(n+1):end, 1:n]/QZ.Z[1:n, 1:n];
6666
end
6767

@@ -292,7 +292,7 @@ function normLinf_twoSteps_ct(sys::AbstractStateSpace, tol=1e-6, maxIters=1000,
292292
if isreal(p) # only real poles
293293
omegap = minimum(abs.(p))
294294
else # at least one pair of complex poles
295-
tmp = maximum(abs.(imag.(p)./(real.(p).*abs.(p))))
295+
tmp = abs.(imag.(p)./(real.(p).*abs.(p)))
296296
omegap = abs(p[argmax(tmp)]) # TODO This is highly suspicious
297297
end
298298
(lb, idx) = findmax([lb, T(maximum(svdvals(evalfr(sys, omegap*1im))))]) #TODO remove T() in julia 0.7.0

src/types/SisoTfTypes/polyprint.jl

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/types/conversion.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ end
285285
# TODO: Could perhaps be made more accurate. See: An accurate and efficient
286286
# algorithm for the computation of the # characteristic polynomial of a general square matrix.
287287
function charpoly(A::AbstractMatrix{<:Number})
288-
Λ = eigvals(A)
288+
Λ = eigvalsnosort(A)
289289

290290
return prod(roots2poly_factors(Λ)) # Compute the polynomial factors directly?
291291
end
292292
function charpoly(A::AbstractMatrix{<:Real})
293-
Λ = eigvals(A)
293+
Λ = eigvalsnosort(A)
294294
return prod(roots2real_poly_factors(Λ))
295295
end
296296

src/utilities.jl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,38 @@ to_matrix(T, A::Number) = fill(T(A), 1, 1)
1616
# Handle Adjoint Matrices
1717
to_matrix(T, A::Adjoint{R, MT}) where {R<:Number, MT<:AbstractMatrix} = to_matrix(T, MT(A))
1818

19+
# Do no sorting of eigenvalues
20+
@static if VERSION > v"1.2.0-DEV.0"
21+
eigvalsnosort(args...; kwargs...) = eigvals(args...; sortby=nothing, kwargs...)
22+
roots(args...; kwargs...) = Polynomials.roots(args...; sortby=nothing, kwargs...)
23+
else
24+
eigvalsnosort(args...; kwargs...) = eigvals(args...; kwargs...)
25+
roots(args...; kwargs...) = Polynomials.roots(args...; kwargs...)
26+
end
1927

28+
""" f = printpolyfun(var)
29+
`fun` Prints polynomial in descending order, with variable `var`
30+
"""
31+
printpolyfun(var) = (io, p, mimetype = MIME"text/plain"()) -> Polynomials.printpoly(io, p, mimetype, descending_powers=true, var=var)
2032

2133
# NOTE: Tolerances for checking real-ness removed, shouldn't happen from LAPACK?
2234
# TODO: This doesn't play too well with dual numbers..
2335
# Allocate for maxiumum possible length of polynomial vector?
2436
#
2537
# This function rely on that the every complex roots is followed by its exact conjugate,
26-
# and that the first complex root in each pair has positive real part. This formaat is always
38+
# and that the first complex root in each pair has positive imaginary part. This format is always
2739
# returned by LAPACK routines for eigenvalues.
2840
function roots2real_poly_factors(roots::Vector{cT}) where cT <: Number
2941
T = real(cT)
3042
poly_factors = Vector{Poly{T}}()
31-
@static if VERSION > v"1.2.0-DEV.0" # Sort one more time to handle GenericLinearAlgebra not being updated
32-
sort!(roots, by=LinearAlgebra.eigsortby)
33-
end
3443
for k=1:length(roots)
3544
r = roots[k]
3645

3746
if isreal(r)
3847
push!(poly_factors,Poly{T}([-real(r),1]))
3948
else
40-
@static if VERSION > v"1.2.0-DEV.0" # Flipped order in this version
41-
if imag(r) > 0 # This roots was handled in the previous iteration # TODO: Fix better error handling
42-
continue
43-
end
44-
else
45-
if imag(r) < 0 # This roots was handled in the previous iteration # TODO: Fix better error handling
46-
continue
47-
end
49+
if imag(r) < 0 # This roots was handled in the previous iteration # TODO: Fix better error handling
50+
continue
4851
end
4952

5053
if k == length(roots) || r != conj(roots[k+1])

test/test_synthesis.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ A = randn(3,3)
6363
B = randn(3,1)
6464
p = [3.0,2,1]
6565
K = ControlSystems.acker(A,B,p)
66-
@test eigvals(A-B*K) p
66+
@test ControlSystems.eigvalsnosort(A-B*K) p
6767

6868
p = [-1+im, -1-im, -1]
6969
K = ControlSystems.acker(A,B,p)
70-
@test eigvals(A-B*K) p
70+
@test ControlSystems.eigvalsnosort(A-B*K) p
7171
end
7272

7373
end

0 commit comments

Comments
 (0)