Ejemplo n.º 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);
        }
 public static void forwBackwCheck1D(ILArray <double> A, ILArray <complex> Result)
 {
     try {
         ILArray <complex> B = fft(A);
         //double errMult = 1/(A.Dimensions.NumberOfElements * Math.Pow(10,A.Dimensions.NumberOfDimensions));
         double errMult = Math.Pow(0.1, A.Dimensions.NumberOfDimensions) / A.Dimensions.NumberOfElements;
         if (!A.IsScalar)
         {
             errMult /= (double)A.Dimensions[A.Dimensions.FirstNonSingleton()];
         }
         if (sumall(abs(subtract(Result, B))) * errMult > (double)MachineParameterDouble.eps)
         {
             throw new Exception("invalid value");
         }
         ILArray <double> ResultR = ifftsym(B);
         if (ILMath.sumall(ILMath.abs(ResultR - A)) * errMult > (double)ILMath.MachineParameterDouble.eps)
         {
             throw new Exception("invalid value");
         }
         B = ifft(B);
         if (ILMath.sumall(ILMath.abs(ILMath.tocomplex(A) - B)) * errMult > (double)ILMath.MachineParameterDouble.eps)
         {
             throw new Exception("invalid value");
         }
     } catch (ILNumerics.Exceptions.ILArgumentException) {
         throw new Exception("unexpected exception was thrown -> error!");
     }
 }
Ejemplo n.º 3
0
/*!HC:TYPELIST:
 * <hycalper>
 *  <type>
 *      <source locate="after">
 *          HCretArr
 *      </source>
 *      <destination>complex</destination>
 *      <destination>complex</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          funcName
 *      </source>
 *      <destination>FFTForward1D</destination>
 *      <destination>FFTBackward1D</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          inArr
 *      </source>
 *      <destination>complex</destination>
 *      <destination>complex</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          HCmapInOut
 *      </source>
 *      <destination>A.C</destination>
 *      <destination>A.C</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          HCdir
 *      </source>
 *      <destination>ACMLValues.Forward</destination>
 *      <destination>ACMLValues.Backwards</destination>
 *  </type>
 * </hycalper>
 */
        public ILArray </*!HC:HCretArr*/ complex> /*!HC:funcName*/ FFTForward1D(ILArray </*!HC:HCinArr*/ double> A, int dim)
        {
            if (A == null || dim < 0)
            {
                throw new ILArgumentException("invalid parameter!");
            }
            if (A.IsEmpty)
            {
                return(ILArray </*!HC:HCretArr*/ complex> .empty(A.Dimensions));
            }
            if (A.IsScalar || A.Dimensions[dim] == 1)
            {
                return /*!HC:HCmapInOut*/ (ILMath.tocomplex(A));
            }
            // prepare output array
            ILArray </*!HC:HCretArr*/ complex> ret = /*!HC:HCmapInOut*/ ILMath.tocomplex(A);

            fft1dInplace(dim, ret, /*!HC:HCdir*/ ACMLValues.Forward);
            return(ret);
        }
