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

Commits on Jun 23, 2020

  1. The headers.

    pleroy committed Jun 23, 2020
    Copy the full SHA
    df24939 View commit details
  2. Copy the full SHA
    7389316 View commit details
  3. Add a test.

    pleroy committed Jun 23, 2020
    Copy the full SHA
    f20aef2 View commit details
  4. Undo some changes.

    pleroy committed Jun 23, 2020
    Copy the full SHA
    cb9f7db View commit details
  5. Copy the full SHA
    0c4755b View commit details
  6. A more complete test.

    pleroy committed Jun 23, 2020
    Copy the full SHA
    a49c139 View commit details
  7. Tests passing.

    pleroy committed Jun 23, 2020
    Copy the full SHA
    aa0bf32 View commit details

Commits on Jun 24, 2020

  1. Copy the full SHA
    efa11e2 View commit details
  2. After egg's review.

    pleroy committed Jun 24, 2020
    Copy the full SHA
    6db2051 View commit details
  3. After egg's 2nd review.

    pleroy committed Jun 24, 2020
    Copy the full SHA
    778eee1 View commit details
  4. Merge pull request #2610 from pleroy/PoissonSeries

    The vector space of Poisson series
    pleroy authored Jun 24, 2020
    Copy the full SHA
    40de4b0 View commit details
