@@ -35,12 +35,12 @@ function poles(sys::TransferFunction{<:TimeEvolution,SisoZpk{T,TR}}) where {T, T
3535 return lcmpoles
3636end
3737
38+ # TODO : Improve implementation, should be more efficient ways.
39+ # Calculates the same minors several times in some cases.
3840"""
3941 minorpoles(sys)
4042
4143Compute the poles of all minors of the system."""
42- # TODO : Improve implementation, should be more efficient ways.
43- # Calculates the same minors several times in some cases.
4444function minorpoles (sys:: Matrix{SisoZpk{T, TR}} ) where {T, TR}
4545 minors = Array{TR,1 }[]
4646 ny, nu = size (sys)
@@ -68,11 +68,11 @@ function minorpoles(sys::Matrix{SisoZpk{T, TR}}) where {T, TR}
6868 return minors
6969end
7070
71+ # TODO : improve this implementation, should be more efficient ones
7172"""
7273 det(sys)
7374
7475Compute the determinant of the Matrix `sys` of SisoTf systems, returns a SisoTf system."""
75- # TODO : improve this implementation, should be more efficient ones
7676function det (sys:: Matrix{S} ) where {S<: SisoZpk }
7777 ny, nu = size (sys)
7878 ny == nu || throw (ArgumentError (" sys matrix is not square" ))
@@ -146,13 +146,13 @@ poles, `ps`, of `sys`"""
146146function damp (sys:: LTISystem )
147147 ps = poles (sys)
148148 if isdiscrete (sys)
149- ps = log . (complex . (ps))/ sys. Ts
149+ ps = @. log (complex (ps))/ sys. Ts
150150 end
151151 Wn = abs .(ps)
152152 order = sortperm (Wn; by= z-> (abs (z), real (z), imag (z)))
153153 Wn = Wn[order]
154154 ps = ps[order]
155- ζ = - cos . (angle . (ps))
155+ ζ = @. - cos (angle (ps))
156156 return Wn, ζ, ps
157157end
158158
@@ -279,8 +279,7 @@ function reduce_sys(A::AbstractMatrix, B::AbstractMatrix, C::AbstractMatrix, D::
279279 end
280280
281281 # Compress columns of Ctilde
282- V = qr (Ctilde' ). Q
283- V = reverse (V,dims= 2 )
282+ V = reverse (qr (Ctilde' ). Q, dims= 2 )
284283 Sj = Ctilde* V
285284 rho = fastrank (Sj' , meps)
286285 nu = size (Sj, 2 ) - rho
@@ -294,7 +293,7 @@ function reduce_sys(A::AbstractMatrix, B::AbstractMatrix, C::AbstractMatrix, D::
294293 end
295294 # Update System
296295 n, m = size (B)
297- Vm = [V zeros (T, n, m); zeros (T, m, n) Matrix {T} (I, m, m)]
296+ Vm = [V zeros (T, n, m); zeros (T, m, n) Matrix {T} (I, m, m)] # I(m) is not used for type stability reasons (as of julia v1.7)
298297 if sigma > 0
299298 M = [A B; Cbar Dbar]
300299 Vs = [V' zeros (T, n, sigma) ; zeros (T, sigma, n) Matrix {T} (I, sigma, sigma)]
@@ -403,14 +402,13 @@ function relative_gain_array(A::AbstractMatrix; tol = 1e-15)
403402end
404403
405404"""
406- ` ωgₘ, gₘ, ωϕₘ, ϕₘ = margin{S<:Real} (sys::LTISystem, w::AbstractVector{S} ; full=false, allMargins=false)`
405+ ωgₘ, gₘ, ωϕₘ, ϕₘ = margin(sys::LTISystem, w::Vector ; full=false, allMargins=false)
407406
408407returns frequencies for gain margins, gain margins, frequencies for phase margins, phase margins
409408
410409If `!allMargins`, return only the smallest margin
411410
412411If `full` return also `fullPhase`
413-
414412"""
415413function margin (sys:: LTISystem , w:: AbstractVector{<:Real} ; full= false , allMargins= false )
416414 ny, nu = size (sys)
@@ -441,7 +439,7 @@ function margin(sys::LTISystem, w::AbstractVector{<:Real}; full=false, allMargin
441439end
442440
443441"""
444- ` ωgₘ, gₘ, ωϕₘ, ϕₘ = sisomargin{S<:Real} (sys::LTISystem, w::AbstractVector{S} ; full=false, allMargins=false)`
442+ ωgₘ, gₘ, ωϕₘ, ϕₘ = sisomargin(sys::LTISystem, w::Vector ; full=false, allMargins=false)
445443
446444returns frequencies for gain margins, gain margins, frequencies for phase margins, phase margins
447445"""
@@ -588,19 +586,13 @@ end
588586Given transfer functions describing the Plant `P`, the controller `C` and a feed forward block `F`,
589587computes the four transfer functions in the Gang-of-Four and the transferfunctions corresponding to the feed forward.
590588
591- `S = 1/(1+PC)` Sensitivity function
592-
593- `PS = P/(1+PC)`
594-
595- `CS = C/(1+PC)`
596-
597- `T = PC/(1+PC)` Complementary sensitivity function
598-
599- `RY = PCF/(1+PC)`
600-
601- `RU = CF/(1+P*C)`
602-
603- `RE = F/(1+P*C)`
589+ - `S = 1/(1+PC)` Sensitivity function
590+ - `PS = P/(1+PC)`
591+ - `CS = C/(1+PC)`
592+ - `T = PC/(1+PC)` Complementary sensitivity function
593+ - `RY = PCF/(1+PC)`
594+ - `RU = CF/(1+P*C)`
595+ - `RE = F/(1+P*C)`
604596
605597Only supports SISO systems"""
606598function gangofseven (P:: TransferFunction , C:: TransferFunction , F:: TransferFunction )
0 commit comments