NTLib - Number Theory Library 0.9
Loading...
Searching...
No Matches
base Module Reference

Basic functionality used frequently throughout the whole library. More...

Concepts

concept  ntlib::HasAdditiveNeutral
 Restricts to types with an additive neutral element.
concept  ntlib::HasMultiplicativeNeutral
 Restricts to types with a multiplicative neutral element.
concept  ntlib::AdditiveSemigroup
 Restricts to types modeling an additive semigroup.
concept  ntlib::MultiplicativeSemigroup
 Restricts to types modeling a multiplication semigroup.
concept  ntlib::AdditiveMonoid
 Restricts to types modeling an additive monoid.
concept  ntlib::MultiplicativeMonoid
 Restricts to types modeling a multiplicative monoid.
concept  ntlib::HasAdditiveInverses
concept  ntlib::HasMultiplicativeInverses
 Restricts to types with multiplicative inverse elements.
concept  ntlib::AdditiveGroup
 Restricts to types modeling an additive group.
concept  ntlib::MultiplicativeGroup
 Restricts to types modeling a multiplicative group.
concept  ntlib::IsAdditiveCommutative
 Restricts to types with a commutative addition operation.
concept  ntlib::IsMultiplicativeCommutative
 Restricts to types with a commutative multiplication operation.
concept  ntlib::AdditiveCommutativeGroup
 Restricts to types modeling an additive commutative group.
concept  ntlib::MultiplicativeCommutativeGroup
 Restricts to types modeling a multiplicative commutative group.
concept  ntlib::Ring
 Restricts to types modeling a ring.
concept  ntlib::CommutativeRing
 Restricts to types modeling a commutative ring.
concept  ntlib::Field
 Restricts to types modeling a field.
concept  ntlib::HasDivisionWithRemainder
 Restricts to types supporting division with remainder.
concept  ntlib::Integer
 Restricts to types modeling the integers.

Classes

class  ntlib::algebra_traits< typename >
 Traits class for algebraic types. More...
class  ntlib::algebra_traits< T >
 Specialization of ntlib::algebra_traits for integral types. More...

Functions

template<Integer T>
constexpr bool ntlib::is_odd (T n) noexcept
 Checks whether a given number is odd.
template<Integer T>
constexpr bool ntlib::is_even (T n) noexcept
 Checks whether a given number is even.
template<AdditiveGroup T>
constexpr T ntlib::abs (T n) noexcept
 Computes the absolute value of a given number.
template<AdditiveGroup T>
constexpr T ntlib::difference (T a, T b) noexcept
 Computes the difference between two numbers.
template<std::totally_ordered T>
constexpr int ntlib::sgn (T n) noexcept
 Computes the sign of a given number.
template<Integer T>
constexpr std::pair< T, T > ntlib::odd_part (T n) noexcept
 Given a number n, computes a pair (e, o), such that n=2^e*o.
template<Integer T>
constexpr T ntlib::gcd (T a, T b) noexcept
 Computes the greatest common divisor of two numbers using the Euclidean algorithm.
template<Integer T>
constexpr T ntlib::gcd (std::initializer_list< T > list) noexcept
 Computes the greatest common divisor of a list of numbers.
template<Integer T>
constexpr T ntlib::lcm (T a, T b) noexcept
 Computes the least common multiple of two numbers.
template<Integer T>
constexpr T ntlib::lcm (std::initializer_list< T > list) noexcept
 Computes the least common multiple of a list of numbers.
template<Integer T>
constexpr std::tuple< T, T, T > ntlib::extended_euclid (T a, T b) noexcept
 Extended Euclidean algorithm.
template<MultiplicativeMonoid A, Integer B>
constexpr A ntlib::pow (A a, B b) noexcept
 Binary exponentation.
template<Integer T>
constexpr T ntlib::ilog2 (T n) noexcept
 Computes the integer part of the binary logarithm of a given number.
template<Integer T>
constexpr T ntlib::isqrt (T n) noexcept
 Computes the integer square root of a given number.
template<Integer T>
constexpr bool ntlib::is_square (T n) noexcept
 Tests, if a given number is a perfect square.
template<Integer T>
constexpr T ntlib::factorial (T n) noexcept
 Computes the factorial of a given number.
template<typename T>
constexpr T ntlib::zero () noexcept
 Returns the additive neutral element of a given type.
template<typename T>
constexpr T ntlib::one () noexcept
 Returns the multiplicative neutral element of a given type.

Variables

template<Integer T>
constexpr auto ntlib::SMALL_PRIMES
 A list with all prime numbers up to ntlib::SMALL_PRIMES_BIGGEST.
template<Integer T>
constexpr T ntlib::SMALL_PRIMES_BIGGEST
 Helper constant to get the biggest among the small primes in ntlib::SMALL_PRIMES.

Detailed Description

Basic functionality used frequently throughout the whole library.

Functionality contained in this module has no further dependencies and only depends on the C++ standard library.

Files

file  modules/base/base.cpp
 Primary module interface unit for module base.
file  modules/base/concepts.cpp
 Module interface unit for module base, partition concepts.