Compiling for CUDA
Refactoring math and matrix functions