scikits.cuda.cublas.cublasDdot

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

Vector dot product (double-precision real)

Computes the dot product of two double-precision real 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 double-precision real input vector.

incx : int

Storage spacing between elements of x.

y : ctypes.c_void_p

Pointer to double-precision real input/output vector.

incy : int

Storage spacing between elements of y.

Returns:

d : np.float64

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.float64(np.random.rand(5))
>>> y = np.float64(np.random.rand(5))
>>> x_gpu = gpuarray.to_gpu(x)
>>> y_gpu = gpuarray.to_gpu(y)
>>> h = cublasCreate()
>>> d = cublasDdot(h, x_gpu.size, x_gpu.gpudata, 1, y_gpu.gpudata, 1)
>>> cublasDestroy(h)
>>> np.allclose(d, np.dot(x, y))
True