/// <summary>
        /// Executes the fourier transformation itself (without data pretreatment).
        /// </summary>
        /// <exception cref="System.InvalidOperationException">The Fourier transformation was already executed.</exception>
        protected virtual void ExecuteFourierTransformation()
        {
            if (_arraysContainTransformation)
            {
                throw new InvalidOperationException("The Fourier transformation was already executed.");
            }

            var numColumns = NumberOfColumns;
            var numRows    = NumberOfRows;

            var rePart = ((IMatrixInArray1DRowMajorRepresentation <double>)_realMatrix).GetArray1DRowMajor();

            _imagMatrix = new DoubleMatrixInArray1DRowMajorRepresentation(numRows, numColumns);
            var imPart = ((IMatrixInArray1DRowMajorRepresentation <double>)_imagMatrix).GetArray1DRowMajor();

            // fourier transform either with Pfa (faster) or with the Chirp-z-transform
            if (Pfa235FFT.CanFactorized(numRows) && Pfa235FFT.CanFactorized(numColumns))
            {
                var fft = new Pfa235FFT(numRows, numColumns);
                fft.FFT(rePart, imPart, FourierDirection.Forward);
            }
            else
            {
                var matrixRe = new DoubleMatrixInArray1DRowMajorRepresentation(rePart, numRows, numColumns);
                ChirpFFT.FourierTransformation2D(matrixRe, _imagMatrix, FourierDirection.Forward);
            }

            _arraysContainTransformation = true;
        }
        /// <summary>
        /// Performs a inplace fourier transformation. The original values are overwritten by the fourier transformed values.
        /// </summary>
        /// <param name="arr">The data to transform. On output, the fourier transformed data.</param>
        /// <param name="direction">Specify forward or reverse transformation here.</param>
        public void Transform(double[] arr, FourierDirection direction)
        {
            if (arr.Length != _numberOfData)
            {
                throw new ArgumentException(string.Format("Length of array arr ({0}) is different from the length specified at construction ({1})", arr.Length, _numberOfData), "arr");
            }

            switch (_method)
            {
            case Method.Trivial:
            {
                if (_numberOfData == 2)
                {
                    double a0 = arr[0], a1 = arr[1];
                    arr[0] = a0 + a1;
                    arr[1] = a0 - a1;
                }
            }
            break;

            case Method.Hartley:
            {
                FastHartleyTransform.RealFFT(arr, direction);
            }
            break;

            case Method.Pfa235:
            {
                NullifyTempArrN1();

                _pfa235.RealFFT(arr, _tempArr1N, direction);
            }
            break;

            case Method.Chirp:
            {
                if (direction == FourierDirection.Forward)
                {
                    NullifyTempArrN1();
                }
                else
                {
                    if (null == this._tempArr1N)
                    {
                        _tempArr1N = new double[_numberOfData];
                    }

                    _tempArr1N[0] = 0;
                    for (int k = 1; k <= _numberOfData / 2; k++)
                    {
                        double sumreal = arr[k];
                        double sumimag = arr[_numberOfData - k];

                        _tempArr1N[k] = sumimag;
                        _tempArr1N[_numberOfData - k] = -sumimag;
                        arr[_numberOfData - k]        = sumreal;
                    }
                }

                ChirpFFT.FFT(arr, _tempArr1N, direction, ref _fftTempStorage);

                if (direction == FourierDirection.Forward)
                {
                    for (int k = 0; k <= _numberOfData / 2; k++)
                    {
                        double sumreal = arr[k];
                        double sumimag = _tempArr1N[k];

                        if (k != 0 && (k + k) != _numberOfData)
                        {
                            arr[_numberOfData - k] = sumimag;
                        }
                        arr[k] = sumreal;
                    }
                }
            }
            break;
            }
        }