scikits.cuda.linalg.multiply

scikits.cuda.linalg.multiply(x_gpu, y_gpu, overwrite=True)[source]

Multiply arguments element-wise.

Parameters:

x_gpu, y_gpu : pycuda.gpuarray.GPUArray

Input arrays to be multiplied.

dev : pycuda.driver.Device

Device object to be used.

overwrite : bool

If true (default), return the result in y_gpu. is false, return the result in a newly allocated array.

Returns:

z_gpu : pycuda.gpuarray.GPUArray

The element-wise product of the input arrays.

Examples

>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> import linalg
>>> linalg.init()
>>> x = np.asarray(np.random.rand(4, 4), np.float32)
>>> y = np.asarray(np.random.rand(4, 4), np.float32)
>>> x_gpu = gpuarray.to_gpu(x)
>>> y_gpu = gpuarray.to_gpu(y)
>>> z_gpu = linalg.multiply(x_gpu, y_gpu)
>>> np.allclose(x*y, z_gpu.get())
True