Ejemplo n.º 4
0
/*!HC:TYPELIST:
 * <hycalper>
 *  <type>
 *      <source locate="after">
 *          HCretArr
 *      </source>
 *      <destination>complex</destination>
 *      <destination>complex</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          funcName
 *      </source>
 *      <destination>FFTForward</destination>
 *      <destination>FFTBackward</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          inArr
 *      </source>
 *      <destination>complex</destination>
 *      <destination>complex</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          HCmapInOut
 *      </source>
 *      <destination>A.C</destination>
 *      <destination>A.C</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          HCdir
 *      </source>
 *      <destination>ACMLValues.Forward</destination>
 *      <destination>ACMLValues.Backwards</destination>
 *  </type>
 * </hycalper>
 */
        public ILArray </*!HC:HCretArr*/ complex> /*!HC:funcName*/ FFTForward(ILArray </*!HC:HCinArr*/ double> A, int nDims)
        {
            if (A == null || nDims <= 0)
            {
                throw new ILArgumentException("invalid parameter!");
            }
            if (A.IsEmpty)
            {
                return(ILArray </*!HC:HCretArr*/ complex> .empty(A.Dimensions));
            }
            if (A.IsScalar || (A.Dimensions[0] == 1 && nDims == 1))
            {
                return /*!HC:HCmapInOut*/ (ILMath.tocomplex(A));
            }
            if (nDims > A.Dimensions.NumberOfDimensions)
            {
                return /*!HC:funcName*/ (FFTForward(A, A.Dimensions.NumberOfDimensions));
            }

            // prepare output array + transform each dimension inplace
            ILArray </*!HC:HCretArr*/ complex> ret = /*!HC:HCmapInOut*/ ILMath.tocomplex(A);

            switch (nDims)
            {
            case 2:
                fft2dInplace(ret, /*!HC:HCdir*/ ACMLValues.Forward);
                break;

            default:
                for (int i = 0; i < nDims; i++)
                {
                    fft1dInplace(i, ret, /*!HC:HCdir*/ ACMLValues.Forward);
                }
                break;
            }
            return(ret);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// run all tests for ILMatFile
        /// </summary>
        public override void Run()
        {
            // tests: creation
            // =================
            Header();
            Test_TestMatlab();
            Test_StreamMatlab("testarray1.mat", ILMath.empty());
            Test_StreamMatlab("testarray1.mat", ILMath.ones(1, 1));
            Test_StreamMatlab("testarray1.mat", ILMath.rand(10, 1));
            Test_StreamMatlab("testarray1.mat", ILMath.rand(1, 10));
            Test_StreamMatlab("testarray1.mat", ILMath.rand(0, 1));
            Test_StreamMatlab("testarray1.mat", ILMath.rand(10, 100, 4));

            Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.ones(1, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.empty()));
            Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.rand(10, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.rand(1, 10)));
            Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.rand(0, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.rand(10, 100, 4)));

            Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.ones(1, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.empty()));
            Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.rand(10, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.rand(1, 10)));
            Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.rand(0, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.rand(10, 100, 4)));

            Test_StreamMatlab("testarray1.mat", new ILArray <complex>(new complex[] { new complex(1.0, 2.0) }));
            Test_StreamMatlab("testarray1.mat", ILMath.tocomplex(ILMath.empty()));
            Test_StreamMatlab("testarray1.mat", ILMath.tocomplex(ILMath.rand(10, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tocomplex(ILMath.rand(1, 10)));
            Test_StreamMatlab("testarray1.mat", ILMath.tocomplex(ILMath.rand(0, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tocomplex(ILMath.rand(10, 100, 4)));

            Test_StreamMatlab("testarray1.mat", new ILArray <fcomplex>(new fcomplex[] { new fcomplex(1.0f, 2.0f) }));
            Test_StreamMatlab("testarray1.mat", ILMath.tofcomplex(ILMath.empty()));
            Test_StreamMatlab("testarray1.mat", ILMath.tofcomplex(ILMath.rand(10, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tofcomplex(ILMath.rand(1, 10)));
            Test_StreamMatlab("testarray1.mat", ILMath.tofcomplex(ILMath.rand(0, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tofcomplex(ILMath.rand(10, 100, 4)));

            Test_StreamMatlab("testarray1.mat", new ILArray <char>(new char[] { 'A', 'B', 'F' }));
            Test_StreamMatlab("testarray1.mat", new ILArray <char>(new char[] { 'A', 'B', 'F' }).T);
            Test_StreamMatlab("testarray1.mat", ILMath.tochar(ILMath.empty()));
            Test_StreamMatlab("testarray1.mat", ILMath.tochar(ILMath.rand(10, 1) * 250));
            Test_StreamMatlab("testarray1.mat", ILMath.tochar(ILMath.rand(1, 10) * 250));
            Test_StreamMatlab("testarray1.mat", ILMath.tochar(ILMath.rand(0, 1) * 250));
            Test_StreamMatlab("testarray1.mat", ILMath.tochar(ILMath.rand(10, 100, 4) * 250));

            Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.ones(1, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.empty()));
            Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.rand(10, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.rand(1, 10) * 255));
            Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.rand(0, 1) * 255));
            Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.rand(10, 100, 4) * 255));

            Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.ones(1, 1) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.empty()) * 16000);
            Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.rand(10, 1) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.rand(1, 10) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.rand(0, 1) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.rand(10, 100, 4) * 16000));

            Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.ones(1, 1) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.empty() * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.rand(10, 1) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.rand(1, 10) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.rand(0, 1) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.rand(10, 100, 4) * 16000));

            Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.ones(1, 1) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.empty() * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.rand(10, 1) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.rand(1, 10) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.rand(0, 1) * 16000));
            Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.rand(10, 100, 4) * 16000));

            Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.ones(1, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.empty()));
            Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.rand(10, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.rand(1, 10)));
            Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.rand(0, 1)));
            Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.rand(10, 100, 4)));
            Test_ImportMatlab2();
            Test_ImportMatlab();
            Test_NameRestrictions();
            // summary
            Footer();
        }
