Skip to content

Documentation of pinv is wrong; also, methods behave differently #444

Open
@Clemens-H

Description

@Clemens-H

(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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions