The generator type should be an invocable which supports the following operations:
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.
#include <eve/module/math.hpp>
#include <iostream>
template <class T>
struct const_fraction
{
auto operator()(){ return T{1.0, 2.0, 3.0, 4.0}; }
};
template <typename T>
struct tan_fraction
{
T a, b;
tan_fraction(T v) : a(-v * v), b(-1) {}
auto operator()()
{
b += T(2);
return kumi::tuple{a, b};
}
};
template <class T>
T mytan(T a)
{
tan_fraction<T> fract(a);
}
int main()
{
const_fraction<w_t> func;
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 sqr
Computes the square of the parameter.
Definition sqr.hpp:92
constexpr auto sqrt
Computes the square root of the parameter.
Definition sqrt.hpp:80
constexpr auto eps
Computes a constant to the machine epsilon.
Definition eps.hpp:73
constexpr auto pio_4
Callable object computing the constant .
Definition pio_4.hpp:77
constexpr auto pio_3
Callable object computing the constant .
Definition pio_3.hpp:77
constexpr auto tan
elementwise_callable object computing the tangent.
Definition tan.hpp:91
Lightweight type-wrapper.
Definition as.hpp:29
Wrapper for SIMD registers.
Definition wide.hpp:86