Fix issue with Eigen when matrix determinant is nearly 0
also fix error message for singular matrix