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

Commits on Aug 25, 2020

  1. Copy the full SHA
    df03f42 View commit details
  2. Merge pull request #2693 from pleroy/Bugs

    Work-around polynomial operators +/- and fix the Mathematica test
    pleroy authored Aug 25, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9699e42 View commit details
Showing with 13 additions and 12 deletions.
  1. +4 −5 mathematica/mathematica_body.hpp
  2. +0 −7 mathematica/mathematica_test.cpp
  3. +9 −0 numerics/polynomial_body.hpp
9 changes: 4 additions & 5 deletions mathematica/mathematica_body.hpp
Original file line number Diff line number Diff line change
@@ -341,20 +341,19 @@ template<typename V, int d,
template<typename, typename, int> class E,
typename OptionalExpressIn>
std::string ToMathematica(PoissonSeries<V, d, E> const& series,
std::string const& variable,
OptionalExpressIn express_in) {
std::vector<std::string> components = {
ToMathematica(series.aperiodic_, variable, express_in)};
ToMathematica(series.aperiodic_, express_in)};
for (auto const& [ω, polynomials] : series.periodic_) {
std::string const polynomial_sin =
ToMathematica(polynomials.sin, variable, express_in);
ToMathematica(polynomials.sin, express_in);
std::string const polynomial_cos =
ToMathematica(polynomials.cos, variable, express_in);
ToMathematica(polynomials.cos, express_in);
std::string const angle =
Apply("Times",
{ToMathematica(ω, express_in),
Apply("Subtract",
{variable, ToMathematica(series.origin_, express_in)})});
{"#", ToMathematica(series.origin_, express_in)})});
components.push_back(Apply("Times",
{polynomial_sin, Apply("Sin", {angle})}));
components.push_back(Apply("Times",
7 changes: 0 additions & 7 deletions mathematica/mathematica_test.cpp
Original file line number Diff line number Diff line change
@@ -343,12 +343,6 @@ TEST_F(MathematicaTest, ToMathematica) {
"2]]]",
ToMathematica(polynomial2));
}
#if 0
// This test does not compile with MSVC 16.6.3: it thinks that operators + and
// - on polynomials are ambiguous deep in the constructor of PoissonSeries.
// But don't despair, because the exact same code compiled in a different
// place (frequency_analysis_test.cpp) works like a charm...
// With Clang it doesn't because it misses the body of ToMathematica.
{
using Series = PoissonSeries<double, 0, HornerEvaluator>;
Instant const t0 = Instant() + 3 * Second;
@@ -389,7 +383,6 @@ TEST_F(MathematicaTest, ToMathematica) {
"\" s\"]]]]]]",
ToMathematica(series));
}
#endif
{
std::optional<std::string> opt1;
std::optional<std::string> opt2("foo");
9 changes: 9 additions & 0 deletions numerics/polynomial_body.hpp
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@

#include "absl/strings/str_join.h"
#include "absl/strings/str_cat.h"
#include "base/macros.hpp"
#include "base/not_constructible.hpp"
#include "base/traits.hpp"
#include "geometry/cartesian_product.hpp"
@@ -554,7 +555,11 @@ template<typename Value, typename Argument, int degree_,
PolynomialInMonomialBasis<Value, Point<Argument>, degree_, Evaluator>&
PolynomialInMonomialBasis<Value, Point<Argument>, degree_, Evaluator>::
operator+=(PolynomialInMonomialBasis const& right) {
#if PRINCIPIA_COMPILER_MSVC
this->coefficients_ = this->coefficients_ + right.coefficients_;
#else
*this = *this + right;
#endif
return *this;
}

@@ -563,7 +568,11 @@ template<typename Value, typename Argument, int degree_,
PolynomialInMonomialBasis<Value, Point<Argument>, degree_, Evaluator>&
PolynomialInMonomialBasis<Value, Point<Argument>, degree_, Evaluator>::
operator-=(PolynomialInMonomialBasis const& right) {
#if PRINCIPIA_COMPILER_MSVC
this->coefficients_ = this->coefficients_ - right.coefficients_;
#else
*this = *this - right;
#endif
return *this;
}