53template <
typename Variable>
63 static constexpr double default_max_point = 10.0F;
73 static constexpr double default_max_point = 20.0;
84template <
typename Signature>
94template <
typename Result, base::concepts::real_scalar Variable>
108 calculate_coefficients();
120 template <base::concepts::invocable_as<result_type(variable_type)> Function>
127 constexpr auto center_weight_rate =
static_cast<variable_type>(0.5);
128 const variable_type center_weight = width * center_weight_rate;
130 sum += function(center) * center_weight;
134 width * variable_rate_list_[
static_cast<std::size_t
>(i)];
136 width * weight_rate_list_[
static_cast<std::size_t
>(i)];
141 function(var_plus) + function(var_minus);
144 "A function value was not a finite value. "
145 "Stopped numerical integration.");
148 sum += function_values * weight;
151 return sum.
sum() * interval_;
168 template <base::concepts::invocable_as<result_type(variable_type)>
169 LeftBoundaryFunction,
170 base::concepts::invocable_as<result_type(variable_type)>
171 RightBoundaryFunction>
173 const LeftBoundaryFunction& left_boundary_function,
174 const RightBoundaryFunction& right_boundary_function,
179 const variable_type half_width = half<variable_type> * width;
181 constexpr auto center_weight_rate =
static_cast<variable_type>(0.5);
182 const variable_type center_weight = width * center_weight_rate;
184 sum += left_boundary_function(half_width) * center_weight;
188 width * variable_rate_list_[
static_cast<std::size_t
>(i)];
190 width * weight_rate_list_[
static_cast<std::size_t
>(i)];
193 left_boundary_function(variable_distance) +
194 right_boundary_function(-variable_distance);
197 "A function value was not a finite value. "
198 "Stopped numerical integration.");
201 sum += function_values * weight;
204 return sum.
sum() * interval_;
216 template <base::concepts::invocable_as<result_type(variable_type)> Function>
219 return integrate(function, left, right);
236 template <base::concepts::invocable_as<result_type(variable_type)>
237 LeftBoundaryFunction,
238 base::concepts::invocable_as<result_type(variable_type)>
239 RightBoundaryFunction>
241 const LeftBoundaryFunction& left_boundary_function,
242 const RightBoundaryFunction& right_boundary_function,
245 left_boundary_function, right_boundary_function, left, right);
256 this->logger(),
"Maximum point must be a positive value.");
258 calculate_coefficients();
270 "Number of points must a positive integer.");
272 calculate_coefficients();
285 variable_rate_list_.clear();
286 variable_rate_list_.reserve(
static_cast<std::size_t
>(points_));
287 weight_rate_list_.clear();
288 weight_rate_list_.reserve(
static_cast<std::size_t
>(points_));
290 interval_ = max_point_ /
static_cast<variable_type>(points_);
296 const variable_type denominator = one<variable_type> + exp_value;
297 variable_rate_list_.push_back(exp_value / denominator);
299 exp_value / (denominator * denominator));
304 static constexpr auto default_max_point =
320 std::vector<variable_type> variable_rate_list_{};
323 std::vector<variable_type> weight_rate_list_{};
tanh_finite_integrator()
Constructor.
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 integrate(const LeftBoundaryFunction &left_boundary_function, const RightBoundaryFunction &right_boundary_function, variable_type left, variable_type right) const -> result_type
Integrate a function.
auto integrate(const Function &function, variable_type left, variable_type right) const -> result_type
Integrate a function.
void calculate_coefficients()
Calculate coefficients for integration.
auto max_point(variable_type val) -> tanh_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.
std::decay_t< Result > result_type
Type of results.
std::decay_t< Variable > variable_type
Type of variables.
auto points(index_type val) -> tanh_finite_integrator &
Set number of points.
Class to perform numerical integration on finite range using TANH 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 exceptions.
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 half
Value 0.5.
Namespace of numerical integration.
constexpr auto tanh_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.
Helper class of constants for use in tanh_finite_integrator class.