Defined in header
#include <eve/module/math.hpp>
{
}
constexpr auto lentz_b
Implement the lentz scheme to evaluate continued fractions.
Definition lentz_b.hpp:92
typename decltype(detail::as_translated_type(as< T >{}))::type translate_t
Returns the final translated type of T.
Definition translation.hpp:107
EVE Main Namespace.
Definition abi.hpp:19
Parameters
g : generator function.
tol : tolerance value. If negative the effective tolerance will be abs(tol)*eveeps(as(< u_t>) where u_t is the underlying floating type associated to the return type of the invocable g.
max_terms : no more than max_terms calls to the generator will be made.
The generator type should be an invocable which supports the following operations:
- The call to g() returns a floating value or a pair (kumi::tuple) of such. Each time this operator is called then the next pair of a and b values has to be returned, or, if result_type is not a pair type, then the next b value has to be returned and all the a values are assumed to be equal to one.
- In all the continued fraction evaluation functions the effective tol parameter is the relative precision desired in the result, The evaluation of the fraction will continue until the last term evaluated leaves the relative error in the result less than tolerance or the max_terms iteration is reached.
Return value
The value of the continued fraction is returned. \(\displaystyle b_0+\frac{a_1}{b_1+\frac{a_2}{b_2+\frac{a_3}{b_3+\cdots\vphantom{\frac{1}{1}} }}}\)
Note that the the first a value (a0) generated is not used here.
- Note
- the implementation is largely inspired by the boost/math/fraction one, with less requirements on the invocable. Peculiarly lambda functions can be used.
#include <eve/module/math.hpp>
#include <iostream>
template <class T>
{
auto operator()(){
return T{1.0, 2.0, 3.0, 4.0}; }
};
template <typename T>
{
auto operator()()
{
return kumi::tuple{
a,
b};
}
};
template <class T>
{
}
{
std::cout <<
" constant fracs " <<
gr << std::endl;
std::cout <<
"frac tan(" <<
z <<
") is: " <<
mytan(
z) << std::endl;
std::cout <<
"ref tan(" <<
z <<
") is: " <<
eve::tan(
z) << std::endl;
}
constexpr auto sqrt
Computes the elementwise square root of the parameter.
Definition sqrt.hpp:81
constexpr auto sqr
Computes the square of the parameter.
Definition sqr.hpp:97
constexpr auto eps
Computes a constant to the machine epsilon.
Definition eps.hpp:74
constexpr auto tan
elementwise_callable object computing the tangent.
Definition tan.hpp:92
Lightweight type-wrapper.
Definition as.hpp:29
Wrapper for SIMD registers.
Definition wide.hpp:94