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

Commits on Nov 21, 2020

  1. Copy the full SHA
    d33eb1c View commit details
  2. After some cleanup.

    pleroy committed Nov 21, 2020
    Copy the full SHA
    2bd2204 View commit details
  3. Copy the full SHA
    ec8a25b View commit details
  4. Scalar test.

    pleroy committed Nov 21, 2020
    Copy the full SHA
    0c5f26f View commit details
  5. Cleanup and comments.

    pleroy committed Nov 21, 2020
    Copy the full SHA
    ef67260 View commit details
  6. Code complete!

    pleroy committed Nov 21, 2020
    Copy the full SHA
    471b6ef View commit details
  7. Fix the clients.

    pleroy committed Nov 21, 2020
    Copy the full SHA
    bc20d73 View commit details
  8. Fix the tests.

    pleroy committed Nov 21, 2020
    Copy the full SHA
    a4aa722 View commit details
  9. Revert MSVC stupidity.

    pleroy committed Nov 21, 2020
    Copy the full SHA
    f9fcf83 View commit details
  10. After egg's review.

    pleroy committed Nov 21, 2020
    Copy the full SHA
    8a472e8 View commit details
  11. After egg's 2nd review.

    pleroy committed Nov 21, 2020
    Copy the full SHA
    a1b08a5 View commit details

Commits on Nov 22, 2020

  1. Typo.

    pleroy committed Nov 22, 2020
    Copy the full SHA
    875bce4 View commit details
  2. Merge pull request #2790 from pleroy/Basis

    Rewrite the Poisson series basis generator
    pleroy authored Nov 22, 2020
    Copy the full SHA
    a3ff357 View commit details
Showing with 277 additions and 178 deletions.
  1. +0 −4 numerics/frequency_analysis_body.hpp
  2. +4 −4 numerics/frequency_analysis_test.cpp
  3. +12 −17 numerics/poisson_series_basis.hpp
  4. +181 −105 numerics/poisson_series_basis_body.hpp
  5. +80 −48 numerics/poisson_series_basis_test.cpp
