eDSP  0.0.1
A cross-platform DSP library written in C++.
Classes | Enumerations | Functions
edsp::math Namespace Reference

Classes

struct  constants
 

Enumerations

enum  distances { manhattan, euclidean, logarithmic }
 

Functions

template<typename T >
constexpr T magnitude (const std::complex< T > &z)
 Computes the magnitude of the complex number z. More...
 
template<typename T >
constexpr T phase (const std::complex< T > &z)
 Computes the phase of the complex number z. More...
 
template<typename T >
constexpr T real (const std::complex< T > &z)
 Computes the real component of the complex number z. More...
 
template<typename T >
constexpr T imag (const std::complex< T > &z)
 Computes the imaginary component of the complex number z. More...
 
template<typename T >
constexpr std::complex< T > conj (const std::complex< T > &z)
 Computes the complex conjugate of the complex number z. More...
 
template<typename T >
constexpr auto is_nan (const std::complex< T > &z) noexcept
 Determines if the given real or imaginary part of the complex number is a not-a-number (NaN) value. More...
 
template<typename T >
constexpr auto is_inf (const std::complex< T > &z) noexcept
 Determines if the given real or imaginary part of the complex number is \( \infty \). More...
 
template<typename T >
constexpr std::complex< T > infinity () noexcept
 Computes an \( \infty \) complex number. More...
 
template<typename T >
constexpr bool is_negative (T x)
 Determines if the number is negative. More...
 
template<typename T >
constexpr bool is_odd (T x)
 Determines if the number is odd. More...
 
template<typename T >
constexpr bool is_even (T x)
 Determines if the number is even. More...
 
template<typename T >
constexpr bool is_power_two (T x)
 Determines if the number is power of two. More...
 
template<typename T >
constexpr bool is_denormal (T x)
 Determines if the number is denormal floating-point. More...
 
template<typename T >
constexpr bool is_normal (T x)
 Determines if the number is normal floating-point. More...
 
template<typename T >
constexpr bool is_zero (T x)
 Determines if the number is zero. More...
 
template<typename T >
constexpr bool is_nan (T x) noexcept
 Determines if the number is not-a-number (NAN). More...
 
template<typename T >
constexpr bool is_inf (T x)
 Determines if the number is \( \infty \). More...
 
template<typename T >
constexpr bool is_prime (T x)
 Determines if the number is prime. More...
 
template<typename T >
constexpr T sign (T x) noexcept
 Determines the sign of the input number. More...
 
template<typename T >
constexpr T next_power_two (T x)
 Computes the closest next higher power of 2 of the input number. More...
 
template<typename T >
constexpr T square (T x)
 Computes the square value of the input number. More...
 
template<typename T >
constexpr T fract (T x)
 Computes the fractional part of the input number. More...
 
template<typename T >
constexpr T inv (T x)
 Computes the inverse value of the input number. More...
 
template<typename T >
constexpr T half (T x)
 Computes the half value of the input number. More...
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, T >::type rand (T min, T max)
 Computes a random number in the range [min, max]. More...
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, T >::type rand ()
 Computes a random number. The generated numbers follow a uniform distribution. More...
 
template<typename T >
std::enable_if< std::is_integral< T >::value, T >::type rand (T min, T max)
 Computes a random number in the range [min, max]. More...
 
template<typename T >
std::enable_if< std::is_integral< T >::value, T >::type rand ()
 Computes a random number. The generated numbers follow a uniform distribution. More...
 
template<distances d, typename T >
constexpr T distance (T x, T y) noexcept
 Computes the distance between x and y. More...
 

Enumeration Type Documentation

◆ distances

Enumerator
manhattan 
euclidean 
logarithmic 

Function Documentation

◆ conj()

template<typename T >
constexpr std::complex<T> edsp::math::conj ( const std::complex< T > &  z)

Computes the complex conjugate of the complex number z.

Parameters
zComplex value
Returns
The complex conjugate of the complex number.

◆ distance()

template<distances d, typename T >
constexpr T edsp::math::distance ( x,
y 
)
noexcept

Computes the distance between x and y.

Parameters
xFirst element of the equation
ySecond element of the equation
Template Parameters
dDistance implementation to be used.
Returns
The computed distance
See also
distances

◆ fract()

template<typename T >
constexpr T edsp::math::fract ( x)

Computes the fractional part of the input number.

Parameters
xNumber to evaluate.
Returns
Fractional part of the input number.

◆ half()

template<typename T >
constexpr T edsp::math::half ( x)

Computes the half value of the input number.

Parameters
xNumber to evaluate.
Returns
Half value of the input number.

◆ imag()

template<typename T >
constexpr T edsp::math::imag ( const std::complex< T > &  z)

Computes the imaginary component of the complex number z.

Parameters
zComplex value
Returns
The imaginary component of the complex number.

◆ infinity()

template<typename T >
constexpr std::complex<T> edsp::math::infinity ( )
noexcept

Computes an \( \infty \) complex number.

Returns
An \( \infty \) complex number.

◆ inv()

template<typename T >
constexpr T edsp::math::inv ( x)

Computes the inverse value of the input number.

Parameters
xNumber to evaluate.
Returns
Inverse value of the input number.

