scikits.cuda.cublas.cublasDrot

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

Apply a real rotation to real vectors (double-precision)

Multiplies the double-precision matrix [[c, s], [-s.conj(), c]] with the 2 x n double-precision matrix [[x.T], [y.T]].

Parameters:

handle : int

CUBLAS context.

n : int

Number of elements in input vectors.

x : ctypes.c_void_p

Pointer to double-precision real input/output 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.

c : numpy.float64

Element of rotation matrix.

s : numpy.float64

Element of rotation matrix.

Notes

Both x and y must contain n elements.

Examples

>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> s = np.float64(np.random.rand()); c = 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()
>>> cublasDrot(h, x.size, x_gpu.gpudata, 1, y_gpu.gpudata, 1, c, s)
>>> cublasDestroy(h)
>>> np.allclose(x_gpu.get(), c*x+s*y)
True
>>> np.allclose(y_gpu.get(), -s.conj()*x+c*y)
True