scikits.cuda.cublas.cublasSscal

scikits.cuda.cublas.cublasSscal(handle, n, alpha, x, incx)[source]

Scale a single-precision real vector by a single-precision real scalar.

Replaces a single-precision real vector x with alpha * x.

Parameters:

handle : int

CUBLAS context.

n : int

Number of elements in input vectors.

alpha : numpy.float32

Scalar multiplier.

x : ctypes.c_void_p

Pointer to single-precision real input/output vector.

incx : int

Storage spacing between elements of x.

Examples

>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> x = np.random.rand(5).astype(np.float32)
>>> x_gpu = gpuarray.to_gpu(x)
>>> alpha = np.float32(np.random.rand())
>>> h = cublasCreate()
>>> cublasSscal(h, x.size, alpha, x_gpu.gpudata, 1)
>>> cublasDestroy(h)
>>> np.allclose(x_gpu.get(), alpha*x)
True