@@ -2,23 +2,25 @@ function freqresp(sys::DelayLtiSystem, ω::AbstractVector{T}) where {T <: Real}
22 ny = noutputs (sys)
33 nu = ninputs (sys)
44
5- P_fr = freqresp (sys. P. P, ω);
5+ P_fr = freqresp (sys. P. P, ω). parent
66
7- G_fr = zeros (eltype (P_fr), length (ω), ny, nu)
7+ G_fr = zeros (eltype (P_fr), ny, nu, length (ω) )
88
9- for ω_idx= 1 : length (ω)
10- P11_fr = P_fr[ω_idx, 1 : ny, 1 : nu]
11- P12_fr = P_fr[ω_idx, 1 : ny, nu+ 1 : end ]
12- P21_fr = P_fr[ω_idx, ny+ 1 : end , 1 : nu]
13- P22_fr = P_fr[ω_idx, ny+ 1 : end , nu+ 1 : end ]
9+ cache = cis .(ω[1 ]. * sys. Tau)
1410
15- delay_matrix_inv_fr = Diagonal (exp .(im* ω[ω_idx]* sys. Tau)) # Frequency response of the diagonal matrix with delays
11+ @views for ω_idx= 1 : length (ω)
12+ P11_fr = P_fr[1 : ny, 1 : nu, ω_idx]
13+ P12_fr = P_fr[1 : ny, nu+ 1 : end , ω_idx]
14+ P21_fr = P_fr[ny+ 1 : end , 1 : nu, ω_idx]
15+ P22_fr = P_fr[ny+ 1 : end , nu+ 1 : end , ω_idx]
16+ @. cache = cis (ω[ω_idx]* sys. Tau)
17+ delay_matrix_inv_fr = Diagonal (cache) # Frequency response of the diagonal matrix with delays
1618 # Inverse of the delay matrix, so there should not be any minus signs in the exponents
1719
18- G_fr[ω_idx, :,:] .= P11_fr + P12_fr/ (delay_matrix_inv_fr - P22_fr)* P21_fr # The matrix is invertible (?!)
20+ G_fr[:,:,ω_idx ] .= P11_fr . + P12_fr/ (delay_matrix_inv_fr - P22_fr)* P21_fr # The matrix is invertible (?!)
1921 end
2022
21- return G_fr
23+ return PermutedDimsArray ( G_fr, ( 3 , 1 , 2 ))
2224end
2325
2426function evalfr (sys:: DelayLtiSystem , s)
0 commit comments