scikits.cuda.cublas.cublasCaxpy

scikits.cuda.cublas.cublasCaxpy(handle, n, alpha, x, incx, y, incy)[source]

Vector addition (single-precision complex).

Computes the sum of a single-precision complex vector scaled by a single-precision complex scalar and another single-precision complex vector.

Parameters:

handle : int

CUBLAS context.

n : int

Number of elements in input vectors.

alpha : numpy.complex64

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.

Notes

Both x and y must contain n elements.

Examples

>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> alpha = np.complex64(np.random.rand()+1j*np.random.rand())
>>> x = (np.random.rand(5)+1j*np.random.rand(5)).astype(np.complex64)
>>> y = (np.random.rand(5)+1j*np.random.rand(5)).astype(np.complex64)
>>> x_gpu = gpuarray.to_gpu(x)
>>> y_gpu = gpuarray.to_gpu(y)
>>> h = cublasCreate()
>>> cublasCaxpy(h, x_gpu.size, alpha, x_gpu.gpudata, 1, y_gpu.gpudata, 1)
>>> cublasDestroy(h)
>>> np.allclose(y_gpu.get(), alpha*x+y)
True