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: 8cd2e3d72723
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: da157f7b91fa
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Jul 6, 2020

  1. Copy the full SHA
    2588891 View commit details
  2. Merge pull request #2630 from pleroy/InnerProduct

    Inner product of Poisson series
    pleroy authored Jul 6, 2020
    Copy the full SHA
    da157f7 View commit details
Showing with 43 additions and 0 deletions.
  1. +16 −0 numerics/poisson_series.hpp
  2. +14 −0 numerics/poisson_series_body.hpp
  3. +13 −0 numerics/poisson_series_test.cpp
16 changes: 16 additions & 0 deletions numerics/poisson_series.hpp
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ namespace internal_poisson_series {

using geometry::Instant;
using quantities::AngularFrequency;
using quantities::Primitive;
using quantities::Product;
using quantities::Quotient;
using quantities::Time;
@@ -146,6 +147,21 @@ PoissonSeries<Product<LValue, RValue>, ldegree_ + rdegree_, Evaluator>
operator*(PoissonSeries<LValue, ldegree_, Evaluator> const& left,
PoissonSeries<RValue, rdegree_, Evaluator> const& right);

// Inner product space of Poisson series.

// Technically the weight function must be nonnegative for this to be an inner
// product. Not sure how with work with the flat-top windows, which can be
// negative.
template<typename LValue, typename RValue,
int ldegree_, int rdegree_, int wdegree_,
template<typename, typename, int> class Evaluator>
Primitive<Product<LValue, RValue>, Time>
Dot(PoissonSeries<LValue, ldegree_, Evaluator> const& left,
PoissonSeries<RValue, rdegree_, Evaluator> const& right,
PoissonSeries<double, wdegree_, Evaluator> const& weight,
Instant const& t_min,
Instant const& t_max);

} // namespace internal_poisson_series

using internal_poisson_series::PoissonSeries;
14 changes: 14 additions & 0 deletions numerics/poisson_series_body.hpp
Original file line number Diff line number Diff line change
@@ -349,6 +349,20 @@ operator*(PoissonSeries<LValue, ldegree_, Evaluator> const& left,
return {aperiodic, std::move(periodic)};
}

template<typename LValue, typename RValue,
int ldegree_, int rdegree_, int wdegree_,
template<typename, typename, int> class Evaluator>
Primitive<Product<LValue, RValue>, Time>
Dot(PoissonSeries<LValue, ldegree_, Evaluator> const& left,
PoissonSeries<RValue, rdegree_, Evaluator> const& right,
PoissonSeries<double, wdegree_, Evaluator> const& weight,
Instant const& t_min,
Instant const& t_max) {
auto const integrand = left * right * weight;
auto const primitive = integrand.Primitive();
return primitive.Evaluate(t_max) - primitive.Evaluate(t_min);
}

} // namespace internal_poisson_series
} // namespace numerics
} // namespace principia
13 changes: 13 additions & 0 deletions numerics/poisson_series_test.cpp
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

#include "geometry/named_quantities.hpp"
#include "gtest/gtest.h"
#include "numerics/apodization.hpp"
#include "numerics/polynomial_evaluators.hpp"
#include "quantities/elementary_functions.hpp"
#include "quantities/quantities.hpp"
@@ -172,5 +173,17 @@ TEST_F(PoissonSeriesTest, Primitive) {
}
}

TEST_F(PoissonSeriesTest, Dot) {
Instant const t_min = t0_;
Instant const t_max = t0_ + 3 * Second;
// Computed using Mathematica.
EXPECT_THAT(Dot(*pa_,
*pb_,
apodization::Hann<HornerEvaluator>(t_min, t_max),
t_min,
t_max),
AlmostEquals(-1143.765683104456272 * Second, 53));
}

} // namespace numerics
} // namespace principia