Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization of integration #2761

Merged
merged 12 commits into from
Oct 13, 2020
Merged

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented Oct 13, 2020

  1. Add Norm² which may be more efficient than InnerProduct of a vector with itself.
  2. Change the Clenshaw-Curtis quadrature to cache function evaluations, thus cutting the overall number of evaluations by 2.

#2400.

Copy link
Member

@eggrobin eggrobin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// TODO(egg): Hilbert::Norm².
return Hilbert<Vector>::InnerProduct(real_part_, real_part_) +
Hilbert<Vector>::InnerProduct(imaginary_part_, imaginary_part_);

geometry/hilbert.hpp Show resolved Hide resolved
@@ -45,11 +45,12 @@ struct Hilbert<T, T, std::enable_if_t<is_quantity_v<T>>>
using InnerProductType = Square<T>;
static InnerProductType InnerProduct(T const& t1, T const& t2);

using Norm²Type = InnerProductType;
static Norm²Type Norm²(T const& t);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use it here:

// TODO(egg): Hilbert::Norm².
return Hilbert<Vector>::InnerProduct(real_part_, real_part_) +
Hilbert<Vector>::InnerProduct(imaginary_part_, imaginary_part_);

Sorry, something went wrong.

numerics/quadrature_body.hpp Outdated Show resolved Hide resolved
numerics/quadrature_body.hpp Outdated Show resolved Hide resolved
numerics/quadrature_body.hpp Outdated Show resolved Hide resolved
numerics/quadrature_body.hpp Outdated Show resolved Hide resolved
numerics/quadrature_body.hpp Outdated Show resolved Hide resolved
f_cos_N⁻¹π[s] = f_cos_N⁻¹π_bit_reversed[bit_reversed_s];
if (s > 0) {
// [Gen72c] (5).
f_cos_N⁻¹π[2 * N - s] = f_cos_N⁻¹π_bit_reversed[bit_reversed_s];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The right-hand side here should be f_cos_N⁻¹π[s] to match (5).

@eggrobin eggrobin added the LGTM label Oct 13, 2020
@pleroy pleroy merged commit 6a5c01b into mockingbirdnest:master Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants