Skip to content

Commit f3eecbb

Browse files
committed
lu -> svd
1 parent 52c73fa commit f3eecbb

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

src/hinfinity_design.jl

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,16 @@ function _synthesizecontroller(
254254
D1122 = D11[(P1-M2+1):P1, (M1-P2+1):M1]
255255

256256
# Equation 19
257-
D11hat = ((-D1121 * D1111') / (γ² * I - D1111 * D1111')) * D1112 - D1122
257+
J1 = (γ² * I - D1111 * D1111')
258+
D11hat = ((-D1121 * D1111') / J1) * D1112 - D1122
258259

259260
# Equation 20
260261
D12hatD12hat = I - (D1121 / (γ² * I - D1111' * D1111)) * D1121'
261262
_assertrealandpsd(D12hatD12hat; msg = " in equation (20)")
262263
D12hat = cholesky(Hermitian(D12hatD12hat)).L
263264

264265
# Equation 21
265-
D21hatD21hat = I - (D1112' / (γ² * I - D1111 * D1111')) * D1112
266+
D21hatD21hat = I - (D1112' / J1) * D1112
266267
_assertrealandpsd(D21hatD21hat; msg = " in equation (21)")
267268
D21hat = cholesky(Hermitian(D21hatD21hat)).U
268269

@@ -306,6 +307,29 @@ function _synthesizecontroller(
306307
return ss(Ac, Bc[:, 1:P2], Cc[1:M2, :], D11c)
307308
end
308309

310+
"""
311+
rqr(D, γ=1)
312+
313+
"Regularized" qr factorization. This struct represents \$(D'D + γI)\$ without forming \$D'D\$
314+
Note: this does not support negative γ or \$(γI - D'D)\$
315+
Supported operations: `\\,/,*`, i.e., it behaves also like a matrix (unlike the standard `QR` factorization object).
316+
"""
317+
struct rqr{T, PT, DGT}
318+
P::PT
319+
DG::DGT
320+
function rqr(D, γ=1)
321+
P = (D'D) + γ*I
322+
DG = qr([D; (γ)I])
323+
new{eltype(P), typeof(P), typeof(DG)}(P, DG)
324+
end
325+
end
326+
327+
Base.:\(d::rqr, b) = (d.DG.R\(adjoint(d.DG.R)\b))
328+
Base.:/(b, d::rqr) = ((b/d.DG.R)/adjoint(d.DG.R))
329+
Base.:*(d::rqr, b) = (d.P*b)
330+
Base.:*(b, d::rqr) = (b*d.P)
331+
332+
309333
"""
310334
_assertrealandpsd(A::AbstractMatrix, msg::AbstractString)
311335
@@ -374,7 +398,7 @@ function _solvehamiltonianare(H)#::AbstractMatrix{<:LinearAlgebra.BlasFloat})
374398
U11 = S.Z[1:div(m, 2), 1:div(n, 2)]
375399
U21 = S.Z[div(m, 2)+1:m, 1:div(n, 2)]
376400

377-
return U21 / U11
401+
return U21 * pinv(U11)
378402
end
379403

380404
"""

0 commit comments

Comments
 (0)