The blo Library
Loading...
Searching...
No Matches
Namespaces | Enumerations | Functions
math.h File Reference

Math functions. More...

#include "defs.h"
#include <cstdint>
#include <complex>
#include "math.inl"

Namespaces

namespace  blo
 The blo library.
 

Enumerations

enum  blo::Saturate { blo::SaturateFalse = 0 , blo::SaturateTrue = 1 }
 

Functions

template<typename T >
void blo::asin (const T &x, T &theta, T &d_theta_d_x)
 Calculates asin.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::asin (const double &x, double &theta, double &d_theta_d_x)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::asin (const float &x, float &theta, float &d_theta_d_x)
 
template<typename T >
void blo::acos (const T &x, T &theta, T &d_theta_d_x)
 Calculates acos.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::acos (const double &x, double &theta, double &d_theta_d_x)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::acos (const float &x, float &theta, float &d_theta_d_x)
 
template<typename T >
void blo::atan (const T &x, T &theta, T &d_theta_d_x)
 Calculates atan.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::atan (const double &x, double &theta, double &d_theta_d_x)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::atan (const float &x, float &theta, float &d_theta_d_x)
 
template<typename T >
void blo::atan2 (const T &y, const T &x, T &theta, T &d_theta_d_y, T &d_theta_d_x)
 Calculates atan2.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::atan2 (const double &y, const double &x, double &theta, double &d_theta_d_y, double &d_theta_d_x)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::atan2 (const float &y, const float &x, float &theta, float &d_theta_d_y, float &d_theta_d_x)
 
template<typename T >
const T blo::sinc (const T &x)
 Calculates sinc.
 
BLO_EXPIMP_TEMPLATE template BLO_API const double blo::sinc (const double &x)
 
BLO_EXPIMP_TEMPLATE template BLO_API const float blo::sinc (const float &x)
 
template<typename T >
void blo::sinc (const T &x, T &y, T &d_y_d_x)
 Calculates sinc.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::sinc (const double &x, double &y, double &d_y_d_x)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::sinc (const float &x, float &y, float &d_y_d_x)
 
double blo::fix (double x)
 Rounds toward zero.
 
float blo::fix (float x)
 Rounds toward zero.
 
double blo::round (double x)
 Rounds to the nearest integer.
 
float blo::round (float x)
 Rounds to the nearest integer.
 
template<typename T , typename U >
const T blo::roundConvert (const U &x, Saturate saturate=SaturateFalse)
 Rounds to the nearest integer and convert data type.
 
template<typename T >
const T blo::gcd (const T &a, const T &b)
 Calculates the greatest common divisor of two integers.
 
