Andrew,
This could actually be a limitation of computers!
There is the possibility that the values on the data points matrix are close to zero, then when this values get squared, they could be getting to close to zero and due to rounding errors they are interpreted as zero, causing the matrix to be singular and the function is not able to calculate the inverse.
Another possibility is that the determinant of the matrix is zero, due to a row or column being zero or there are some linearly dependant rows/columns.
My suggestion is to print out the original matrix when you get an error and check if the determinant of the matrix is 0.
I hope this can give you some pointers on this problem, let me know if you have any questions.
Regards,
Juan Carlos
N.
I.