diff options
| author | skal <pascal.massimino@gmail.com> | 2026-05-21 08:10:47 +0200 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-05-21 08:10:47 +0200 |
| commit | d806027dcaeadcdd8d2febd88bc46b2fd2c465de (patch) | |
| tree | 30bc1ef9f40ccab7c00e31ee20e62bb86755fa26 /src/tests/audio/test_fft.cc | |
| parent | 680042a18c11ad5e58757e45b260745c2f52417f (diff) | |
Diffstat (limited to 'src/tests/audio/test_fft.cc')
| -rw-r--r-- | src/tests/audio/test_fft.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/tests/audio/test_fft.cc b/src/tests/audio/test_fft.cc index 2d47aa0..a34d203 100644 --- a/src/tests/audio/test_fft.cc +++ b/src/tests/audio/test_fft.cc @@ -39,7 +39,7 @@ static void idct_reference(const float* input, float* output, size_t N) { // Reference direct DFT matching fft_forward convention (e^{+j} sign). // fft_radix2 with direction=+1 computes X[k] = sum x[n] * e^{+j*2*pi*k*n/N}. static void dft_reference(const float* real_in, const float* imag_in, - float* real_out, float* imag_out, size_t N) { + float* real_out, float* imag_out, size_t N) { const float PI = 3.14159265358979323846f; for (size_t k = 0; k < N; k++) { real_out[k] = 0.0f; @@ -68,7 +68,8 @@ static bool arrays_match(const float* a, const float* b, size_t N, // Test B: fft_forward small N=4 — all 4 unit impulses vs direct DFT static void test_b_fft_radix2_small_n() { - printf("Test B: fft_forward N=4 (unit impulses vs direct DFT, tol=1e-5)...\n"); + printf( + "Test B: fft_forward N=4 (unit impulses vs direct DFT, tol=1e-5)...\n"); const size_t N = 4; const float tolerance = 1e-5f; @@ -117,8 +118,7 @@ static void test_c_twiddle_accumulation() { if (k >= 128 && k < 256) { const float wr_direct = cosf(angle * (float)k); const float wi_direct = sinf(angle * (float)k); - const float err = - fabsf(wr_iter - wr_direct) + fabsf(wi_iter - wi_direct); + const float err = fabsf(wr_iter - wr_direct) + fabsf(wi_iter - wi_direct); if (err > max_err) { max_err = err; max_err_k = k; @@ -129,9 +129,8 @@ static void test_c_twiddle_accumulation() { wi_iter = wr_old * wi_delta + wi_iter * wr_delta; } - printf( - " ✓ iterative twiddle drift at k=128..255: max_err=%.2e at k=%zu\n", - (double)max_err, max_err_k); + printf(" ✓ iterative twiddle drift at k=128..255: max_err=%.2e at k=%zu\n", + (double)max_err, max_err_k); printf(" ✓ fixed code uses cosf/sinf directly — no accumulation\n"); printf("Test C: PASSED ✓\n\n"); } @@ -279,7 +278,8 @@ static void test_idct_correctness() { assert(arrays_match(output_ref, output_fft, N)); printf(" ✓ Single bin test passed\n"); - // Mixed spectrum: IDCT→DCT round-trip (dct_fft and idct_fft are mutual inverses) + // Mixed spectrum: IDCT→DCT round-trip (dct_fft and idct_fft are mutual + // inverses) for (size_t i = 0; i < N; i++) { input[i] = sinf(i * 0.1f) * cosf(i * 0.05f) + cosf(i * 0.03f); } |
