(mat_shape, dtype)
return mult_gpu
Generate multiplication matrix for 2D trapezoidal integration.

    Generates a matrix whose dot product with some other matrix of
    equal length (when flattened) is equivalent to the definite double
    integral of the latter computed using trapezoidal integration.

    Parameters
    ----------
    mat_shape : tuple
        Shape of matrix.
    dtype : float type
        Floating point type to use when generating the array.

    Returns
    -------
    result : pycuda.gpuarray.GPUArray
        Generated matrix.
Generate multiplication matrix for 2D trapezoidal integration.
Generate multiplication matrix for 2D trapezoidal integration .
def gen_trapz2d_mult(mat_shape, dtype):
    """
    Generate multiplication matrix for 2D trapezoidal integration.

    Generates a matrix whose dot product with some other matrix of
    equal length (when flattened) is equivalent to the definite double
    integral of the latter computed using trapezoidal integration.

    Parameters
    ----------
    mat_shape : tuple
        Shape of matrix.
    dtype : float type
        Floating point type to use when generating the array.

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

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

    use_double = int(dtype in [np.float64, np.complex128])
    use_complex = int(dtype in [np.complex64, np.complex128])

    # Allocate output matrix:
    Ny, Nx = mat_shape
    mult_gpu = gpuarray.empty(mat_shape, dtype)

    # Get block/grid sizes:
    dev = misc.get_current_device()
    block_dim, grid_dim = misc.select_block_grid_sizes(dev, mat_shape)
    gen_trapz2d_mult = _get_trapz2d_mult_kernel(use_double, use_complex)
    gen_trapz2d_mult(mult_gpu, np.uint32(Ny), np.uint32(Nx),
                     block=block_dim,
                     grid=grid_dim)

    return mult_gpu
def gen_trapz2d_mult ( mat_shape , dtype ) : if dtype not in [ np . float32 , np . float64 , np . complex64 , np . complex128 ] : raise ValueError ( 'unrecognized type' ) use_double = int ( dtype in [ np . float64 , np . complex128 ] ) use_complex = int ( dtype in [ np . complex64 , np . complex128 ] ) # Allocate output matrix: Ny , Nx = mat_shape mult_gpu = gpuarray . empty ( mat_shape , dtype ) # Get block/grid sizes: dev = misc . get_current_device ( ) block_dim , grid_dim = misc . select_block_grid_sizes ( dev , mat_shape ) gen_trapz2d_mult = _get_trapz2d_mult_kernel ( use_double , use_complex ) gen_trapz2d_mult ( mult_gpu , np . uint32 ( Ny ) , np . uint32 ( Nx ) , block = block_dim , grid = grid_dim ) return mult_gpu