void BuildPermutationTable() { _P = PersistentMemory.New <int2>(_N / 2); for (var i = 0; i < _N; i += 2) { _P[i / 2] = math.int2(Permutate(i), Permutate(i + 1)); } }
void InitializeWindow() { _W = PersistentMemory.New <float>(_N); for (var i = 0; i < _N; i++) { _W[i] = (1 - math.cos(2 * math.PI * i / (_N - 1))) / 2; } }
public BurstFft(int width) { _N = width; _logN = (int)math.log2(width); BuildPermutationTable(); BuildTwiddleFactors(); _O = PersistentMemory.New <float>(_N); }
public FftBuffer(int width) { _N = width; _logN = (int)math.log2(width); _I = PersistentMemory.New <float>(_N); _O = PersistentMemory.New <float>(_N); InitializeWindow(); BuildPermutationTable(); BuildTwiddleFactors(); }
public BurstDft(int width) { // DFT coefficients var coeffs = Enumerable.Range(0, width / 2 * width). Select(i => (k: i / width, n: i % width)). Select(I => 2 * math.PI / width * I.k * I.n); var coeffs_r = coeffs.Select(x => math.cos(x)); var coeffs_i = coeffs.Select(x => math.sin(x)); _coeffs_r = PersistentMemory.New <float>(coeffs_r); _coeffs_i = PersistentMemory.New <float>(coeffs_i); // Output buffer _buffer = PersistentMemory.New <float>(width / 2); }
void BuildTwiddleFactors() { _T = PersistentMemory.New <TFactor>((_logN - 1) * (_N / 4)); var i = 0; for (var m = 4; m <= _N; m <<= 1) { for (var k = 0; k < _N; k += m) { for (var j = 0; j < m / 2; j += 2) { _T[i++] = new TFactor { I = math.int2((k + j) / 2, (k + j + m / 2) / 2), W = math.cos(-2 * math.PI / m * math.float2(j, j + 1)) } } } } ; }