示例#1
0
        public ILArray </*!HC:HCretArr*/ complex> /*!HC:funcName*/ FFTForward(ILArray </*!HC:HCinArr*/ double> A, int firstDim, int nDims)
        {
            if (A == null || nDims < 0 || firstDim < 0)
            {
                throw new ILArgumentException("invalid parameter!");
            }
            if (A.IsEmpty)
            {
                return(ILArray </*!HC:HCretArr*/ complex> .empty(A.Dimensions));
            }
            if (A.IsScalar || (A.Dimensions[firstDim] == 1 && nDims == 1))
            {
                return /*!HC:convRet*/ (ILMath.tocomplex(A));
            }
            if (nDims > A.Dimensions.NumberOfDimensions)
            {
                nDims = A.Dimensions.NumberOfDimensions;
            }
            // prepare output array
            ILArray </*!HC:HCretArr*/ complex> ret = /*!HC:convRet*/ ILMath.tocomplex(A);
            IntPtr         plan  = IntPtr.Zero;
            int            hrank = 2;
            FFTW_DIRECTION dir   = /*!HC:HCdir*/ FFTW_DIRECTION.FORWARD;

            lock (_lockobject) {
                FFTW_PLANCREATION flags = FFTW_PLANCREATION.ESTIMATE;
                if (nDims > m_n.Length)
                {
                    resizeCache(nDims);
                }
                for (int i = 0; i < nDims; i++)
                {
                    m_n[i]  = A.Dimensions[i + firstDim];
                    m_is[i] = A.Dimensions.SequentialIndexDistance(i + firstDim);
                    m_os[i] = m_is[i];
                }
                m_hn[0]  = A.Dimensions.SequentialIndexDistance(firstDim);
                m_his[0] = 1;
                m_hos[0] = 1;
                m_his[1] = A.Dimensions.SequentialIndexDistance(nDims + firstDim);
                m_hn[1]  = A.Dimensions.NumberOfElements / m_his[1];
                m_hos[1] = m_his[1];
                fixed(/*!HC:HCretArr*/ complex *retArr = ret.m_data)
                {
                    /*!HC:HCplanfun*/ dfftw_plan_guru_dft_(ref plan, ref nDims, m_n, m_is, m_os,
                                                           ref hrank, m_hn, m_his, m_hos,
                                                           retArr, retArr,
                                                           ref dir, ref flags);
                }
            }
            if (plan == IntPtr.Zero)
            {
                throw new ILInvalidOperationException("error creating plan for fftw3 (guru interface)");
            }
            dfftw_execute_(ref plan);
            dfftw_destroy_plan_(ref plan);
            /*!HC:HCbackwScale*/

            return(ret);
        }
示例#2
0
        public ILArray <complex> FFTBackward(ILArray <complex> A, int firstDim, int nDims)
        {
            if (A == null || nDims < 0 || firstDim < 0)
            {
                throw new ILArgumentException("invalid parameter!");
            }
            if (A.IsEmpty)
            {
                return(ILArray <complex> .empty(A.Dimensions));
            }
            if (A.IsScalar || (A.Dimensions[firstDim] == 1 && nDims == 1))
            {
                return(A.C);
            }
            if (nDims > A.Dimensions.NumberOfDimensions)
            {
                nDims = A.Dimensions.NumberOfDimensions;
            }
            // prepare output array
            ILArray <complex> ret  = A.C;
            IntPtr            plan = IntPtr.Zero;
            int            hrank   = 2;
            FFTW_DIRECTION dir     = FFTW_DIRECTION.BACKWARDS;

            lock (_lockobject) {
                FFTW_PLANCREATION flags = FFTW_PLANCREATION.ESTIMATE;
                if (nDims > m_n.Length)
                {
                    resizeCache(nDims);
                }
                for (int i = 0; i < nDims; i++)
                {
                    m_n[i]  = A.Dimensions[i + firstDim];
                    m_is[i] = A.Dimensions.SequentialIndexDistance(i + firstDim);
                    m_os[i] = m_is[i];
                }
                m_hn[0]  = A.Dimensions.SequentialIndexDistance(firstDim);
                m_his[0] = 1;
                m_hos[0] = 1;
                m_his[1] = A.Dimensions.SequentialIndexDistance(nDims + firstDim);
                m_hn[1]  = A.Dimensions.NumberOfElements / m_his[1];
                m_hos[1] = m_his[1];
                fixed(complex *retArr = ret.m_data)
                {
                    dfftw_plan_guru_dft_(ref plan, ref nDims, m_n, m_is, m_os,
                                         ref hrank, m_hn, m_his, m_hos,
                                         retArr, retArr,
                                         ref dir, ref flags);
                }
            }
            if (plan == IntPtr.Zero)
            {
                throw new ILInvalidOperationException("error creating plan for fftw3 (guru interface)");
            }
            dfftw_execute_(ref plan);
            dfftw_destroy_plan_(ref plan);
            ret /= new complex(m_his[1] / m_hn[0], 0.0f);
            return(ret);
        }
示例#3
0
 private static extern void dfftw_plan_dft_(ref IntPtr plan, ref int rank, [In, Out] int[] n, [In, Out] complex *input, [In, Out] complex *output, ref FFTW_DIRECTION sign, ref FFTW_PLANCREATION flags);
示例#4
0
 private static extern void dfftw_plan_many_dft_(ref IntPtr plan, ref int rank, [In, Out] int[] n, ref int howmany, [In, Out] complex *input, [In, Out] int[] inembed, ref int istride, ref int idist, [In, Out] complex *output, [In, Out] int[] onembed, ref int ostride, ref int odist, ref FFTW_DIRECTION sign, ref FFTW_PLANCREATION flags);
示例#5
0
		private static extern void dfftw_plan_dft_(ref IntPtr plan, ref int rank, [In,Out] int[] n, [In,Out] complex* input, [In,Out] complex* output, ref FFTW_DIRECTION sign, ref FFTW_PLANCREATION flags);
示例#6
0
		private static extern void sfftw_plan_guru_dft_(ref IntPtr plan, ref int rank, [In,Out] int[] n, [In,Out] int[] iS,  [In,Out] int[] iO, ref int howmany_rank, [In,Out] int[] hn, [In,Out] int[] hiS,  [In,Out] int[] hiO, [In,Out] fcomplex* input, [In,Out] fcomplex* output, ref FFTW_DIRECTION sign, ref FFTW_PLANCREATION flags);
示例#7
0
 private static extern void sfftw_plan_many_dft_(ref IntPtr plan, ref int rank, [In,Out] int[] n, ref int howmany, [In,Out] fcomplex* input, [In,Out] int[] inembed, ref int istride, ref int idist, [In,Out] fcomplex* output, [In,Out] int[] onembed, ref int ostride, ref int odist, ref FFTW_DIRECTION sign, ref FFTW_PLANCREATION flags);		
示例#8
0
		private static extern void sfftw_plan_dft_3d_(ref IntPtr plan, ref int nx, ref int ny, ref int nz, [In,Out] fcomplex* input, [In,Out] fcomplex* output, ref FFTW_DIRECTION sign, ref FFTW_PLANCREATION flags);