Пример #1
0
    def inverse_transform( self, G, F ):
        """
        Performs the MDHT of G and stores the result in F
        Reference: see the paper associated with FBPIC

        G: 2darray of real or complex values
        Array containing the values from which to compute the DHT

        F: 2darray of real or complex values
        Array where the result will be stored
        """
        # Perform the matrix product with invM
        if self.use_cuda:
            # Convert C-order, complex array `G` to F-order, real `d_in`
            cuda_copy_2dC_to_2dR[self.dim_grid, self.dim_block](G, self.d_in )
            # Call cuBLAS gemm kernel
            cublas.dgemm(self.blas, 0, 0, self.Nr, 2*self.Nz, self.Nr,
                         1, self.d_invM.data.ptr, self.Nr,
                            self.d_in.data.ptr, self.Nr,
                         0, self.d_out.data.ptr, self.Nr)
            # Convert the F-order d_out array to the C-order F array
            cuda_copy_2dR_to_2dC[self.dim_grid, self.dim_block]( self.d_out, F )
        else:
            # Convert complex array `G` to real array `array_in`
            numba_copy_2dC_to_2dR( G, self.array_in )
            # Perform real matrix product (faster than complex matrix product)
            np.dot( self.array_in, self.invM, out=self.array_out )
            # Convert real array `array_out` to complex array `F`
            numba_copy_2dR_to_2dC( self.array_out, F )
Пример #2
0
    def transform( self, F, G ):
        """
        Perform the Hankel transform of F.

        Parameters:
        ------------
        F: 2darray of complex values
        Array containing the discrete values of the function for which
        the discrete Hankel transform is to be calculated.

        G: 2darray of complex values
        Array where the result will be stored
        """
        # Perform the matrix product with M
        if self.use_cuda:
            # Convert C-order, complex array `F` to F-order, real `d_in`
            cuda_copy_2dC_to_2dR[self.dim_grid, self.dim_block]( F, self.d_in )
            # Call cuBLAS gemm kernel
            cublas.dgemm(self.blas, 0, 0, self.Nr, 2*self.Nz, self.Nr,
                         1, self.d_M.data.ptr, self.Nr,
                            self.d_in.data.ptr, self.Nr,
                         0, self.d_out.data.ptr, self.Nr)
            # Convert F-order, real `d_out` to the C-order, complex `G`
            cuda_copy_2dR_to_2dC[self.dim_grid, self.dim_block]( self.d_out, G )
        else:
            # Convert complex array `F` to real array `array_in`
            numba_copy_2dC_to_2dR( F, self.array_in )
            # Perform real matrix product (faster than complex matrix product)
            np.dot( self.array_in, self.M, out=self.array_out )
            # Convert real array `array_out` to complex array `G`
            numba_copy_2dR_to_2dC( self.array_out, G )