scikits.cuda.misc.cumsum

scikits.cuda.misc.cumsum(x_gpu)[source]

Cumulative sum.

Return the cumulative sum of the elements in the specified array.

Parameters:

x_gpu : pycuda.gpuarray.GPUArray

Input array.

Returns:

c_gpu : pycuda.gpuarray.GPUArray

Output array containing cumulative sum of x_gpu.

Notes

Higher dimensional arrays are implicitly flattened row-wise by this function.

Examples

>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import misc
>>> x_gpu = gpuarray.to_gpu(np.random.rand(5).astype(np.float32))
>>> c_gpu = misc.cumsum(x_gpu)
>>> np.allclose(c_gpu.get(), np.cumsum(x_gpu.get()))
True