fixed the division by zero.
fixed typos.
Merge pull request #1823 from caglar/cuda_ndarray_fix

Cuda ndarray fix