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

Commits on Oct 13, 2020

  1. Declare and reorder functions.

    pleroy committed Oct 13, 2020
    Copy the full SHA
    e032fcd View commit details

Commits on Oct 14, 2020

  1. Merge pull request #2762 from pleroy/Optimization

    Declare and reorder functions
    pleroy authored Oct 14, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    140154b View commit details
Showing with 40 additions and 10 deletions.
  1. +40 −10 numerics/quadrature_body.hpp
50 changes: 40 additions & 10 deletions numerics/quadrature_body.hpp
Original file line number Diff line number Diff line change
@@ -44,18 +44,34 @@ Primitive<std::invoke_result_t<Function, Argument>, Argument> Gauss(
}

template<int points, typename Argument, typename Function>
Primitive<std::invoke_result_t<Function, Argument>, Argument> GaussLegendre(
void FillClenshawCurtisCache(
Function const& f,
Argument const& lower_bound,
Argument const& upper_bound) {
static_assert(points < LegendreRoots.size,
"No table for Gauss-Legendre with the chosen number of points");
return Gauss<points>(f,
lower_bound,
upper_bound,
LegendreRoots[points],
GaussLegendreWeights[points]);
}
Argument const& upper_bound,
std::vector<std::invoke_result_t<Function, Argument>>&
f_cos_N⁻¹π_bit_reversed);

template<int points, typename Argument, typename Function>
Primitive<std::invoke_result_t<Function, Argument>, Argument>
AutomaticClenshawCurtisImplementation(
Function const& f,
Argument const& lower_bound,
Argument const& upper_bound,
std::optional<double> const max_relative_error,
std::optional<int> const max_points,
Primitive<std::invoke_result_t<Function, Argument>, Argument> const
previous_estimate,
std::vector<std::invoke_result_t<Function, Argument>>&
f_cos_N⁻¹π_bit_reversed);

template<int points, typename Argument, typename Function>
Primitive<std::invoke_result_t<Function, Argument>, Argument>
ClenshawCurtisImplementation(
Function const& f,
Argument const& lower_bound,
Argument const& upper_bound,
std::vector<std::invoke_result_t<Function, Argument>>&
f_cos_N⁻¹π_bit_reversed);

// Our automatic Cleshaw-Curtis implementation doubles the number of points
// repeatedly until it reaches a suitable exit criterion. Naïvely evaluating
@@ -227,6 +243,20 @@ ClenshawCurtisImplementation(
return Σʺ * half_width;
}

template<int points, typename Argument, typename Function>
Primitive<std::invoke_result_t<Function, Argument>, Argument> GaussLegendre(
Function const& f,
Argument const& lower_bound,
Argument const& upper_bound) {
static_assert(points < LegendreRoots.size,
"No table for Gauss-Legendre with the chosen number of points");
return Gauss<points>(f,
lower_bound,
upper_bound,
LegendreRoots[points],
GaussLegendreWeights[points]);
}

template<int initial_points, typename Argument, typename Function>
Primitive<std::invoke_result_t<Function, Argument>, Argument>
AutomaticClenshawCurtis(