Skip to content

Commit

Permalink
Add inv(::AbstractQ) (JuliaLang#35826)
Browse files Browse the repository at this point in the history
* Override `inv` for `AbstractQ`

* Add test for inv

* Update qr.jl

Co-authored-by: Andreas Noack <[email protected]>
  • Loading branch information
2 people authored and Roger-luo committed May 14, 2020
1 parent 00154da commit a6fe51a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stdlib/LinearAlgebra/src/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ Base.propertynames(F::QRPivoted, private::Bool=false) =

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

inv(Q::AbstractQ) = Q'

"""
QRPackedQ <: AbstractMatrix
Expand Down
7 changes: 7 additions & 0 deletions stdlib/LinearAlgebra/test/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,11 @@ end
end
end

@testset "inv(::AbstractQ)" begin
for T in (Float64, ComplexF64)
Q = qr(randn(T,5,5)).Q
@test inv(Q) === Q'
end
end

end # module TestQR

0 comments on commit a6fe51a

Please sign in to comment.