diff --git a/stdlib/LinearAlgebra/src/dense.jl b/stdlib/LinearAlgebra/src/dense.jl index 80ef0071081a1..240f05cd29f90 100644 --- a/stdlib/LinearAlgebra/src/dense.jl +++ b/stdlib/LinearAlgebra/src/dense.jl @@ -1222,6 +1222,8 @@ function factorize(A::StridedMatrix{T}) where T end qrfact(A, Val(true)) end +factorize(A::Adjoint) = adjoint(factorize(parent(A))) +factorize(A::Transpose) = transpose(factorize(parent(A))) ## Moore-Penrose pseudoinverse diff --git a/stdlib/LinearAlgebra/test/dense.jl b/stdlib/LinearAlgebra/test/dense.jl index 0a1dd9ab0ab9e..8a7cac5361b8f 100644 --- a/stdlib/LinearAlgebra/test/dense.jl +++ b/stdlib/LinearAlgebra/test/dense.jl @@ -847,4 +847,19 @@ end end end +@testset "inverse of Adjoint" begin + A = randn(n, n) + + @test inv(A')*A' ≈ I + @test inv(transpose(A))*transpose(A) ≈ I + + B = complex.(A, randn(n, n)) + B = B + transpose(B) + + # The following two cases fail because ldiv!(F::Adjoint/Transpose{BunchKaufman},b) + # isn't implemented yet + @test_broken inv(B')*B' ≈ I + @test_broken inv(transpose(B))*transpose(B) ≈ I +end + end # module TestDense