scikits.cuda.cublas.cublasCdotu

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

Vector dot product (single-precision complex)

Computes the dot product of two single-precision complex vectors. cublasCdotc and cublasZdotc use the conjugate of the first vector when computing the dot product.

Parameters:

handle : int

CUBLAS context.

n : int

Number of elements in input vectors.

x : ctypes.c_void_p

Pointer to single-precision complex input vector.

incx : int

Storage spacing between elements of x.

y : ctypes.c_void_p

Pointer to single-precision complex input/output vector.

incy : int

Storage spacing between elements of y.

Returns:

d : np.complex64

Dot product of x and y.

Notes

Both x and y must contain n elements.

Examples

>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> 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()
>>> d = cublasCdotu(h, x_gpu.size, x_gpu.gpudata, 1, y_gpu.gpudata, 1)
>>> cublasDestroy(h)
>>> np.allclose(d, np.dot(x, y))
True