Ejemplo n.º 6
0
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !!

        #endregion HYCALPER AUTO GENERATED CODE

        #endregion

        #region IILFFT Member - n-D

        #region HYCALPER LOOPSTART ND-TRANSFORMS

/*!HC:TYPELIST:
 * <hycalper>
 *  <type>
 *      <source locate="after">
 *          HCretArr
 *      </source>
 *      <destination>complex</destination>
 *      <destination>complex</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          funcName
 *      </source>
 *      <destination>FFTForward</destination>
 *      <destination>FFTBackward</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          inArr
 *      </source>
 *      <destination>complex</destination>
 *      <destination>complex</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          convRet
 *      </source>
 *      <destination>A.C</destination>
 *      <destination>A.C</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          mklPrec
 *      </source>
 *      <destination>MKLValues.DOUBLE</destination>
 *      <destination>MKLValues.DOUBLE</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          dftiFunc
 *      </source>
 *      <destination>MKLImports.DftiComputeForward</destination>
 *      <destination>MKLImports.DftiComputeBackward</destination>
 *  </type>
 *  <type>
 *      <source locate="nextline">
 *          HCbackwScale
 *      </source>
 *      <destination></destination>
 *      <destination><![CDATA[MKLImports.DftiSetValue(descriptor,MKLParameter.BACKWARD_SCALE, __arglist(1.0/tmp));]]></destination>
 *  </type>
 *  <type>
 *      <source locate="nextline">
 *          limit3D
 *      </source>
 *      <destination></destination>
 *      <destination></destination>
 *  </type>
 * </hycalper>
 */
        public ILArray </*!HC:HCretArr*/ complex> /*!HC:funcName*/ FFTForward(ILArray </*!HC:HCinArr*/ double> A, int nDims)
        {
            if (A == null || nDims <= 0)
            {
                throw new ILArgumentException("invalid argument!");
            }
            if (A.IsEmpty)
            {
                return(ILArray </*!HC:HCretArr*/ complex> .empty(A.Dimensions));
            }
            if (A.IsScalar || (A.Dimensions[0] == 1 && nDims == 1))
            {
                return /*!HC:convRet*/ (ILMath.tocomplex(A));
            }
            if (nDims > A.Dimensions.NumberOfDimensions)
            {
                nDims = A.Dimensions.NumberOfDimensions;
            }
            /*!HC:limit3D*/
            if (nDims > 3)
            {
                return(FFTForward(ILMath.tocomplex(A), nDims));
            }
            // prepare output array
            ILArray </*!HC:HCretArr*/ complex> ret = /*!HC:convRet*/ ILMath.tocomplex(A);
            IntPtr descriptor = IntPtr.Zero;
            int    error      = -1;

            int[]  tmpDims = A.Dimensions.ToIntArray(nDims + 1);
            string hash    = hashPlan(/*!HC:mklPrec*/ MKLValues.DOUBLE, MKLValues.COMPLEX, nDims, tmpDims);

            lock (_lockobject) {
                // try to reuse existing descriptor
                if (!m_descriptors.TryGetValue(hash, out descriptor))
                {
                    error = MKLImports.DftiCreateDescriptor(ref descriptor, /*!HC:mklPrec*/ MKLValues.DOUBLE, MKLValues.COMPLEX, nDims, tmpDims);
                    if (isMKLError(error))
                    {
                        throw new ILInvalidOperationException("error creating descriptor: " + MKLImports.DftiErrorMessage(error));
                    }
                    m_descriptors[hash] = descriptor;
                }
            }
            // how many transformations ?
            int tmp = A.Dimensions.SequentialIndexDistance(nDims);

            MKLImports.DftiSetValue(descriptor, MKLParameter.NUMBER_OF_TRANSFORMS, __arglist(A.Dimensions.NumberOfElements / tmp));
            //error = MKLImports.DftiSetValue(descriptor,MKLParameter.PLACEMENT,MKLValues.NOT_INPLACE);
            //error = MKLImports.DftiSetValue(descriptor,MKLParameter.REAL_STORAGE, MKLValues.REAL_COMPLEX);
            // storage of subsequent transformations
            MKLImports.DftiSetValue(descriptor, MKLParameter.INPUT_DISTANCE, __arglist(tmp));
            MKLImports.DftiSetValue(descriptor, MKLParameter.OUTPUT_DISTANCE, __arglist(tmp));
            /*!HC:HCbackwScale*/

            // spacing between elements
            tmpDims[0] = 0;
            for (int i = 0; i < nDims; i++)
            {
                tmpDims[i + 1] = A.Dimensions.SequentialIndexDistance(i);
            }
            MKLImports.DftiSetValue(descriptor, MKLParameter.INPUT_STRIDES, __arglist(tmpDims));
            error = MKLImports.DftiSetValue(descriptor, MKLParameter.OUTPUT_STRIDES, __arglist(tmpDims));
            if (isMKLError(error))
            {
                throw new ILInvalidOperationException("error: " + MKLImports.DftiErrorMessage(error));
            }
            error = MKLImports.DftiCommitDescriptor(descriptor);
            if (isMKLError(error))
            {
                throw new ILInvalidOperationException("error: " + MKLImports.DftiErrorMessage(error));
            }
            // do the transform(s)
            unsafe
            {
                fixed(/*!HC:HCretArr*/ complex *retArr = ret.m_data)
                {
                    error = /*!HC:dftiFunc*/ MKLImports.DftiComputeForward(descriptor, __arglist(retArr));
                }
            }
            if (isMKLError(error))
            {
                throw new ILInvalidOperationException("error: " + MKLImports.DftiErrorMessage(error));
            }
            return(ret);
        }