4 changes: 0 additions & 4 deletions numerics/frequency_analysis_body.hpp
Original file line number Diff line number Diff line change
@@ -117,14 +117,12 @@ IncrementalProjection(Function const& function,
if (ω.value() == AngularFrequency{}) {
auto const ω_basis =
PoissonSeriesBasisGenerator<Series,
Hilbert<Value>::dimension,
aperiodic_degree>::Basis(t0);
basis_size = std::tuple_size_v<decltype(ω_basis)>;
std::move(ω_basis.begin(), ω_basis.end(), std::back_inserter(basis));
} else {
auto const ω_basis =
PoissonSeriesBasisGenerator<Series,
Hilbert<Value>::dimension,
periodic_degree>::Basis(ω.value(), t0);
basis_size = std::tuple_size_v<decltype(ω_basis)>;
std::move(ω_basis.begin(), ω_basis.end(), std::back_inserter(basis));
@@ -172,14 +170,12 @@ IncrementalProjection(Function const& function,
if (ω.value() == AngularFrequency{}) {
auto const ω_basis =
PoissonSeriesBasisGenerator<Series,
Hilbert<Value>::dimension,
aperiodic_degree>::Basis(t0);
ω_basis_size = std::tuple_size_v<decltype(ω_basis)>;
std::move(ω_basis.begin(), ω_basis.end(), std::back_inserter(basis));
} else {
auto const ω_basis =
PoissonSeriesBasisGenerator<Series,
Hilbert<Value>::dimension,
periodic_degree>::Basis(ω.value(), t0);
ω_basis_size = std::tuple_size_v<decltype(ω_basis)>;
std::move(ω_basis.begin(), ω_basis.end(), std::back_inserter(basis));
8 changes: 4 additions & 4 deletions numerics/frequency_analysis_test.cpp
Original file line number Diff line number Diff line change
@@ -316,7 +316,7 @@ TEST_F(FrequencyAnalysisTest, PoissonSeriesVectorProjection) {
t_min, t_max);
for (int i = 0; i <= 100; ++i) {
EXPECT_THAT(projection4(t0_ + i * Radian / ω),
AlmostEquals(series(t0_ + i * Radian / ω), 0, 1024));
AlmostEquals(series(t0_ + i * Radian / ω), 0, 1536));
}

// Projection on a 5th degree basis is also accurate.
@@ -327,7 +327,7 @@ TEST_F(FrequencyAnalysisTest, PoissonSeriesVectorProjection) {
t_min, t_max);
for (int i = 0; i <= 100; ++i) {
EXPECT_THAT(projection5(t0_ + i * Radian / ω),
AlmostEquals(series(t0_ + i * Radian / ω), 0, 1024));
AlmostEquals(series(t0_ + i * Radian / ω), 0, 1536));
}

// Projection on a 3rd degree basis introduces significant errors.
@@ -431,7 +431,7 @@ TEST_F(FrequencyAnalysisTest, PoissonSeriesIncrementalProjectionNoSecular) {
? AllOf(Gt(6.7e-2 * Metre), Lt(7.9 * Metre))
: ω_index == 2
? AllOf(Gt(1.1e-4 * Metre), Lt(9.7e-1 * Metre))
: AllOf(Gt(2.1e-17 * Metre), Lt(6.6e-13 * Metre)))
: AllOf(Gt(1.0e-17 * Metre), Lt(6.6e-13 * Metre)))
<< ω_index;
}
if (ω_index == ωs.size()) {
@@ -496,7 +496,7 @@ TEST_F(FrequencyAnalysisTest, PoissonSeriesIncrementalProjectionSecular) {
? AllOf(Gt(3.3e-2 * Metre), Lt(3.6 * Metre))
: ω_index == 3
? AllOf(Gt(7.5e-3 * Metre), Lt(5.4 * Metre))
: AllOf(Gt(9.6e-17 * Metre),
: AllOf(Gt(8.7e-17 * Metre),
Lt(8.7e-14 * Metre)))
<< ω_index;
}
29 changes: 12 additions & 17 deletions numerics/poisson_series_basis.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#include <array>
#include <type_traits>
#include <utility>

#include "geometry/hilbert.hpp"
#include "geometry/named_quantities.hpp"
#include "numerics/poisson_series.hpp"
#include "quantities/named_quantities.hpp"
@@ -11,26 +13,19 @@ namespace principia {
namespace numerics {
namespace internal_poisson_series_basis {

using geometry::Hilbert;
using geometry::Instant;
using quantities::AngularFrequency;

// A helper struct for generating the Кудрявцев basis, i.e., functions of the
// form tⁿ sin ω t and tⁿ cos ω t properly ordered. |dimension| is the number
// of multivector dimensions to produce. |degree| is the maximum degree of tⁿ.
template<typename Series,
int dimension,
int degree,
typename = std::make_index_sequence<dimension * (degree + 1)>>
struct PoissonSeriesBasisGenerator;

// In this template, the indices encode the degree and the dimension of the
// basis term so that, in the terminology of SeriesGenerator, n (the degree) is
// indices / dimension and d (the dimension index) is indices % dimension.
template<typename Series, int dimension, int degree, std::size_t... indices>
struct PoissonSeriesBasisGenerator<Series,
dimension,
degree,
std::index_sequence<indices...>> {
// A generator for the Кудрявцев basis, i.e., functions of the
// form tⁿ sin ω t and tⁿ cos ω t properly ordered. |degree| is the maximum
// degree of tⁿ.
template<typename Series, int degree>
class PoissonSeriesBasisGenerator {
using Value = std::invoke_result_t<Series, Instant>;
static constexpr int dimension = Hilbert<Value>::dimension;

public:
// Basis of aperiodic terms.
static std::array<Series, dimension * (degree + 1)> Basis(
Instant const& origin);
Loading