(N, dtype)
return x_gpu
Generate multiplication array for 1D trapezoidal integration.

    Generates an array whose dot product with some array of equal
    length is equivalent to the definite integral of the latter
    computed using trapezoidal integration.

    Parameters
    ----------
    N : int
        Length of array.
    dtype : float type
        Floating point type to use when generating the array.

    Returns
    -------
    result : pycuda.gpuarray.GPUArray
        Generated array.
Generate multiplication array for 1D trapezoidal integration.
Generate multiplication array for 1D trapezoidal integration .
def gen_trapz_mult(N, dtype):
    """
    Generate multiplication array for 1D trapezoidal integration.

    Generates an array whose dot product with some array of equal
    length is equivalent to the definite integral of the latter
    computed using trapezoidal integration.

    Parameters
    ----------
    N : int
        Length of array.
    dtype : float type
        Floating point type to use when generating the array.

    Returns
    -------
    result : pycuda.gpuarray.GPUArray
        Generated array.
    """

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

    ctype = tools.dtype_to_ctype(dtype)
    func = elementwise.ElementwiseKernel("{ctype} *x".format(ctype=ctype),
                                         "x[i] = ((i == 0) || (i == {M})) ? 0.5 : 1".format(M=N-1))
    x_gpu = gpuarray.empty(N, dtype)
    func(x_gpu)
    return x_gpu
def gen_trapz_mult ( N , dtype ) : if dtype not in [ np . float32 , np . float64 , np . complex64 , np . complex128 ] : raise ValueError ( 'unrecognized type' ) ctype = tools . dtype_to_ctype ( dtype ) func = elementwise . ElementwiseKernel ( "{ctype} *x" . format ( ctype = ctype ) , "x[i] = ((i == 0) || (i == {M})) ? 0.5 : 1" . format ( M = N - 1 ) ) x_gpu = gpuarray . empty ( N , dtype ) func ( x_gpu ) return x_gpu