49template <base::concepts::real_scalar T>
65 degree >= 1,
"Degree of Legendre function must be at least one.");
113template <base::concepts::real_scalar T>
139 degree >= 1,
"Degree of Legendre function must be at least one.");
147 auto solver = solver_type(function_type(
degree_));
148 constexpr auto tol_last_change =
149 std::numeric_limits<variable_type>::epsilon() *
151 constexpr auto tol_value_norm =
152 std::numeric_limits<variable_type>::epsilon() *
154 solver.tol_last_change(tol_last_change);
155 solver.tol_value_norm(tol_value_norm);
157 for (
index_type i = 0; i < roots_to_solve; ++i) {
159 constexpr auto offset_in_num =
static_cast<variable_type>(0.75);
160 constexpr auto offset_in_den =
static_cast<variable_type>(0.5);
165 solver.init(init_var);
167 roots_[i] = solver.variable();
221 Eigen::Matrix<variable_type, Eigen::Dynamic, 1>
roots_{};
Definition of assertion macros.
#define NUM_COLLECT_DEBUG_ASSERT(CONDITION)
Macro to check whether a condition is satisfied in debug build only.
Class of Legendre function to use with num_collect::roots::newton_raphson class.
T variable_type
Type of variables.
index_type degree_
Degree of Legendre function.
legendre_for_newton(index_type degree)
Constructor.
auto jacobian() const noexcept -> const jacobian_type &
Get Jacobian.
auto value() const noexcept -> const variable_type &
Get function value.
variable_type value_
Function value.
T jacobian_type
Type of Jacobians.
void evaluate_on(const variable_type &variable)
Evaluate on a variable.
jacobian_type jacobian_
Jacobian matrix.
Class of roots of Legendre function.
auto size() const noexcept -> index_type
Get the number of roots.
Eigen::Matrix< variable_type, Eigen::Dynamic, 1 > roots_
List of roots.
void compute(index_type degree)
Compute roots of Legendre function.
index_type degree_
Degree of Legendre function.
auto degree() const noexcept -> index_type
Get the degree of Legendre function.
auto operator[](index_type i) const -> variable_type
Get the i-th root.
auto root(index_type i) const -> variable_type
Get the i-th root.
T variable_type
Type of variables.
legendre_roots(index_type degree=0)
Constructor.
Class of Newton-Raphson method.
Definition of exceptions.
Definition of index_type type.
Definition of legendre function.
Definition of macros for logging.
std::ptrdiff_t index_type
Type of indices in this library.
constexpr T pi
Value of pi, .
Namespace of special functions.
constexpr auto legendre_with_diff(F x, I n) -> std::pair< F, F >
Calculate Legendre function and its differential coefficient.
Definition of newton_raphson class.
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.