The pseudo-inverse, returned by pinv, is equal to a right inverse (or left inverse), if one exists:
julia> using LinearAlgebra
julia> A = [1 2 3; 0 1 2]
2×3 Matrix{Int64}:
1 2 3
0 1 2
julia> A * pinv(A) ≈ I
true
(Edit: Note that right or left inverses are not generally unique, however. Also, in most practical applications, it is a truism of numerical linear algebra that one should avoid computing inverses explicitly if possible.)
With A*X = I, I would think that X = A\I should give the right inverse??
Is it unique? As far as I remember one of Gilbert Strang’s books on linear algebra, if the system has a non-trivial null space, the solution is chosen such that some norm of X is minimized (at least in the pseudoinverse case). This minimal norm criterion probably makes the solution unique, but I don’t know whether this carries over to right/left inverses.
The pseudo inverse is unique. Right inverses (for non-square matrices) are not. (That’s because Ax=b does not have unique solutions for a “wide” matrix: the problem is underdetermined.)
If you additionally request the minimum-norm solution (which is a choice, and may or may not be the best choice for a given application), that gives a unique solution and a unique right inverse equal to the pseudo inverse.
Or just use x = A \ b, which gives the minimum norm solution without explicitly computing the right/pseudo inverse matrix.
You first have to precisely define which right inverse you want, if you don’t want the pseudo inverse. (Equivalently, define which solution of Ax=b you want, if you don’t want the minimum norm solution,)