Skip to content
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 src/pinv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
return _pinv(A_S, atol, rtol)
end

@inline pinv(A::LinearAlgebra.HermOrSym{T,<:StaticMatrix}; kwargs...) where T = pinv(convert(similar_type(A), A); kwargs...)

@inline function _pinv(A::StaticMatrix{m,n,T}, atol::Real, rtol::Real) where T where m where n
if m == 0 || n == 0
return similar_type(A, Size(n,m))()
Expand Down
7 changes: 7 additions & 0 deletions test/pinv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,11 @@ tol = 1e-13
@test norm(N10*M10*N10 - N10) < tol
@test N10 isa StaticMatrix
@test N10 ≈ pinv(Matrix(M10))

for wrapper in (Symmetric, Hermitian)
M_w = wrapper(@SMatrix [1.0 0.5; 0.5 2.0])
N_w = pinv(M_w)
@test N_w ≈ pinv(Matrix(M_w))
@test N_w isa SMatrix{2,2,Float64}
end
end
Loading