Skip to content

Commit

Permalink
Define factorize(Adjoint/Transpose) to make e.g. inv(Adjoint/Transpos…
Browse files Browse the repository at this point in the history
…e) (#26302)

work (in most cases)
  • Loading branch information
andreasnoack committed Mar 7, 2018
1 parent fa462ba commit 8613942
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stdlib/LinearAlgebra/src/dense.jl
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions stdlib/LinearAlgebra/test/dense.jl
Expand Up @@ -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

0 comments on commit 8613942

Please sign in to comment.