Completed inverse function for matrix.js