◆ is_denormal()

template<typename T >
constexpr bool edsp::math::is_denormal ( x)

Determines if the number is denormal floating-point.

Parameters
xNumber to evaluate.
Returns
true if the number is denormal, false otherwise

◆ is_even()

template<typename T >
constexpr bool edsp::math::is_even ( x)

Determines if the number is even.

Parameters
xNumber to evaluate.
Returns
true if the number is even, false otherwise

◆ is_inf() [1/2]

template<typename T >
constexpr auto edsp::math::is_inf ( const std::complex< T > &  z)
noexcept

Determines if the given real or imaginary part of the complex number is \( \infty \).

Parameters
zComplex value
Returns
true if the number is a \( \infty \), false otherwise

◆ is_inf() [2/2]

template<typename T >
constexpr bool edsp::math::is_inf ( x)

Determines if the number is \( \infty \).

Parameters
xNumber to evaluate.
Returns
true if the number is \( \infty \), false otherwise

◆ is_nan() [1/2]

template<typename T >
constexpr auto edsp::math::is_nan ( const std::complex< T > &  z)
noexcept

Determines if the given real or imaginary part of the complex number is a not-a-number (NaN) value.

Parameters
zComplex value
Returns
true if the number is a NaN, false otherwise

◆ is_nan() [2/2]

template<typename T >
constexpr bool edsp::math::is_nan ( x)
noexcept

Determines if the number is not-a-number (NAN).

Parameters
xNumber to evaluate.
Returns
true if the number is NAN, false otherwise

◆ is_negative()

template<typename T >
constexpr bool edsp::math::is_negative ( x)

Determines if the number is negative.

Parameters
xNumber to evaluate.
Returns
true if the number is a negative number, false otherwise

◆ is_normal()

template<typename T >
constexpr bool edsp::math::is_normal ( x)

Determines if the number is normal floating-point.

Parameters
xNumber to evaluate.
Returns
true if the number is even, false otherwise

◆ is_odd()

template<typename T >
constexpr bool edsp::math::is_odd ( x)

Determines if the number is odd.

Parameters
xNumber to evaluate.
Returns
true if the number is odd, false otherwise

◆ is_power_two()

template<typename T >
constexpr bool edsp::math::is_power_two ( x)

Determines if the number is power of two.

Parameters
xNumber to evaluate.
Returns
true if the number is a power of two, false otherwise

◆ is_prime()

template<typename T >
constexpr bool edsp::math::is_prime ( x)

Determines if the number is prime.

Parameters
xNumber to evaluate.
Returns
true if the number is prime, false otherwise

◆ is_zero()

template<typename T >
constexpr bool edsp::math::is_zero ( x)

Determines if the number is zero.

Parameters
xNumber to evaluate.
Returns
true if the number is zero, false otherwise

◆ magnitude()

template<typename T >
constexpr T edsp::math::magnitude ( const std::complex< T > &  z)

Computes the magnitude of the complex number z.

Parameters
zComplex value
Returns
The magnitude of the complex number.

◆ next_power_two()

template<typename T >
constexpr T edsp::math::next_power_two ( x)

Computes the closest next higher power of 2 of the input number.

Parameters
xNumber to evaluate.
Returns
Closest next higher power of 2.

◆ phase()

template<typename T >
constexpr T edsp::math::phase ( const std::complex< T > &  z)

Computes the phase of the complex number z.

Parameters
zComplex value
Returns
The phase of the complex number.

◆ rand() [1/4]

template<typename T >
std::enable_if<std::is_floating_point<T>::value, T>::type edsp::math::rand ( min,
max 
)
inline

Computes a random number in the range [min, max].

The generated numbers follow a uniform distribution.

Parameters
minMinimum number
maxMaximum number
Returns
Random number in the range [min, max]

◆ rand() [2/4]

template<typename T >
std::enable_if<std::is_floating_point<T>::value, T>::type edsp::math::rand ( )
inline

Computes a random number. The generated numbers follow a uniform distribution.

Returns
Random number.

◆ rand() [3/4]

template<typename T >
std::enable_if<std::is_integral<T>::value, T>::type edsp::math::rand ( min,
max 
)
inline

Computes a random number in the range [min, max].

The generated numbers follow a uniform distribution.

Parameters
minMinimum number
maxMaximum number
Returns
Random number in the range [min, max]

◆ rand() [4/4]

template<typename T >
std::enable_if<std::is_integral<T>::value, T>::type edsp::math::rand ( )
inline

Computes a random number. The generated numbers follow a uniform distribution.

Returns
Random number.

◆ real()

template<typename T >
constexpr T edsp::math::real ( const std::complex< T > &  z)

Computes the real component of the complex number z.

Parameters
zComplex value
Returns
The real component of the complex number.

◆ sign()

template<typename T >
constexpr T edsp::math::sign ( x)
noexcept

Determines the sign of the input number.

Parameters
xNumber to evaluate.
Returns
Returns -1 if the number is negative, 1 otherwise

◆ square()

template<typename T >
constexpr T edsp::math::square ( x)

Computes the square value of the input number.

Parameters
xNumber to evaluate.
Returns
Square value of the input number.