C++ Library Extensions 2022.12.09
To help learn modern C++ programming
cpg::rational_number Namespace Reference

Classes

class  rational
 

Concepts

concept  real_number_c
 
concept  allowed_type_c
 
concept  number_c
 

Typedefs

using real_number_list = types::type_container< float, double, long double >
 
using allowed_type_list = types::type_container< char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long >
 
using numerical_type_list = types::type_container< char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double >
 

Functions

template<allowed_type_c ElementType>
constexpr ElementType reduce_adjusted (ElementType &A, ElementType &B) noexcept
 
template<allowed_type_c ElementType>
constexpr ElementType reduce_simple (ElementType &A, ElementType &B) noexcept
 
template<allowed_type_c T>
constexpr bool tell_comparable_as_double ()
 
template<allowed_type_c L, allowed_type_c R>
requires ( !std::same_as<L, R>)
std::strong_ordering operator<=> (rational< L > const &lhs, rational< R > const &rhs)
 
template<allowed_type_c L, allowed_type_c R>
requires ( !std::same_as<L, R>)
std::strong_ordering operator<=> (rational< L > const &lhs, R rhs)
 
template<allowed_type_c L, real_number_c R>
std::strong_ordering operator<=> (rational< L > const &lhs, R rhs)
 
template<allowed_type_c L, allowed_type_c R>
requires ( !std::same_as<L, R>)
bool operator== (rational< L > const &lhs, rational< R > const &rhs)
 
template<allowed_type_c L, allowed_type_c R>
requires ( !std::same_as<L, R>)
bool operator== (rational< L > const &lhs, R rhs)
 
template<allowed_type_c L, real_number_c R>
bool operator== (rational< L > const &lhs, R rhs)
 
auto factorial (unsigned long long n) noexcept
 
auto nPr (unsigned long long n, unsigned long long r=1) noexcept
 
auto nCr (unsigned long long n, unsigned long long r) noexcept
 

Variables

const std::vector< unsigned long long > factorial_table
 
const std::vector< std::vector< unsigned long long > > permutation_table
 
const std::vector< std::vector< unsigned long long > > combination_table
 

Typedef Documentation

◆ allowed_type_list

using cpg::rational_number::allowed_type_list = typedef types::type_container<char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long>

Definition at line 55 of file cpg_rational.hpp.

◆ numerical_type_list

using cpg::rational_number::numerical_type_list = typedef types::type_container<char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double>

Definition at line 65 of file cpg_rational.hpp.

◆ real_number_list

using cpg::rational_number::real_number_list = typedef types::type_container<float, double, long double>

Definition at line 48 of file cpg_rational.hpp.

Function Documentation

◆ factorial()

auto cpg::rational_number::factorial ( unsigned long long  n)
noexcept

Definition at line 909 of file cpg_rational.hpp.

◆ nCr()

auto cpg::rational_number::nCr ( unsigned long long  n,
unsigned long long  r 
)
noexcept

Definition at line 958 of file cpg_rational.hpp.

◆ nPr()

auto cpg::rational_number::nPr ( unsigned long long  n,
unsigned long long  r = 1 
)
noexcept

Definition at line 933 of file cpg_rational.hpp.

Here is the caller graph for this function:

◆ operator<=>() [1/3]

template<allowed_type_c L, allowed_type_c R>
requires ( !std::same_as<L, R>)
std::strong_ordering cpg::rational_number::operator<=> ( rational< L > const &  lhs,
rhs 
)

Definition at line 734 of file cpg_rational.hpp.

◆ operator<=>() [2/3]

template<allowed_type_c L, real_number_c R>
std::strong_ordering cpg::rational_number::operator<=> ( rational< L > const &  lhs,
rhs 
)

Definition at line 745 of file cpg_rational.hpp.

◆ operator<=>() [3/3]

template<allowed_type_c L, allowed_type_c R>
requires ( !std::same_as<L, R>)
std::strong_ordering cpg::rational_number::operator<=> ( rational< L > const &  lhs,
rational< R > const &  rhs 
)

Definition at line 722 of file cpg_rational.hpp.

◆ operator==() [1/3]

template<allowed_type_c L, allowed_type_c R>
requires ( !std::same_as<L, R>)
bool cpg::rational_number::operator== ( rational< L > const &  lhs,
rhs 
)

Definition at line 772 of file cpg_rational.hpp.

◆ operator==() [2/3]

template<allowed_type_c L, real_number_c R>
bool cpg::rational_number::operator== ( rational< L > const &  lhs,
rhs 
)

Definition at line 783 of file cpg_rational.hpp.

◆ operator==() [3/3]

template<allowed_type_c L, allowed_type_c R>
requires ( !std::same_as<L, R>)
bool cpg::rational_number::operator== ( rational< L > const &  lhs,
rational< R > const &  rhs 
)

Definition at line 760 of file cpg_rational.hpp.

◆ reduce_adjusted()

template<allowed_type_c ElementType>
constexpr ElementType cpg::rational_number::reduce_adjusted ( ElementType &  A,
ElementType &  B 
)
constexprnoexcept

Definition at line 77 of file cpg_rational.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reduce_simple()

template<allowed_type_c ElementType>
constexpr ElementType cpg::rational_number::reduce_simple ( ElementType &  A,
ElementType &  B 
)
constexprnoexcept

Definition at line 100 of file cpg_rational.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tell_comparable_as_double()

template<allowed_type_c T>
constexpr bool cpg::rational_number::tell_comparable_as_double ( )
constexpr

Definition at line 116 of file cpg_rational.hpp.

Variable Documentation

◆ combination_table

const std::vector<std::vector<unsigned long long> > cpg::rational_number::combination_table

Definition at line 793 of file permu_combi_table.cxx.

◆ factorial_table

const std::vector<unsigned long long> cpg::rational_number::factorial_table
Initial value:
{
1ull
,1ull
,2ull
,6ull
,24ull
,120ull
,720ull
,5040ull
,40320ull
,362880ull
,3628800ull
,39916800ull
,479001600ull
,6227020800ull
,87178291200ull
,1307674368000ull
,20922789888000ull
,355687428096000ull
,6402373705728000ull
,121645100408832000ull
,2432902008176640000ull
}

Definition at line 5 of file permu_combi_table.cxx.

◆ permutation_table

const std::vector<std::vector<unsigned long long> > cpg::rational_number::permutation_table

Definition at line 31 of file permu_combi_table.cxx.