diff options
author | Chris Robinson <[email protected]> | 2022-01-28 00:37:12 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-01-30 04:55:13 -0800 |
commit | c9d59ebc4a2c3566d34759a901be639b5f932e30 (patch) | |
tree | 84aa1df97eb73bf5e29aa062c3150b5049034fc0 /common/alcomplex.cpp | |
parent | 19ed994dc30ed84ea7cbbb5152577669fc25caf6 (diff) |
Simplify FFT complex arg handling a bit
Diffstat (limited to 'common/alcomplex.cpp')
-rw-r--r-- | common/alcomplex.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/common/alcomplex.cpp b/common/alcomplex.cpp index 6d2b18c1..126e2c04 100644 --- a/common/alcomplex.cpp +++ b/common/alcomplex.cpp @@ -120,12 +120,14 @@ void complex_fft(const al::span<std::complex<double>> buffer, const double sign) std::swap(buffer[rev.first], buffer[rev.second]); /* Iterative form of Danielson-Lanczos lemma */ + const double pi{al::numbers::pi * sign}; size_t step2{1u}; for(size_t i{0};i < log2_size;++i) { - const double arg{al::numbers::pi / static_cast<double>(step2)}; + const double arg{pi / static_cast<double>(step2)}; - const std::complex<double> w{std::cos(arg), std::sin(arg)*sign}; + /* TODO: Would std::polar(1.0, arg) be any better? */ + const std::complex<double> w{std::cos(arg), std::sin(arg)}; std::complex<double> u{1.0, 0.0}; const size_t step{step2 << 1}; for(size_t j{0};j < step2;j++) |