Description
(1) The documentation of pinv
does not apply to all methods. In the general, the SVD is used to calculate the pseudoinverse as documented. There is a tolerance when elements in S are considered zero.
julia> pinv([1.0 0.0; 0.0 1.0e-17])
2×2 Array{Float64,2}:
1.0 0.0
0.0 0.0
However, there are also special methods for diagonal matrices. The method pinv(D::Diagonal{T})
doesn't use any tolerance, which is different from the behavior of the general case.
julia> pinv(Diagonal([1.0, 1.0e-17]))
2×2 Diagonal{Float64}:
1.0 ⋅
⋅ 1.0e17
Wouldn't it be better / more consistent to use optional arguments with default values for all methods?
(2) The documentation of pinv
says the default value of the tolerance is eps(real(float(one(eltype(M)))))*maximum(size(A))
. However, in the method pinv(A::StridedMatrix{T}, tol::Real)
, the values actually used are tol*maxabsA
and tol*maximum(SVD.S)
(where tol = eps(real(float(one(T))))*maximum(size(A))
), which is good.