Before I open an Issue, I would like to discuss this question.
The core of the question is the following difference:
julia> 1 / 0
Inf
julia> [1] / [0]
1×1 Array{Float64,2}:
0.0
In my method this lead to a problem as discovered here, because I use the left division with a non-square matrix, which can be full of zeros in some special situation.
I supposed that as a
tends to zero [1]/[a]
tends to infinity
julia> [1] / [0.01]
1×1 Array{Float64,2}:
100.0
julia> [1] / [0.001]
1×1 Array{Float64,2}:
1000.0000000000001
So, I supposed that the limit case will provide Inf if a
is 0.0
.
Furthermore, if squared matrix is used in the division:
julia> [1 0;0 1]/[1 0; 0 0]
ERROR: SingularException(2)
it leads to an error, and I think [0] is squared matrix.
I accept (but I am not happy) that pinv
provides zeros for non-square matrices:
julia> [1 0;0 1; 0 0]/[1 0; 0 0; 0 0]
3×3 Array{Float64,2}:
1.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0
pinv
fullfils all the definition and in the help it is clarifies:
For matrices M with floating point elements, it is convenient to compute the pseudoinverse by inverting only singular values greater than rtol * maximum(svdvals(M)).
I would prefer Inf (or error) if the number of “non-singular values” is smaller then the smaller size of the matix (e.g.: if det(A * A')=0
).
Note, that the same is problem can be found for left and right division (/
,\
). The help shows, that
help?> \
...
\(A, B)
Matrix division using a polyalgorithm. For input matrices A and B, the result X is such that A*X == B when A is square.
but
julia> [0]\[1]
0.0