C++ Utilities  4.17.1
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Functions
MathUtilities Namespace Reference

Contains various mathematical functions. More...

Functions

CPP_UTILITIES_EXPORT int random (int lowerbounds, int upperbounds)
 Returns a pseudo random number between lowerbounds and upperbounds. More...
 
CPP_UTILITIES_EXPORT int digitsum (int number, int base)
 Returns the digitsum of the given number using the specified base. More...
 
CPP_UTILITIES_EXPORT int factorial (int number)
 Returns the factorial of the given number. More...
 
CPP_UTILITIES_EXPORT uint64 powerModulo (const uint64 base, const uint64 exponent, const uint64 module)
 Computes base power exponent modulo module. More...
 
CPP_UTILITIES_EXPORT int64 inverseModulo (int64 number, int64 module)
 Computes the inverse of number modulo module. More...
 
CPP_UTILITIES_EXPORT uint64 orderModulo (const uint64 number, const uint64 module)
 Computes the order of number modulo module. More...
 
template<typename T >
constexpr T min (T first, T second)
 Returns the smallest of the given items. More...
 
template<typename T1 , typename... T2>
constexpr T1 min (T1 first, T1 second, T2... remaining)
 Returns the smallest of the given items. More...
 
template<typename T >
constexpr T max (T first, T second)
 Returns the greatest of the given items. More...
 
template<typename T1 , typename... T2>
constexpr T1 max (T1 first, T1 second, T2... remaining)
 Returns the greatest of the given items. More...
 

Detailed Description

Contains various mathematical functions.

Todo:
Move math.h and math.cpp to misc in v5.

Function Documentation

◆ digitsum()

int MathUtilities::digitsum ( int  number,
int  base 
)

Returns the digitsum of the given number using the specified base.

Todo:
Make constexpr/template in v5.

Definition at line 28 of file math.cpp.

◆ factorial()

int MathUtilities::factorial ( int  number)

Returns the factorial of the given number.

Todo:
Make constexpr/template in v5.

Definition at line 42 of file math.cpp.

◆ inverseModulo()

int64 MathUtilities::inverseModulo ( int64  number,
int64  module 
)

Computes the inverse of number modulo module.

Todo:
Make constexpr/template in v5.

Definition at line 74 of file math.cpp.

◆ max() [1/2]

template<typename T >
constexpr T MathUtilities::max ( first,
second 
)

Returns the greatest of the given items.

Definition at line 29 of file math.h.

◆ max() [2/2]

template<typename T1 , typename... T2>
constexpr T1 MathUtilities::max ( T1  first,
T1  second,
T2...  remaining 
)

Returns the greatest of the given items.

Definition at line 35 of file math.h.

◆ min() [1/2]

template<typename T >
constexpr T MathUtilities::min ( first,
second 
)

Returns the smallest of the given items.

Definition at line 17 of file math.h.

◆ min() [2/2]

template<typename T1 , typename... T2>
constexpr T1 MathUtilities::min ( T1  first,
T1  second,
T2...  remaining 
)

Returns the smallest of the given items.

Definition at line 23 of file math.h.

◆ orderModulo()

uint64 MathUtilities::orderModulo ( const uint64  number,
const uint64  module 
)

Computes the order of number modulo module.

Todo:
Make constexpr/template in v5.

Definition at line 92 of file math.cpp.

◆ powerModulo()

uint64 MathUtilities::powerModulo ( const uint64  base,
const uint64  exponent,
const uint64  module 
)

Computes base power exponent modulo module.

Todo:
Make constexpr/template in v5.

Definition at line 55 of file math.cpp.

◆ random()

int MathUtilities::random ( int  lowerbounds,
int  upperbounds 
)

Returns a pseudo random number between lowerbounds and upperbounds.

Todo:
Remove in v5 since std::uniform_int_distribution does the same.

Definition at line 18 of file math.cpp.