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

Commits on Nov 29, 2020

  1. Basis orthogonality and tests.

    pleroy committed Nov 29, 2020
    Copy the full SHA
    6fa4f2d View commit details
  2. Adjust tolerances.

    pleroy committed Nov 29, 2020
    Copy the full SHA
    433a00b View commit details
  3. A microoptimization.

    pleroy committed Nov 29, 2020
    Copy the full SHA
    d1150aa View commit details
  4. Tolerances and lint.

    pleroy committed Nov 29, 2020
    Copy the full SHA
    f72ff87 View commit details
  5. Comment.

    pleroy committed Nov 29, 2020
    Copy the full SHA
    40a4208 View commit details
  6. More tolerances.

    pleroy committed Nov 29, 2020
    Copy the full SHA
    74f4e62 View commit details
  7. Merge pull request #2801 from pleroy/Parity

    Use parity in basis subspaces
    pleroy authored Nov 29, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d74f564 View commit details
14 changes: 7 additions & 7 deletions numerics/frequency_analysis_test.cpp
Original file line number Diff line number Diff line change
@@ -318,7 +318,7 @@ TEST_F(FrequencyAnalysisTest, PoissonSeriesVectorProjection) {
t_min, t_max);
for (int i = 0; i <= 100; ++i) {
EXPECT_THAT(projection4(t_min + i * Radian / ω),
AlmostEquals(series(t_min + i * Radian / ω), 0, 1536));
AlmostEquals(series(t_min + i * Radian / ω), 0, 4096));
}

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

// Projection on a 3rd degree basis introduces significant errors.
@@ -441,7 +441,7 @@ TEST_F(FrequencyAnalysisTest, PoissonSeriesIncrementalProjectionNoSecular) {
? AllOf(Gt(2.0e-10 * Metre), Lt(5.3e-7 * Metre))
: ω_index == 2
? AllOf(Gt(2.9e-13 * Metre), Lt(2.6e-9 * Metre))
: AllOf(Gt(-1.0e-100 * Metre), Lt(7.1e-14 * Metre)))
: AllOf(Gt(-1.0e-100 * Metre), Lt(7.1e-13 * Metre)))
<< ω_index;
}
if (ω_index == ωs.size()) {
@@ -463,7 +463,7 @@ TEST_F(FrequencyAnalysisTest, PoissonSeriesIncrementalProjectionNoSecular) {
EXPECT_THAT(
projection4(t_min + i * (t_max - t_min) / 100),
RelativeErrorFrom(series.value()(t_min + i * (t_max - t_min) / 100),
AllOf(Ge(0), Lt(4.8e-14))));
AllOf(Ge(0), Lt(2.5e-13))));
}
}

@@ -511,8 +511,8 @@ TEST_F(FrequencyAnalysisTest, PoissonSeriesIncrementalProjectionSecular) {
? AllOf(Gt(2.8e-10 * Metre), Lt(1.3e-6 * Metre))
: ω_index == 3
? AllOf(Gt(1.3e-13 * Metre), Lt(4.5e-9 * Metre))
: AllOf(Gt(6.4e-17 * Metre),
Lt(1.1e-13 * Metre)))
: AllOf(Gt(-1.0e-100 * Metre),
Lt(1.2e-12 * Metre)))
<< ω_index;
}
if (ω_index == ωs.size()) {
@@ -534,7 +534,7 @@ TEST_F(FrequencyAnalysisTest, PoissonSeriesIncrementalProjectionSecular) {
EXPECT_THAT(
projection4(t_min + i * (t_max - t_min) / 100),
RelativeErrorFrom(series(t_min + i * (t_max - t_min) / 100),
AllOf(Ge(0), Lt(4.4e-15))));
AllOf(Ge(0), Lt(5.2e-14))));
}
}

5 changes: 5 additions & 0 deletions numerics/poisson_series_basis.hpp
Original file line number Diff line number Diff line change
@@ -44,6 +44,8 @@ class PoissonSeriesSubspace {
friend struct AperiodicSeriesGenerator;
template<typename Series, int degree, int dimension, typename>
friend struct PeriodicSeriesGenerator;
friend std::ostream& operator<<(std::ostream& out,
PoissonSeriesSubspace const& subspace);
};

// A generator for the Кудрявцев basis, i.e., functions of the
@@ -71,6 +73,9 @@ class PoissonSeriesBasisGenerator {
Subspaces(AngularFrequency const& ω, Instant const& origin);
};

std::ostream& operator<<(std::ostream& out,
PoissonSeriesSubspace const& subspace);

} // namespace internal_poisson_series_basis

using internal_poisson_series_basis::PoissonSeriesBasisGenerator;
17 changes: 11 additions & 6 deletions numerics/poisson_series_basis_body.hpp
Original file line number Diff line number Diff line change
@@ -138,7 +138,7 @@ Polynomials PolynomialGenerator<Polynomial, dimension>::UnitPolynomials(

inline bool PoissonSeriesSubspace::orthogonal(PoissonSeriesSubspace const v,
PoissonSeriesSubspace const w) {
return v.coordinate_ != w.coordinate_;
return v.coordinate_ != w.coordinate_ || v.parity_ != w.parity_;
}

inline PoissonSeriesSubspace::PoissonSeriesSubspace(Coordinate coordinate,
@@ -230,12 +230,11 @@ std::array<PoissonSeriesSubspace, sizeof...(indices)> PeriodicSeriesGenerator<
PoissonSeriesSubspace{
static_cast<PoissonSeriesSubspace::Coordinate>(indices % dimension),
// The parity of the trigonometric factors of the ith basis element is
// (i / dimension) % 2; the degrees its polynomial factor is
// i / (2 * dimension), so that the overall parity of that basis
// element is (i / dimension + i / (2 * dimension)) % 2, which
// simplifies to (3 * i / (2 * dimension)) % 2.
// ⌊i / dimension⌋ mod 2; the degree of its polynomial factor is
// ⌊i / (2 * dimension)⌋, so that the overall parity of that basis
// element is (⌊i / dimension⌋ + ⌊i / (2 * dimension)⌋) mod 2.
static_cast<PoissonSeriesSubspace::Parity>(
(3 * indices / (2 * dimension)) % 2)}...};
(indices / dimension + indices / (2 * dimension)) % 2)}...};
}


@@ -270,6 +269,12 @@ auto PoissonSeriesBasisGenerator<Series, degree>::Subspaces(
origin);
}

inline std::ostream& operator<<(std::ostream& out,
PoissonSeriesSubspace const& subspace) {
return out << "{coordinate: " << static_cast<int>(subspace.coordinate_)
<< ", parity: " << static_cast<int>(subspace.parity_) << "}";
}

} // namespace internal_poisson_series_basis
} // namespace numerics
} // namespace principia
Loading