E.V.E
v2022.03.00

◆ catalan

eve::catalan = {}
inlineconstexpr

Callable object computing the catalan constant \(\beta(2) = \sum_0^\infty \frac{(-1)^n}{(2n+1)^2}\).

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
template< eve::value T >
T catalan(as<T> x) noexcept;
}
constexpr callable_catalan_ catalan
Callable object computing the catalan constant .
Definition: catalan.hpp:51
Definition: all_of.hpp:22
Lightweight type-wrapper.
Definition: as.hpp:29

Parameters

  • x : Type wrapper instance embedding the type of the constant.

Return value

The call eve::catalan(as<T>()) returns the catalan constant \(\beta(2) = \sum_0^\infty \frac{(-1)^n}{(2n+1)^2}\).

Example

#include <eve/module/math.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
using wide_ft = eve::wide<float>;
using wide_dt = eve::wide<double>;
int main()
{
wide_ft wxf;
wide_dt wxd;
std::cout << "---- simd" << std::setprecision(9) << std::endl
<< "-> catalan(as<wide_ft>()) = " << eve::catalan(eve::as<wide_ft>()) << std::endl
<< "-> catalan(as(wxf)) = " << eve::catalan(eve::as(wxf)) << std::endl
<< "-> upward(catalan)(as<wide_ft>()) = " << eve::upward(eve::catalan)(eve::as<wide_ft>()) << std::endl
<< "-> upward(catalan)(as(wxf)) = " << eve::upward(eve::catalan)(eve::as(wxf)) << std::endl
<< "-> downward(catalan)(as<wide_ft>()) = " << eve::downward(eve::catalan)(eve::as<wide_ft>()) << std::endl
<< "-> downward(catalan)(as(wxf)) = " << eve::downward(eve::catalan)(eve::as(wxf)) << std::endl
<< std::setprecision(17)
<< "-> catalan(as<wide_dt>()) = " << eve::catalan(eve::as<wide_dt>()) << std::endl
<< "-> catalan(as(wxd)) = " << eve::catalan(eve::as(wxd)) << std::endl
<< "-> upward(catalan)(as<wide_dt>()) = " << eve::upward(eve::catalan)(eve::as<wide_dt>()) << std::endl
<< "-> upward(catalan)(as(wxd)) = " << eve::upward(eve::catalan)(eve::as(wxd)) << std::endl
<< "-> downward(catalan)(as<wide_dt>()) = " << eve::downward(eve::catalan)(eve::as<wide_dt>()) << std::endl
<< "-> downward(catalan)(as(wxd)) = " << eve::downward(eve::catalan)(eve::as(wxd)) << std::endl;
float xf;
double xd;
std::cout << "---- scalar" << std::endl
<< "-> catalan(as<float>()) = " << eve::catalan(eve::as(float())) << std::endl
<< "-> catalan(as<xf)) = " << eve::catalan(eve::as(xf)) << std::endl
<< "-> catalan(as<double>()) = " << eve::catalan(eve::as(double()))<< std::endl
<< "-> catalan(as<xd)) = " << eve::catalan(eve::as(xd)) << std::endl;
return 0;
}
constexpr upward_type const upward
Higher-order Callable Object imbuing upward rounding semantic onto other Callable Objects.
Definition: roundings.hpp:160
constexpr downward_type const downward
Higher-order Callable Object imbuing rounding downard semantic onto other Callable Objects.
Definition: roundings.hpp:161
Wrapper for SIMD registers.
Definition: wide.hpp:65