Skip to content

Commit

Permalink
Define factorize(Adjoint/Transpose) to make e.g. inv(Adjoint/Transpose)
Browse files Browse the repository at this point in the history
work (in most cases)
  • Loading branch information
andreasnoack committed Mar 3, 2018
1 parent be4e39f commit cfee1b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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
13 changes: 13 additions & 0 deletions stdlib/LinearAlgebra/test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -847,4 +847,17 @@ 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)

@test_broken inv(B')*B' I
@test_broken inv(transpose(B))*transpose(B) I
end

end # module TestDense

0 comments on commit cfee1b8

Please sign in to comment.