skcuda.cublas.cublasDaxpy¶
-
skcuda.cublas.
cublasDaxpy
(handle, n, alpha, x, incx, y, incy)[source]¶ Vector addition (double precision real).
Computes the sum of a double precision real vector scaled by a double precision real scalar and another double precision real vector.
Parameters: - handle (int) – CUBLAS context.
- n (int) – Number of elements in input vectors.
- alpha (numpy.float64) – Scalar.
- x (ctypes.c_void_p) – Pointer to single precision input vector.
- incx (int) – Storage spacing between elements of x.
- y (ctypes.c_void_p) – Pointer to single precision input/output vector.
- incy (int) – Storage spacing between elements of y.
Examples
>>> import pycuda.autoinit >>> import pycuda.gpuarray as gpuarray >>> import numpy as np >>> alpha = np.float64(np.random.rand()) >>> x = np.random.rand(5).astype(np.float64) >>> y = np.random.rand(5).astype(np.float64) >>> x_gpu = gpuarray.to_gpu(x) >>> y_gpu = gpuarray.to_gpu(y) >>> h = cublasCreate() >>> cublasDaxpy(h, x_gpu.size, alpha, x_gpu.gpudata, 1, y_gpu.gpudata, 1) >>> cublasDestroy(h) >>> np.allclose(y_gpu.get(), alpha*x+y) True
Notes
Both x and y must contain n elements.
References