Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 599f202ef721
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ca5d9e3f4d3d
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Oct 6, 2020

  1. Remove FFT type decay

    eggrobin committed Oct 6, 2020
    Copy the full SHA
    a3323c7 View commit details
  2. Merge pull request #2751 from eggrobin/type-fourier

    Remove FFT type decay
    eggrobin authored Oct 6, 2020
    Copy the full SHA
    ca5d9e3 View commit details
Showing with 9 additions and 21 deletions.
  1. +3 −9 numerics/fast_fourier_transform.hpp
  2. +6 −12 numerics/fast_fourier_transform_body.hpp
12 changes: 3 additions & 9 deletions numerics/fast_fourier_transform.hpp
Original file line number Diff line number Diff line change
@@ -61,16 +61,10 @@ class FastFourierTransform {

private:
Time const Δt_;
AngularFrequency const ω_;
AngularFrequency const Δω_;

// A type obtained by complexifying the signal or frequency space, and
// discarding the units. The Fourier transform is computed in place, so that
// the same member successively holds the signal and frequency.
using Complex = Complexification<typename Hilbert<Value>::NormalizedType>;

// The elements of transform_ are in SI units of Value. They are spaced in
// frequency by ω_.
std::array<Complex, size> transform_;
// The elements of transform_ are spaced in frequency by ω_.
std::array<Complexification<Value>, size> transform_;

friend class FastFourierTransformTest;
};
18 changes: 6 additions & 12 deletions numerics/fast_fourier_transform_body.hpp
Original file line number Diff line number Diff line change
@@ -19,8 +19,6 @@ using base::BitReversedIncrement;
using quantities::Angle;
using quantities::Sin;
using quantities::si::Radian;
using quantities::si::Unit;
namespace si = quantities::si;

// Implementation of the Danielson-Lánczos algorithm using templates for
// recursion and template specializations for short FFTs [DL42, Myr07].
@@ -128,21 +126,21 @@ FastFourierTransform<Value, size_>::FastFourierTransform(
Iterator const end,
Time const& Δt)
: Δt_(Δt),
ω_(2 * π * Radian / (size * Δt_)) {
Δω_(2 * π * Radian / (size * Δt_)) {
DCHECK_EQ(size, std::distance(begin, end));

// Type decay, reindexing, and promotion to complex.
// Reindexing and promotion to complex.
int bit_reversed_index = 0;
for (auto it = begin;
it != end;
++it,
bit_reversed_index = BitReversedIncrement(bit_reversed_index,
log2_size)) {
transform_[bit_reversed_index] =
*it / si::Unit<typename Hilbert<Value>::NormType>;
transform_[bit_reversed_index] = *it;
}

DanielsonLánczos<Complex, size>::Transform(transform_.begin());
DanielsonLánczos<Complexification<Value>, size>::Transform(
transform_.begin());
}

template<typename Value, std::size_t size_>
@@ -158,11 +156,7 @@ FastFourierTransform<Value, size_>::PowerSpectrum() const {
spectrum;
int k = 0;
for (auto const& coefficient : transform_) {
spectrum.emplace_hint(
spectrum.end(),
k * ω_,
coefficient.Norm²() *
si::Unit<typename Hilbert<Value>::InnerProductType>);
spectrum.emplace_hint(spectrum.end(), k * Δω_, coefficient.Norm²());
++k;
}
return spectrum;