Adding inverse and determinant functions to matrix. Taken from www.euclideanspace.com.