Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define factorize(Adjoint) to make e.g. inv(Adjoint) work (in most cases) #26302

Merged
merged 1 commit into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stdlib/LinearAlgebra/src/dense.jl
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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