54template <
typename Signature>
64template <
typename Result, base::concepts::real_scalar Variable>
77 calculate_coefficients();
89 template <base::concepts::invocable_as<result_type(variable_type)> Function>
100 const variable_type center_weight = width * center_weight_rate;
102 sum += function(center) * center_weight;
106 width * variable_rate_list_[
static_cast<std::size_t
>(i)];
108 width * weight_rate_list_[
static_cast<std::size_t
>(i)];
113 function(var_plus) + function(var_minus);
116 "A function value was not a finite value. "
117 "Stopped numerical integration.");
120 sum += function_values * weight;
123 return sum.
sum() * interval_;
140 template <base::concepts::invocable_as<result_type(variable_type)>
141 LeftBoundaryFunction,
142 base::concepts::invocable_as<result_type(variable_type)>
143 RightBoundaryFunction>
145 const LeftBoundaryFunction& left_boundary_function,
146 const RightBoundaryFunction& right_boundary_function,
152 const variable_type half_width = half<variable_type> * width;
156 const variable_type center_weight = width * center_weight_rate;
158 sum += left_boundary_function(half_width) * center_weight;
162 width * variable_rate_list_[
static_cast<std::size_t
>(i)];
164 width * weight_rate_list_[
static_cast<std::size_t
>(i)];
167 left_boundary_function(variable_distance) +
168 right_boundary_function(-variable_distance);
171 "A function value was not a finite value. "
172 "Stopped numerical integration.");
175 sum += function_values * weight;
178 return sum.
sum() * interval_;
190 template <base::concepts::invocable_as<result_type(variable_type)> Function>
193 return integrate(function, left, right);
210 template <base::concepts::invocable_as<result_type(variable_type)>
211 LeftBoundaryFunction,
212 base::concepts::invocable_as<result_type(variable_type)>
213 RightBoundaryFunction>
215 const LeftBoundaryFunction& left_boundary_function,
216 const RightBoundaryFunction& right_boundary_function,
219 left_boundary_function, right_boundary_function, left, right);
230 this->logger(),
"Maximum point must be a positive value.");
232 calculate_coefficients();
244 "Number of points must be a positive integer.");
246 calculate_coefficients();
267 half_width * std::cosh(changed_var) * exp_value /
268 (exp_value_p1 * exp_value_p1);
280 variable_rate_list_.clear();
281 variable_rate_list_.reserve(
static_cast<std::size_t
>(points_));
282 weight_rate_list_.clear();
283 weight_rate_list_.reserve(
static_cast<std::size_t
>(points_));
285 interval_ = max_point_ /
static_cast<variable_type>(points_);
290 std::exp(-pi<variable_type> * std::sinh(changed_variable));
291 const variable_type denominator = one<variable_type> + exp_value;
292 variable_rate_list_.push_back(exp_value / denominator);
293 weight_rate_list_.push_back(pi<variable_type> *
294 std::cosh(changed_variable) * exp_value /
295 (denominator * denominator));
315 std::vector<variable_type> variable_rate_list_{};
318 std::vector<variable_type> weight_rate_list_{};
auto points(index_type val) -> de_finite_integrator &
Set number of points.
de_finite_integrator()
Constructor.
void calculate_coefficients()
Calculate coefficients for integration.
static auto diff_coeff(variable_type changed_var, variable_type half_width) -> variable_type
Calculate differential coefficient for change of variable.
auto operator()(const LeftBoundaryFunction &left_boundary_function, const RightBoundaryFunction &right_boundary_function, variable_type left, variable_type right) const -> result_type
Integrate a function.
auto max_point(variable_type val) -> de_finite_integrator &
Set maximum point in changed variable.
auto operator()(const Function &function, variable_type left, variable_type right) const -> result_type
Integrate a function.
auto integrate(const LeftBoundaryFunction &left_boundary_function, const RightBoundaryFunction &right_boundary_function, variable_type left, variable_type right) const -> result_type
Integrate a 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.
std::decay_t< Result > result_type
Type of results.
Class to perform numerical integration on finite range using double exponential rule.
Class of tags of logs without memory management.
Class to incorporate logging in algorithms.
Class to add numbers using Kahan summation kahan1965.
auto sum() const noexcept -> const T &
Get sum.
Definition of index_type type.
Definition of invocable_as concept.
Definition of isfinite function.
Definition of kahan_adder class.
Definition of log_tag_view class.
Definition of macros for logging.
#define NUM_COLLECT_LOG_WARNING(LOGGER,...)
Write a warning log.
Definition of logging_mixin class.
std::ptrdiff_t index_type
Type of indices in this library.
auto isfinite(const T &val) -> bool
Check whether a number is finite.
constexpr T pi
Value of pi, .
constexpr T half
Value 0.5.
Namespace of numerical integration.
constexpr auto de_finite_integrator_tag
Tag of de_finite_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.