6 changes: 6 additions & 0 deletions geometry/cartesian_product.hpp
Original file line number Diff line number Diff line change
@@ -14,6 +14,12 @@ namespace geometry {
// polluting the entire universe in cases where they are not useful.
namespace cartesian_product {

template<typename RTuple>
constexpr auto operator+(RTuple const& right);

template<typename RTuple>
constexpr auto operator-(RTuple const& right);

template<typename LTuple, typename RTuple>
constexpr auto operator+(LTuple const& left, RTuple const& right);

14 changes: 14 additions & 0 deletions geometry/cartesian_product_body.hpp
Original file line number Diff line number Diff line change
@@ -290,6 +290,20 @@ constexpr auto PolynomialRing<LTuple, RTuple, lsize_, 1>::Multiply(

namespace cartesian_product {

template<typename RTuple>
FORCE_INLINE(constexpr) auto operator+(RTuple const& right) {
return right;
}

template<typename RTuple>
FORCE_INLINE(constexpr)
auto operator-(RTuple const& right) {
std::tuple<> zero;
return internal_cartesian_product::
CartesianProductAdditiveGroup<decltype(zero), RTuple>::Subtract(zero,
right);
}

template<typename LTuple, typename RTuple>
FORCE_INLINE(constexpr)
auto operator+(LTuple const& left, RTuple const& right) {
3 changes: 3 additions & 0 deletions numerics/numerics.vcxproj
Original file line number Diff line number Diff line change
@@ -41,6 +41,8 @@
<ClInclude Include="newhall_body.hpp" />
<ClInclude Include="pid.hpp" />
<ClInclude Include="pid_body.hpp" />
<ClInclude Include="poisson_series.hpp" />
<ClInclude Include="poisson_series_body.hpp" />
<ClInclude Include="polynomial.hpp" />
<ClInclude Include="polynomial_body.hpp" />
<ClInclude Include="polynomial_evaluators.hpp" />
@@ -71,6 +73,7 @@
<ClCompile Include="max_abs_normalized_associated_legendre_functions_test.cc" />
<ClCompile Include="newhall_test.cpp" />
<ClCompile Include="pid_test.cpp" />
<ClCompile Include="poisson_series_test.cpp" />
<ClCompile Include="polynomial_evaluators_test.cpp" />
<ClCompile Include="polynomial_test.cpp" />
<ClCompile Include="root_finders_test.cpp" />
9 changes: 9 additions & 0 deletions numerics/numerics.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -125,6 +125,12 @@
<ClInclude Include="pid_body.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="poisson_series.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="poisson_series_body.hpp">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="чебышёв_series_test.cpp">
@@ -193,6 +199,9 @@
<ClCompile Include="pid_test.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="poisson_series_test.cpp">
<Filter>Test Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="xgscd.proto.txt">
133 changes: 133 additions & 0 deletions numerics/poisson_series.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

#pragma once

#include <algorithm>
#include <map>

#include "numerics/polynomial.hpp"
#include "quantities/named_quantities.hpp"
#include "quantities/quantities.hpp"

namespace principia {
namespace numerics {
namespace internal_poisson_series {

using quantities::AngularFrequency;
using quantities::Product;
using quantities::Quotient;
using quantities::Time;

// A Poisson series is the sum of terms of the form:
// aₙtⁿ aₙₖ tⁿ sin ωₖ t aₙₖ tⁿ cos ωₖ t
// Terms of the first kind are called aperiodic, terms of the second and third
// kind are called periodic. Poisson series form an algebra that is stable by
// derivation and integration.
template<typename Value, int degree_,
template<typename, typename, int> class Evaluator>
class PoissonSeries {
public:
using Polynomial =
numerics::PolynomialInMonomialBasis<Value, Time, degree_, Evaluator>;

// TODO(phl): Use designated initializers for this struct once this project
// can be compiled using c++latest.
struct Polynomials {
Polynomial sin;
Polynomial cos;
};

using PolynomialsByAngularFrequency = std::map<AngularFrequency, Polynomials>;

PoissonSeries(Polynomial const& aperiodic,
PolynomialsByAngularFrequency const& periodic);

Value Evaluate(Time const& t) const;

private:
Polynomial aperiodic_;
// All the keys in this map are positive.
PolynomialsByAngularFrequency periodic_;

template<typename V, int r, template<typename, typename, int> class E>
PoissonSeries<V, r, E> friend operator-(PoissonSeries<V, r, E> const& right);
template<typename V, int l, int r, template<typename, typename, int> class E>
PoissonSeries<V, std::max(l, r), E> friend operator+(
PoissonSeries<V, l, E> const& left,
PoissonSeries<V, r, E> const& right);
template<typename V, int l, int r, template<typename, typename, int> class E>
PoissonSeries<V, std::max(l, r), E> friend operator-(
PoissonSeries<V, l, E> const& left,
PoissonSeries<V, r, E> const& right);
template<typename Scalar,
typename V, int degree_,
template<typename, typename, int> class E>
PoissonSeries<Product<Scalar, V>, degree_, E> friend operator*(
Scalar const& left,
PoissonSeries<V, degree_, E> const& right);
template<typename Scalar,
typename V, int degree_,
template<typename, typename, int> class E>
PoissonSeries<Product<V, Scalar>, degree_, E> friend operator*(
PoissonSeries<V, degree_, E> const& left,
Scalar const& right);
template<typename Scalar,
typename V, int degree_,
template<typename, typename, int> class E>
PoissonSeries<Quotient<V, Scalar>, degree_, E> friend operator/(
PoissonSeries<V, degree_, E> const& left,
Scalar const& right);
};

// Vector space of Poisson series.

template<typename Value, int rdegree_,
template<typename, typename, int> class Evaluator>
PoissonSeries<Value, rdegree_, Evaluator>
operator+(PoissonSeries<Value, rdegree_, Evaluator> const& right);

template<typename Value, int rdegree_,
template<typename, typename, int> class Evaluator>
PoissonSeries<Value, rdegree_, Evaluator>
operator-(PoissonSeries<Value, rdegree_, Evaluator> const& right);

template<typename Value, int ldegree_, int rdegree_,
template<typename, typename, int> class Evaluator>
PoissonSeries<Value, std::max(ldegree_, rdegree_), Evaluator>
operator+(PoissonSeries<Value, ldegree_, Evaluator> const& left,
PoissonSeries<Value, rdegree_, Evaluator> const& right);

template<typename Value, int ldegree_, int rdegree_,
template<typename, typename, int> class Evaluator>
PoissonSeries<Value, std::max(ldegree_, rdegree_), Evaluator>
operator-(PoissonSeries<Value, ldegree_, Evaluator> const& left,
PoissonSeries<Value, rdegree_, Evaluator> const& right);

template<typename Scalar,
typename Value, int degree_,
template<typename, typename, int> class Evaluator>
PoissonSeries<Product<Scalar, Value>, degree_, Evaluator>
operator*(Scalar const& left,
PoissonSeries<Value, degree_, Evaluator> const& right);

template<typename Scalar,
typename Value, int degree_,
template<typename, typename, int> class Evaluator>
PoissonSeries<Product<Value, Scalar>, degree_, Evaluator>
operator*(PoissonSeries<Value, degree_, Evaluator> const& left,
Scalar const& right);

template<typename Scalar,
typename Value, int degree_,
template<typename, typename, int> class Evaluator>
PoissonSeries<Quotient<Value, Scalar>, degree_, Evaluator>
operator/(PoissonSeries<Value, degree_, Evaluator> const& left,
Scalar const& right);

} // namespace internal_poisson_series

using internal_poisson_series::PoissonSeries;

} // namespace numerics
} // namespace principia

#include "numerics/poisson_series_body.hpp"
Loading