Fix off-by-one error
Suppress warnings
Add CUDA implementation
Standardise code