Regression code now works is multidimensional, improved code speed

Using sparse matrices decreased code execution time from 20s to 4s