(x_gpu, y_gpu, overwrite=False)
Element-wise array multiplication (Hadamard product).

    Parameters
    ----------
    x_gpu, y_gpu : pycuda.gpuarray.GPUArray
        Input arrays to be multiplied.
    dev : pycuda.driver.Device
        Device object to be used.
    overwrite : bool (default: False)
        If true, 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 skcuda.linalg as 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
Element-wise array multiplication (Hadamard product).
Element - wise array multiplication ( Hadamard product ) .
def multiply(x_gpu, y_gpu, overwrite=False):
    """
    Element-wise array multiplication (Hadamard product).

    Parameters
    ----------
    x_gpu, y_gpu : pycuda.gpuarray.GPUArray
        Input arrays to be multiplied.
    dev : pycuda.driver.Device
        Device object to be used.
    overwrite : bool (default: False)
        If true, 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 skcuda.linalg as 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

    """

    alloc = misc._global_cublas_allocator

    if x_gpu.shape != y_gpu.shape:
        raise ValueError('input arrays must have the same shape')

    if x_gpu.dtype not in [np.float32, np.float64, np.complex64,
                           np.complex128]:
        raise ValueError('unrecognized type')

    x_ctype = tools.dtype_to_ctype(x_gpu.dtype)
    y_ctype = tools.dtype_to_ctype(y_gpu.dtype)

    if overwrite:
        func = el.ElementwiseKernel("{x_ctype} *x, {y_ctype} *y".format(x_ctype=x_ctype,
                                                                        y_ctype=y_ctype),
                                    "y[i] *= x[i]")
        func(x_gpu, y_gpu)
        return y_gpu
    else:
        result_type = np.result_type(x_gpu.dtype, y_gpu.dtype)
        z_gpu = gpuarray.empty(x_gpu.shape, result_type, allocator=alloc)
        func = \
               el.ElementwiseKernel("{x_ctype} *x, {y_ctype} *y, {z_type} *z".format(x_ctype=x_ctype,
                                                                                     y_ctype=y_ctype,
                                                                                     z_type=tools.dtype_to_ctype(result_type)),
                                    "z[i] = x[i]*y[i]")
        func(x_gpu, y_gpu, z_gpu)
        return z_gpu
def multiply ( x_gpu , y_gpu , overwrite = False ) : alloc = misc . _global_cublas_allocator if x_gpu . shape != y_gpu . shape : raise ValueError ( 'input arrays must have the same shape' ) if x_gpu . dtype not in [ np . float32 , np . float64 , np . complex64 , np . complex128 ] : raise ValueError ( 'unrecognized type' ) x_ctype = tools . dtype_to_ctype ( x_gpu . dtype ) y_ctype = tools . dtype_to_ctype ( y_gpu . dtype ) if overwrite : func = el . ElementwiseKernel ( "{x_ctype} *x, {y_ctype} *y" . format ( x_ctype = x_ctype , y_ctype = y_ctype ) , "y[i] *= x[i]" ) func ( x_gpu , y_gpu ) return y_gpu else : result_type = np . result_type ( x_gpu . dtype , y_gpu . dtype ) z_gpu = gpuarray . empty ( x_gpu . shape , result_type , allocator = alloc ) func = el . ElementwiseKernel ( "{x_ctype} *x, {y_ctype} *y, {z_type} *z" . format ( x_ctype = x_ctype , y_ctype = y_ctype , z_type = tools . dtype_to_ctype ( result_type ) ) , "z[i] = x[i]*y[i]" ) func ( x_gpu , y_gpu , z_gpu ) return z_gpu