44 "num_collect::integration::gauss_legendre_integrator");
51template <
typename Signature>
60template <
typename Result, base::concepts::real_scalar Variable>
82 "Degree of Legendre function must be at least one.");
93 "Degree of Legendre function must be at least one.");
94 roots_.compute(degree);
107 template <base::concepts::invocable_as<result_type(variable_type)> Function>
110 const auto degree = roots_.degree();
117 sum += weight * function(x);
119 return sum * half_width;
131 template <base::concepts::invocable_as<result_type(variable_type)> Function>
134 return integrate(function, left, right);
142 const auto degree = roots_.degree();
143 weights_.resize(degree);
157 Eigen::Matrix<variable_type, Eigen::Dynamic, 1> weights_{};
Class of roots of Legendre function.
std::decay_t< Result > result_type
Type of results.
gauss_legendre_integrator(index_type degree=default_degree)
Constructor.
void update_weight()
Update weight for roots.
void prepare(index_type degree)
Compute internal variables for integration.
auto operator()(const Function &function, variable_type left, variable_type right) const -> result_type
Integrate a function.
functions::legendre_roots< variable_type > roots_
Roots of Legendre function.
std::decay_t< Variable > variable_type
Type of variables.
auto integrate(const Function &function, variable_type left, variable_type right) const -> result_type
Integrate a function.
Class to perform numerical integration with Gauss-Legendre formula.
Class of tags of logs without memory management.
Class to incorporate logging in algorithms.
Definition of index_type type.
Definition of invocable_as concept.
Definition of legendre function.
Definition of legendre_roots function.
Definition of log_tag_view class.
Definition of logging_mixin class.
std::ptrdiff_t index_type
Type of indices in this library.
constexpr T half
Value 0.5.
constexpr auto legendre(F x, I n) -> F
Calculate Legendre function.
Namespace of numerical integration.
constexpr auto gauss_legendre_integrator_tag
Tag of gauss_legendre_integrator.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.
Definition of real_scalar concept.