Skip to content

Commit 755df8e

Browse files
Add inv(::AbstractQ) (#35826)
* Override `inv` for `AbstractQ` * Add test for inv * Update qr.jl Co-authored-by: Andreas Noack <andreas@noack.dk>
1 parent 826b16a commit 755df8e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

stdlib/LinearAlgebra/src/qr.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ Base.propertynames(F::QRPivoted, private::Bool=false) =
467467

468468
abstract type AbstractQ{T} <: AbstractMatrix{T} end
469469

470+
inv(Q::AbstractQ) = Q'
471+
470472
"""
471473
QRPackedQ <: AbstractMatrix
472474

stdlib/LinearAlgebra/test/qr.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,11 @@ end
297297
end
298298
end
299299

300+
@testset "inv(::AbstractQ)" begin
301+
for T in (Float64, ComplexF64)
302+
Q = qr(randn(T,5,5)).Q
303+
@test inv(Q) === Q'
304+
end
305+
end
306+
300307
end # module TestQR

0 commit comments

Comments
 (0)