Refactored float[,] to Matrix2D<float>

Refactored arrays to be wrapped by Matrix2D<> in order to associate GPU
resident arrays with the gpu and also track array dimensions.
Refactored the calls to cuda.