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

Commits on Jun 8, 2021

  1. fix the build

    eggrobin committed Jun 8, 2021
    Copy the full SHA
    1134ebd View commit details
  2. Merge pull request #3028 from eggrobin/fma-polynomials

    Fix the build
    eggrobin authored Jun 8, 2021
    Copy the full SHA
    38b12d6 View commit details
Showing with 28 additions and 19 deletions.
  1. +28 −19 numerics/polynomial_evaluators.hpp
47 changes: 28 additions & 19 deletions numerics/polynomial_evaluators.hpp
Original file line number Diff line number Diff line change
@@ -11,21 +11,38 @@ namespace internal_polynomial_evaluators {
using quantities::Derivative;
using quantities::Square;

// The structs below are only needed because the language won't let us have (1)
// a partial specialization of a function (2) an explicit specialization of a
// member function template in an unspecialized class template. Sigh.
template<typename Value, typename Argument, int degree, bool allow_fma>
struct EstrinEvaluator;
template<typename Value, typename Argument, int degree, bool allow_fma>
struct HornerEvaluator;

namespace exported {
template<typename Value, typename Argument, int degree>
using EstrinEvaluator = internal_polynomial_evaluators::
EstrinEvaluator<Value, Argument, degree, /*allow_fma=*/true>;
template<typename Value, typename Argument, int degree>
using EstrinEvaluatorWithoutFMA = internal_polynomial_evaluators::
EstrinEvaluator<Value, Argument, degree, /*allow_fma=*/false>;
template<typename Value, typename Argument, int degree>
using HornerEvaluator = internal_polynomial_evaluators::
HornerEvaluator<Value, Argument, degree, /*allow_fma=*/true>;
template<typename Value, typename Argument, int degree>
using HornerEvaluatorWithoutFMA = internal_polynomial_evaluators::
HornerEvaluator<Value, Argument, degree, /*allow_fma=*/false>;
} // namespace exported

// We use FORCE_INLINE because we have to write this recursively, but we really
// want linear code.

template<typename Value, typename Argument, int degree, bool allow_fma = true>
template<typename Value, typename Argument, int degree, bool allow_fma>
struct EstrinEvaluator {
// The fully qualified name below designates the template, not the current
// instance.
using Coefficients = typename PolynomialInMonomialBasis<
Value,
Argument,
degree,
internal_polynomial_evaluators::EstrinEvaluator>::Coefficients;
exported::EstrinEvaluator>::Coefficients;

FORCE_INLINE(static) Value Evaluate(Coefficients const& coefficients,
Argument const& argument);
@@ -34,19 +51,15 @@ struct EstrinEvaluator {
Argument const& argument);
};

template<typename Value, typename Argument, int degree>
using EstrinEvaluatorWithoutFMA =
EstrinEvaluator<Value, Argument, degree, /*allow_fma=*/false>;

template<typename Value, typename Argument, int degree, bool allow_fma = true>
template<typename Value, typename Argument, int degree, bool allow_fma>
struct HornerEvaluator {
// The fully qualified name below designates the template, not the current
// instance.
using Coefficients = typename PolynomialInMonomialBasis<
Value,
Argument,
degree,
internal_polynomial_evaluators::HornerEvaluator>::Coefficients;
exported::HornerEvaluator>::Coefficients;

FORCE_INLINE(static) Value Evaluate(Coefficients const& coefficients,
Argument const& argument);
@@ -55,16 +68,12 @@ struct HornerEvaluator {
Argument const& argument);
};

template<typename Value, typename Argument, int degree>
using HornerEvaluatorWithoutFMA =
HornerEvaluator<Value, Argument, degree, /*allow_fma=*/false>;

} // namespace internal_polynomial_evaluators

using internal_polynomial_evaluators::EstrinEvaluator;
using internal_polynomial_evaluators::EstrinEvaluatorWithoutFMA;
using internal_polynomial_evaluators::HornerEvaluator;
using internal_polynomial_evaluators::HornerEvaluatorWithoutFMA;
using internal_polynomial_evaluators::exported::EstrinEvaluator;
using internal_polynomial_evaluators::exported::EstrinEvaluatorWithoutFMA;
using internal_polynomial_evaluators::exported::HornerEvaluator;
using internal_polynomial_evaluators::exported::HornerEvaluatorWithoutFMA;

} // namespace numerics
} // namespace principia