let A be a m by n matrix considered as a list of columns
construct B, an n by m matrix (considered as a list of rows), by elimination
such that BAB = B, ABA = A and AB an orthogonal projection onto the image of A
in exact artihmetic and pythonesque psuedo-code:
B = array(A)
for k,a in enumerate(A):
v = B[k] # pivot row
va = inner(v,a)
if va: # note that v nonzero if and only if va positive
v *= 1/va # scale on <a>
for j,b in enumerate(B):
if j == k: continue
b = b - inner(b,a)*v # elimination on <a>