I think ols_matrix is a re-implementation of np.linalg.pinv. When the rows of A are linearly independent `pinv(A)` is `(A' x A)^{-1} A'` (but I think it's implemented slightly differently to be more numerically stable).

http://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_pseudoinverse#Linearly_independent_rows