BLO_EXPIMP_TEMPLATE template BLO_API const int8_t blo::gcd (const int8_t &a, const int8_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int16_t blo::gcd (const int16_t &a, const int16_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int32_t blo::gcd (const int32_t &a, const int32_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int64_t blo::gcd (const int64_t &a, const int64_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint8_t blo::gcd (const uint8_t &a, const uint8_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint16_t blo::gcd (const uint16_t &a, const uint16_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint32_t blo::gcd (const uint32_t &a, const uint32_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint64_t blo::gcd (const uint64_t &a, const uint64_t &b)
 
template<typename T >
const T blo::gcd (const T *pSrc, int count)
 Calculates the greatest common divisor of a set of integers.
 
BLO_EXPIMP_TEMPLATE template BLO_API const int8_t blo::gcd (const int8_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int16_t blo::gcd (const int16_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int32_t blo::gcd (const int32_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int64_t blo::gcd (const int64_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint8_t blo::gcd (const uint8_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint16_t blo::gcd (const uint16_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint32_t blo::gcd (const uint32_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint64_t blo::gcd (const uint64_t *pSrc, int count)
 
template<typename T >
const T blo::lcm (const T &a, const T &b)
 Calculates the least common multiple of two integers.
 
BLO_EXPIMP_TEMPLATE template BLO_API const int8_t blo::lcm (const int8_t &a, const int8_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int16_t blo::lcm (const int16_t &a, const int16_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int32_t blo::lcm (const int32_t &a, const int32_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int64_t blo::lcm (const int64_t &a, const int64_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint8_t blo::lcm (const uint8_t &a, const uint8_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint16_t blo::lcm (const uint16_t &a, const uint16_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint32_t blo::lcm (const uint32_t &a, const uint32_t &b)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint64_t blo::lcm (const uint64_t &a, const uint64_t &b)
 
template<typename T >
const T blo::lcm (const T *pSrc, int count)
 Calculates the least common multiple of a set of integers.
 
BLO_EXPIMP_TEMPLATE template BLO_API const int8_t blo::lcm (const int8_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int16_t blo::lcm (const int16_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int32_t blo::lcm (const int32_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const int64_t blo::lcm (const int64_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint8_t blo::lcm (const uint8_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint16_t blo::lcm (const uint16_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint32_t blo::lcm (const uint32_t *pSrc, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API const uint64_t blo::lcm (const uint64_t *pSrc, int count)
 
template<typename T >
constexpr T blo::pi ()
 The constant pi.
 
template<typename T >
void blo::fitPoly (const T *pSrc_x, const T *pSrc_y, int count, T *pDst, int dstLen)
 Fits a polynomial to data.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::fitPoly (const double *pSrc_x, const double *pSrc_y, int count, double *pDst, int dstLen)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::fitPoly (const float *pSrc_x, const float *pSrc_y, int count, float *pDst, int dstLen)
 
template<typename T >
const T blo::evalPoly (const T *pSrcCoeffs, int lenCoeffs, const T &src)
 Evaluates a polynomial.
 
BLO_EXPIMP_TEMPLATE template BLO_API const double blo::evalPoly (const double *pSrcCoeffs, int lenCoeffs, const double &src)
 
BLO_EXPIMP_TEMPLATE template BLO_API const float blo::evalPoly (const float *pSrcCoeffs, int lenCoeffs, const float &src)
 
template<typename T >
void blo::evalPoly (const T *pSrcCoeffs, int lenCoeffs, const T *pSrc, T *pDst, int count)
 Evaluates a polynomial.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::evalPoly (const double *pSrcCoeffs, int lenCoeffs, const double *pSrc, double *pDst, int count)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::evalPoly (const float *pSrcCoeffs, int lenCoeffs, const float *pSrc, float *pDst, int count)
 
template<typename T >
void blo::polyDerivative (const T *pSrc, int srcLen, T *pDst)
 Calculates the derivative of a polynomial.
 
template<typename T >
void blo::polyIntegral (const T *pSrc, int srcLen, T *pDst, const T &C=0)
 Calculates the integral of a polynomial.
 
template<typename T >
void blo::rootsPoly (const T *pSrc, int srcLen, std::complex< T > *pDst, Balance balance=BalanceTrue)
 Calculates the roots of a polynomial.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::rootsPoly (const double *pSrc, int srcLen, std::complex< double > *pDst, Balance balance)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::rootsPoly (const float *pSrc, int srcLen, std::complex< float > *pDst, Balance balance)
 
template<typename T >
void blo::realRootsPoly (const T *pSrc, int srcLen, T *pDst, int &numRealRoots, Balance balance=BalanceTrue)
 Calculates the real roots of a polynomial.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::realRootsPoly (const double *pSrc, int srcLen, double *pDst, int &numRealRoots, Balance balance)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::realRootsPoly (const float *pSrc, int srcLen, float *pDst, int &numRealRoots, Balance balance)
 
template<typename T >
void blo::rootsQuadratic (const T *pSrc, std::complex< T > *pDst, int &numRoots)
 Calculates the roots of a quadratic polynomial.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::rootsQuadratic (const double *pSrc, std::complex< double > *pDst, int &numRoots)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::rootsQuadratic (const float *pSrc, std::complex< float > *pDst, int &numRoots)
 
template<typename T >
void blo::realRootsQuadratic (const T *pSrc, T *pDst, int &numRealRoots)
 Calculates the real roots of a quadratic polynomial.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::realRootsQuadratic (const double *pSrc, double *pDst, int &numRealRoots)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::realRootsQuadratic (const float *pSrc, float *pDst, int &numRealRoots)
 
template<typename T >
void blo::rootsCubic (const T *pSrc, std::complex< T > *pDst, int &numRoots)
 Calculates the roots of a cubic polynomial.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::rootsCubic (const double *pSrc, std::complex< double > *pDst, int &numRoots)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::rootsCubic (const float *pSrc, std::complex< float > *pDst, int &numRoots)
 
template<typename T >
void blo::realRootsCubic (const T *pSrc, T *pDst, int &numRealRoots)
 Calculates the real roots of a cubic polynomial.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::realRootsCubic (const double *pSrc, double *pDst, int &numRealRoots)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::realRootsCubic (const float *pSrc, float *pDst, int &numRealRoots)
 
template<typename T >
void blo::d_rootPoly_partial_coeffsPoly (const T &src_r, const T *pSrc_c, int lenCoeffs, T *pDst_d_r_partial_c, int dst_d_r_partial_cStride2)
 Partial derivative of the root of a polynomial with respect to its coefficients.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::d_rootPoly_partial_coeffsPoly (const double &src_r, const double *pSrc_c, int lenCoeffs, double *pDst_d_r_partial_c, int dst_d_r_partial_cStride2)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::d_rootPoly_partial_coeffsPoly (const float &src_r, const float *pSrc_c, int lenCoeffs, float *pDst_d_r_partial_c, int dst_d_r_partial_cStride2)
 
BLO_API unsigned int blo::nextPow2 (int n)
 Computes the next higher power of 2.
 
template<typename T >
void blo::rationalApprox (const T &x, T &num, T &den, const T &tolerance)
 Rational fraction approximation.
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::rationalApprox (const double &x, double &num, double &den, const double &tolerance)
 
BLO_EXPIMP_TEMPLATE template BLO_API void blo::rationalApprox (const float &x, float &num, float &den, const float &tolerance)
 
template<typename T >
void blo::rationalApprox (const T &x, T &num, T &den)
 Rational fraction approximation.
 
template<typename T >
const T blo::absDiff (const T &x, const T &y)
 Computes the absolute difference between two values.
 
uint8_t blo::absDiff (int8_t x, int8_t y)
 
uint16_t blo::absDiff (int16_t x, int16_t y)
 
uint32_t blo::absDiff (int32_t x, int32_t y)
 
uint64_t blo::absDiff (int64_t x, int64_t y)
 
template<typename T >
const std::enable_if_t< std::is_integral< T >::value, T > blo::mean (const T &x1, const T &x2)
 Computes the mean of two values.
 
template<typename T >
const std::enable_if_t<!std::is_integral< T >::value, T > blo::mean (const T &x1, const T &x2)
 

Detailed Description

Math functions.