Ejemplo n.º 7
0
/*!HC:TYPELIST:
 * <hycalper>
 *  <type>
 *      <source locate="after">
 *          HCretArr
 *      </source>
 *      <destination>complex</destination>
 *      <destination>complex</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          funcName
 *      </source>
 *      <destination>FFTForward1D</destination>
 *      <destination>FFTBackward1D</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          inArr
 *      </source>
 *      <destination>complex</destination>
 *      <destination>complex</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          convRet
 *      </source>
 *      <destination>A.C</destination>
 *      <destination>A.C</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          mklPrec
 *      </source>
 *      <destination>MKLValues.DOUBLE</destination>
 *      <destination>MKLValues.DOUBLE</destination>
 *  </type>
 *  <type>
 *      <source locate="after">
 *          dftiFunc
 *      </source>
 *      <destination>MKLImports.DftiComputeForward</destination>
 *      <destination>MKLImports.DftiComputeBackward</destination>
 *  </type>
 *  <type>
 *      <source locate="nextline">
 *          HCbackwScale
 *      </source>
 *      <destination></destination>
 *      <destination><![CDATA[MKLImports.DftiSetValue(descriptor,MKLParameter.BACKWARD_SCALE, __arglist(1.0 / inDim));]]></destination>
 *  </type>
 * </hycalper>
 */
        public ILArray </*!HC:HCretArr*/ complex> /*!HC:funcName*/ FFTForward1D(ILArray </*!HC:inArr*/ double> A, int dim)
        {
            if (object.Equals(A, null) || dim < 0)
            {
                throw new ILArgumentException("invalid parameter!");
            }
            if (A.IsEmpty)
            {
                return(ILArray </*!HC:HCretArr*/ complex> .empty(A.Dimensions));
            }
            if (dim >= A.Dimensions.NumberOfDimensions || A.Dimensions[dim] == 1)
            {
                return /*!HC:convRet*/ (ILMath.tocomplex(A));
            }
            // prepare output array
            ILArray </*!HC:HCretArr*/ complex> ret = /*!HC:convRet*/ ILMath.tocomplex(A);
            string hash = hashPlan(/*!HC:mklPrec*/ MKLValues.DOUBLE, MKLValues.COMPLEX, 1, A.Dimensions[dim]);
            IntPtr descriptor = IntPtr.Zero;
            int    error, inDim = A.Dimensions[dim];

            // try to reuse existing descriptor
            lock (_lockobject) {
                if (!m_descriptors.TryGetValue(hash, out descriptor))
                {
                    error = MKLImports.DftiCreateDescriptor(ref descriptor, /*!HC:mklPrec*/ MKLValues.DOUBLE, MKLValues.COMPLEX, 1, inDim);
                    if (isMKLError(error))
                    {
                        throw new ILInvalidOperationException("error creating descriptor: " + MKLImports.DftiErrorMessage(error));
                    }
                    m_descriptors[hash] = descriptor;
                }
            }
            // spacing between elements
            int tmp = A.Dimensions.SequentialIndexDistance(dim);

            int[] stride = new int[] { 0, tmp };
            MKLImports.DftiSetValue(descriptor, MKLParameter.INPUT_STRIDES, __arglist(stride));
            error = MKLImports.DftiSetValue(descriptor, MKLParameter.OUTPUT_STRIDES, __arglist(stride));
            if (isMKLError(error))
            {
                throw new ILInvalidOperationException("error: " + MKLImports.DftiErrorMessage(error));
            }
            // storage of subsequent transformations
            tmp = inDim * tmp;
            MKLImports.DftiSetValue(descriptor, MKLParameter.INPUT_DISTANCE, __arglist(tmp));
            MKLImports.DftiSetValue(descriptor, MKLParameter.OUTPUT_DISTANCE, __arglist(tmp));
            // how many transformations ?
            tmp = A.Dimensions.NumberOfElements / tmp;
            MKLImports.DftiSetValue(descriptor, MKLParameter.NUMBER_OF_TRANSFORMS, __arglist(tmp));
            //error = MKLImports.DftiSetValue(descriptor,MKLParameter.PLACEMENT,MKLValues.NOT_INPLACE);
            /*!HC:HCbackwScale*/

            error = MKLImports.DftiCommitDescriptor(descriptor);
            if (isMKLError(error))
            {
                throw new ILInvalidOperationException("error: " + MKLImports.DftiErrorMessage(error));
            }
            // do the transform(s)
            unsafe {
                tmp = A.Dimensions.SequentialIndexDistance(dim);
                fixed(/*!HC:HCretArr*/ complex *retArr = ret.m_data)
                {
                    for (int i = 0; i < tmp && error == 0; i++)
                    {
                        error = /*!HC:dftiFunc*/ MKLImports.DftiComputeForward(descriptor, __arglist(retArr + i));
                    }
                }
            }
            if (isMKLError(error))
            {
                throw new ILInvalidOperationException("error: " + MKLImports.DftiErrorMessage(error));
            }
            return(ret);
        }