skcuda.cublas.cublasDasum¶
-
skcuda.cublas.
cublasDasum
(handle, n, x, incx)[source]¶ Sum of absolute values of double precision real vector.
Computes the sum of the absolute values of the elements of a double precision real vector.
Note: if the vector is complex, then this computes the sum sum(abs(x.real)) + sum(abs(x.imag))
Parameters: - handle (int) – CUBLAS context.
- n (int) – Number of elements in input vector.
- x (ctypes.c_void_p) – Pointer to double precision real input vector.
- incx (int) – Storage spacing between elements of x.
Examples
>>> import pycuda.autoinit >>> import pycuda.gpuarray as gpuarray >>> import numpy as np >>> x = np.random.rand(5).astype(np.float64) >>> x_gpu = gpuarray.to_gpu(x) >>> h = cublasCreate() >>> s = cublasDasum(h, x_gpu.size, x_gpu.gpudata, 1) >>> cublasDestroy(h) >>> np.allclose(s, abs(x.real).sum() + abs(x.imag).sum()) True
Returns: s – Sum of absolute values. Return type: numpy.float64 References