public unsafe static void ForwardTransformLut(Complex *buffer, int length) { int num = length - 1; int num2 = length / 2; Complex complex = default(Complex); complex.Real = 0f; complex.Imag = 0f; Complex c = default(Complex); c.Real = 0f; c.Imag = 0f; int num3 = 0; for (int num4 = length; num4 > 1; num4 >>= 1) { num3++; } int num5 = num2; for (int num4 = 1; num4 < num; num4++) { if (num4 < num5) { complex = buffer[num5]; buffer[num5] = buffer[num4]; buffer[num4] = complex; } int num6; for (num6 = num2; num6 <= num5; num6 /= 2) { num5 -= num6; } num5 += num6; } for (int i = 1; i <= num3; i++) { int num7 = 1 << i; int num8 = num7 / 2; int num9 = 16 - i; for (num5 = 1; num5 <= num8; num5++) { int num10 = num5 - 1; int num11 = num10 << num9; c.Real = Fourier._lr[num11]; c.Imag = Fourier._li[num11]; for (int num4 = num10; num4 <= num; num4 += num7) { num11 = num4 + num8; Complex.Mul(ref complex, c, buffer[num11]); Complex.Sub(ref buffer[num11], buffer[num4], complex); Complex.Add(ref buffer[num4], complex); } } } }
public unsafe static void ForwardTransformRot(Complex *buffer, int length) { int num = length - 1; int num2 = length / 2; Complex c = default(Complex); c.Real = 0f; c.Imag = 0f; Complex complex = default(Complex); complex.Real = 0f; complex.Imag = 0f; int num3 = 0; for (int num4 = length; num4 > 1; num4 >>= 1) { num3++; } int num5 = num2; for (int num4 = 1; num4 < num; num4++) { if (num4 < num5) { complex = buffer[num5]; buffer[num5] = buffer[num4]; buffer[num4] = complex; } int num6; for (num6 = num2; num6 <= num5; num6 /= 2) { num5 -= num6; } num5 += num6; } for (int i = 1; i <= num3; i++) { int num7 = 1 << i; int num8 = num7 / 2; double num9 = 3.1415926535897931 / (double)num8; for (num5 = 1; num5 <= num8; num5++) { int num10 = num5 - 1; Complex.FromAngle(ref c, num9 * (double)num10); Complex.Conjugate(ref c); for (int num4 = num10; num4 <= num; num4 += num7) { int num11 = num4 + num8; Complex.Mul(ref complex, c, buffer[num11]); Complex.Sub(ref buffer[num11], buffer[num4], complex); Complex.Add(ref buffer[num4], complex); } } } }
public unsafe void SetCoefficients(Complex[] coefficients) { this._isFast = false; if (coefficients != null) { if (this._coeffBuffer == null || coefficients.Length != this._queueSize) { this._queueSize = coefficients.Length; this._offset = this._queueSize * 3; this._coeffBuffer = UnsafeBuffer.Create(this._queueSize, sizeof(Complex)); this._coeffPtr = (Complex *)(void *)this._coeffBuffer; this._queueBuffer = UnsafeBuffer.Create(this._queueSize * 4, sizeof(Complex)); this._queuePtr = (Complex *)(void *)this._queueBuffer; } for (int i = 0; i < this._queueSize; i++) { this._coeffPtr[i] = coefficients[i]; } this._isSymmetric = true; this._isSparse = true; if (this._queueSize % 2 != 0) { int num = this._queueSize / 2; for (int j = 0; j < num; j++) { int num2 = this._queueSize - 1 - j; Complex.Sub(ref this._dif, this._coeffPtr[j], this._coeffPtr[num2]); if ((double)this._dif.Modulus() > 1E-06) { this._isSymmetric = false; this._isSparse = false; break; } if (j % 2 != 0) { this._isSparse = (this._coeffPtr[j].Real == 0f && this._coeffPtr[j].Imag == 0f && this._coeffPtr[num2].Real == 0f && this._coeffPtr[num2].Imag == 0f); } } } if (this._segment == null || this._segment.Length != this._fftSize) { this._segment = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); this._segPtr = (Complex *)(void *)this._segment; this._kernel = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); this._kerPtr = (Complex *)(void *)this._kernel; this._overlap = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); this._olaPtr = (Complex *)(void *)this._overlap; this._temp = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); this._tmpPtr = (Complex *)(void *)this._temp; } if (this._queueSize < 64) { this._fftLen = 128; goto IL_033c; } if (this._queueSize < 128) { this._fftLen = 256; goto IL_033c; } if (this._queueSize < 256) { this._fftLen = 512; goto IL_033c; } if (this._queueSize < 512) { this._fftLen = 1024; goto IL_033c; } if (this._queueSize < 1024) { this._fftLen = 2048; goto IL_033c; } if (this._queueSize < 2048) { this._fftLen = 4096; goto IL_033c; } throw new Exception("kernel too long"); } return; IL_033c: CpxFirFilter.FillFft(this._kerPtr, this._fftLen, this._coeffPtr, this._queueSize); Fourier.ForwardTransform(this._kerPtr, this._fftLen, false); this._isFast = true; }