libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Modules | Namespaces | Classes | Typedefs | Enumerations | Functions
Maths
+ Collaboration diagram for Maths:

Modules

 Geometry
 
 Statistics
 

Namespaces

 crn::Combinatorics
 Combinatorics toolbox.
 
 crn::LinearSystem
 Solvers for systems of linear equations.
 
 crn::QuadraticEquation
 Solvers for quadratic equations.
 
 crn::FuzzyLogic
 Fuzzy logic toolbox.
 
 crn::literals
 
 crn::UnivariateRandomTools
 Univariate random toolbox class.
 

Classes

class  crn::DiscreteHMM
 Discrete HMM class. More...
 
class  crn::GaussianSCHMM
 Semi-continuous gaussian HMM class. More...
 
class  crn::Cartesian2DFunction
 Base class for 2D functions. More...
 
class  crn::CubicSpline
 Cubic spline interpolation. More...
 
class  crn::LinearInterpolation
 Linear interpolation. More...
 
class  crn::Matrix< T >
 Base matrix class. More...
 
class  crn::MatrixComplex
 Complex matrix class. More...
 
class  crn::MatrixDouble
 double matrix class More...
 
class  crn::MatrixInt
 Integer matrix class. More...
 
class  crn::MultivariateGaussianMixture
 Multivariate gaussian mixture. More...
 
class  crn::MultivariateGaussianPDF
 Multivariate Gaussian distribution. More...
 
class  crn::MultivariateRandomTools
 Multivariate random toolbox class. More...
 
class  crn::PolynomialRegression
 Polynomial regression. More...
 
class  crn::Prop3
 A ternary proposition. More...
 
class  crn::RealToRealFunction
 Numerical integration toolbox class. More...
 
class  crn::SquareMatrixDouble
 Square double matrix class. More...
 
struct  crn::Radian
 Radian angle unit. More...
 
struct  crn::Degree
 Degree angle unit. More...
 
struct  crn::ByteAngle
 BYTE angle unit. More...
 
struct  crn::Angle< Unit >
 A convenience class for angles units. More...
 
class  crn::UnivariateGaussianMixture
 Univariate Gaussian mixture. More...
 
class  crn::UnivariateGaussianPDF
 Univariate Gaussian distribution. More...
 

Typedefs

template<class ANGLE >
using crn::Unit = typename ANGLE::unit
 

Enumerations

enum  crn::Direction {
  crn::Direction::INVALID = 0, crn::Direction::LEFT = 1, crn::Direction::RIGHT = 2, crn::Direction::TOP = 4,
  crn::Direction::BOTTOM = 8
}
 An enumeration of directions. More...
 
enum  crn::Orientation { crn::Orientation::INVALID = 0, crn::Orientation::HORIZONTAL, crn::Orientation::VERTICAL }
 An enumeration of orientations. More...
 
enum  crn::DistanceType { crn::DistanceType::INVALID = 0, crn::DistanceType::D4, crn::DistanceType::D8, crn::DistanceType::EUCLIDEAN }
 An enumeration of distances. More...
 

Functions

template<typename T >
const T & crn::Max (const T &a, const T &b)
 Returns the max of two values. More...
 
template<typename T >
const T & crn::Min (const T &a, const T &b)
 Returns the min of two values. More...
 
template<typename T >
const T & crn::Max (const T &a, const T &b, const T &c)
 Returns the max of three values. More...
 
template<typename T >
const T & crn::Min (const T &a, const T &b, const T &c)
 Returns the min of three values. More...
 
template<typename T >
constexpr TypeInfo< T >::SumType crn::Twice (const T &v) noexcept(noexcept(v+v))
 Returns the double of a value. More...
 
template<typename T >
constexpr TypeInfo< T >::SumType crn::Thrice (const T &v) noexcept(noexcept(v+v))
 Returns three times a value. More...
 
template<typename T >
constexpr int crn::SignOf (const T &x) noexcept(noexcept(x< 0))
 Returns the sign (-1 or 1) of a value. More...
 
template<typename T >
constexpr SumType< T > crn::Sqr (const T &v) noexcept(noexcept(v *v))
 Returns the square of a value. More...
 
template<typename T >
constexpr T crn::Abs (const T &v) noexcept(noexcept(v< 0)&&noexcept(-v))
 Returns the absolute value of a value. More...
 
template<typename T >
crn::Abs (const std::complex< T > &v) noexcept(noexcept(std::abs(std::complex< T >(0))))
 Returns the absolute value of a value. More...
 
template<typename T >
crn::AbsMax (const T &a, const T &b) noexcept(noexcept(Abs(a)))
 Returns the value that has the maximal absolute value. More...
 
template<typename T >
crn::AbsMin (const T &a, const T &b) noexcept(noexcept(Abs(a)))
 Returns the value that has the minimal absolute value. More...
 
template<typename T >
crn::AbsMaxSameSign (const T &a, const T &b) noexcept(noexcept(Abs(a))&&noexcept(SignOf(a)))
 Returns the value that has the maximal absolute value if the values have the same sign. More...
 
template<typename T >
crn::AbsMinSameSign (const T &a, const T &b) noexcept(noexcept(Abs(a))&&noexcept(SignOf(a)))
 Returns the value that has the minimal absolute value if the values have the same sign. More...
 
template<typename T >
const T & crn::Cap (const T &v, const T &min, const T &max)
 Bounds a value to an interval. More...
 
double crn::Gauss (double x, double sigma)
 Computes Gauss function at x for a given standard deviation (centered in 0) More...
 
double crn::MeanGauss (double x, double sigma)
 Computes Gauss function at x for a given standard deviation (centered in 0) – to use with matrices. More...
 
double crn::Pythagoras (double a, double b) noexcept
 Computes sqrt(a²+b²) without destructive underflow or overflow. More...
 
double crn::Pythagoras (int a, int b) noexcept
 Computes sqrt(a²+b²) without destructive underflow or overflow. More...
 
double crn::Pythagoras (double a, double b, double c) noexcept
 Computes sqrt(a²+b²+c²) More...
 
template<class ITER >
double crn::Pythagoras (ITER it_begin, ITER it_end)
 Computes euclidean norm. More...
 
template<class ITER >
void crn::Scale (ITER it_begin, ITER it_end, const double s)
 Scale a collection of numbers. More...
 
template<typename Unit >
Direction crn::ToDirection (const Angle< Unit > &ang) noexcept
 
Orientation crn::ToOrientation (Direction d) noexcept
 
template<typename T , typename std::enable_if< std::is_arithmetic< T >::value, int >::type = 0>
double crn::Distance (T o1, T o2)
 Distance between two numbers. More...
 
template<typename Unit >
double crn::Cosine (typename Unit::type angle) noexcept
 Cosine of an angle. More...
 
template<typename Unit >
double crn::Sine (typename Unit::type angle) noexcept
 Sine of an angle. More...
 
template<typename Unit >
double crn::Tangent (typename Unit::type angle) noexcept
 Tangent of an angle. More...
 
template<>
double crn::Cosine< ByteAngle > (uint8_t angle) noexcept
 Cosine of a byte angle using a lookup table. More...
 
template<>
double crn::Sine< ByteAngle > (uint8_t angle) noexcept
 Sine of a byte angle using a lookup table. More...
 
template<>
double crn::Tangent< ByteAngle > (uint8_t angle) noexcept
 Tangent of a byte angle using a lookup table. More...
 
template<typename Unit >
Angle< Unit > crn::operator+ (const Angle< Unit > &a1, const Angle< Unit > &a2) noexcept(std::is_nothrow_constructible< typename Unit::type >::value &&std::is_nothrow_copy_assignable< typename Unit::type >::value)
 Adds two angles. More...
 
template<typename Unit >
Angle< Unit > crn::operator- (const Angle< Unit > &a1, const Angle< Unit > &a2) noexcept(std::is_nothrow_constructible< typename Unit::type >::value &&std::is_nothrow_copy_assignable< typename Unit::type >::value)
 Subtracts two angles. More...
 
template<typename Unit >
Angle< Unit > crn::operator* (double f, const Angle< Unit > &a) noexcept(std::is_nothrow_constructible< typename Unit::type >::value &&std::is_nothrow_copy_assignable< typename Unit::type >::value)
 Multiplies an scalar with an angle. More...
 
template<class A >
double crn::Cos (const A &a) noexcept
 
double crn::Cos (double a) noexcept
 
double crn::Cos (uint8_t a) noexcept
 
template<class A >
double crn::Sin (const A &a) noexcept
 
double crn::Sin (double a) noexcept
 
double crn::Sin (uint8_t a) noexcept
 
template<class A >
double crn::Tan (const A &a) noexcept
 
double crn::Tan (double a) noexcept
 
double crn::Tan (uint8_t a) noexcept
 
template<class A >
crn::Atan (double s, double c) noexcept
 
template<>
double crn::Atan< double > (double s, double c) noexcept
 
template<typename Unit >
Unit::type crn::AngularDistance (const Angle< Unit > &a1, const Angle< Unit > &a2) noexcept(std::is_nothrow_constructible< typename TypeInfo< typename Unit::type >::DiffType >::value &&std::is_nothrow_copy_assignable< typename TypeInfo< typename Unit::type >::DiffType >::value &&std::is_nothrow_constructible< typename Unit::type >::value)
 Distance between two angles. More...
 
double crn::AngularDistance (double a1, double a2) noexcept
 Distance between two angles. More...
 
template<typename ITER >
std::iterator_traits< ITER >
::value_type 
crn::AngularMean (ITER beg, ITER en)
 Mean of a set of angles. More...
 
template<typename ITER >
ITER crn::AngularMedian (ITER beg, ITER en)
 Mean of a set of angles. More...
 
template<typename ITER >
double crn::AngularVariance (ITER beg, ITER en)
 Variance of a set of angles. More...
 
template<typename ITER >
double crn::AngularVariance (ITER beg, ITER en, typename std::iterator_traits< ITER >::value_type mean)
 Variance of a set of angles. More...
 
template<typename ITER >
double crn::CircularVariance (ITER beg, ITER en)
 Circular (pseudo) variance of a set of angles. More...
 
template<typename ITER >
double crn::CircularStdDev (ITER beg, ITER en)
 Circular (pseudo) standard deviation of a set of angles. More...
 
template<typename ITER >
std::complex< double > crn::TrigonometricMoment (ITER beg, ITER en, typename std::iterator_traits< ITER >::value_type refer, size_t p)
 Trigonometric moment. More...
 
template<typename ITER >
double crn::AngularSkewness (ITER beg, ITER en)
 Skewness of a set of angles. More...
 
template<typename ITER >
double crn::AngularKurtosis (ITER beg, ITER en)
 Kurtosis of a set of angles. More...
 
void crn::FFT (std::vector< std::complex< double > > &sig, bool direct)
 Fast Fourier transform. More...
 

Detailed Description

Typedef Documentation

template<class ANGLE >
using crn::Unit = typedef typename ANGLE::unit

Definition at line 259 of file CRNTrigonometry.h.

Enumeration Type Documentation

enum crn::Direction
strong

An enumeration of directions.

An enumeration of directions

Enumerator
INVALID 
LEFT 
RIGHT 
TOP 
BOTTOM 

Definition at line 122 of file CRNMath.h.

enum crn::DistanceType
strong

An enumeration of distances.

An enumeration of distances

Enumerator
INVALID 
D4 
D8 
EUCLIDEAN 

Definition at line 159 of file CRNMath.h.

enum crn::Orientation
strong

An enumeration of orientations.

An enumeration of orientations

Enumerator
INVALID 
HORIZONTAL 
VERTICAL 

Definition at line 152 of file CRNMath.h.

Function Documentation

template<typename T >
constexpr T crn::Abs ( const T &  v)
noexcept

Returns the absolute value of a value.

Definition at line 63 of file CRNMath.h.

template<typename T >
T crn::Abs ( const std::complex< T > &  v)
inlinenoexcept

Returns the absolute value of a value.

Definition at line 65 of file CRNMath.h.

template<typename T >
T crn::AbsMax ( const T &  a,
const T &  b 
)
inlinenoexcept

Returns the value that has the maximal absolute value.

Definition at line 67 of file CRNMath.h.

template<typename T >
T crn::AbsMaxSameSign ( const T &  a,
const T &  b 
)
inlinenoexcept

Returns the value that has the maximal absolute value if the values have the same sign.

Definition at line 71 of file CRNMath.h.

template<typename T >
T crn::AbsMin ( const T &  a,
const T &  b 
)
inlinenoexcept

Returns the value that has the minimal absolute value.

Definition at line 69 of file CRNMath.h.

template<typename T >
T crn::AbsMinSameSign ( const T &  a,
const T &  b 
)
inlinenoexcept

Returns the value that has the minimal absolute value if the values have the same sign.

Definition at line 73 of file CRNMath.h.

template<typename Unit >
Unit::type crn::AngularDistance ( const Angle< Unit > &  a1,
const Angle< Unit > &  a2 
)
inlinenoexcept

Distance between two angles.

Distance between two angles

Usage example: AngularDistance<ByteAngle>(35, Angle<ByteAngle>::TOP())

Parameters
[in]a1first angle
[in]a2second angle

Definition at line 341 of file CRNTrigonometry.h.

double crn::AngularDistance ( double  a1,
double  a2 
)
inlinenoexcept

Distance between two angles.

Distance between two angles

Parameters
[in]a1first angle
[in]a2second angle

Definition at line 359 of file CRNTrigonometry.h.

template<typename ITER >
double crn::AngularKurtosis ( ITER  beg,
ITER  en 
)

Kurtosis of a set of angles.

Exceptions
ExceptionDomainempty set of angles
Parameters
[in]begiterator on the first angle
[in]eniterator after the last angle
Returns
the kurtosis of the set

Definition at line 530 of file CRNTrigonometry.h.

template<typename ITER >
std::iterator_traits<ITER>::value_type crn::AngularMean ( ITER  beg,
ITER  en 
)

Mean of a set of angles.

Exceptions
ExceptionDomainempty set of angles
Parameters
[in]begiterator on the first angle
[in]eniterator after the last angle
Returns
the mean angle

Definition at line 371 of file CRNTrigonometry.h.

template<typename ITER >
ITER crn::AngularMedian ( ITER  beg,
ITER  en 
)

Mean of a set of angles.

Exceptions
ExceptionDomainempty set of angles
Parameters
[in]begiterator on the first angle
[in]eniterator after the last angle
Returns
an iterator to the median angle

Definition at line 391 of file CRNTrigonometry.h.

template<typename ITER >
double crn::AngularSkewness ( ITER  beg,
ITER  en 
)

Skewness of a set of angles.

Exceptions
ExceptionDomainempty set of angles
Parameters
[in]begiterator on the first angle
[in]eniterator after the last angle
Returns
the skewness of the set

Definition at line 514 of file CRNTrigonometry.h.

template<typename ITER >
double crn::AngularVariance ( ITER  beg,
ITER  en 
)

Variance of a set of angles.

Exceptions
ExceptionDomainempty set of angles
Parameters
[in]begiterator on the first angle
[in]eniterator after the last angle
Returns
the biased variance

Definition at line 416 of file CRNTrigonometry.h.

template<typename ITER >
double crn::AngularVariance ( ITER  beg,
ITER  en,
typename std::iterator_traits< ITER >::value_type  mean 
)

Variance of a set of angles.

Exceptions
ExceptionDomainempty set of angles
Parameters
[in]begiterator on the first angle
[in]eniterator after the last angle
[in]meanthe mean of the set of angles
Returns
the biased variance

Definition at line 437 of file CRNTrigonometry.h.

template<class A >
A crn::Atan ( double  s,
double  c 
)
inlinenoexcept
Returns
the arctangent of a pair or sine/cosine

Definition at line 328 of file CRNTrigonometry.h.

template<>
double crn::Atan< double > ( double  s,
double  c 
)
inlinenoexcept
Returns
the arctangent of a pair or sine/cosine

Definition at line 330 of file CRNTrigonometry.h.

template<typename T >
const T& crn::Cap ( const T &  v,
const T &  min,
const T &  max 
)
inline

Bounds a value to an interval.

Definition at line 75 of file CRNMath.h.

template<typename ITER >
double crn::CircularStdDev ( ITER  beg,
ITER  en 
)

Circular (pseudo) standard deviation of a set of angles.

Exceptions
ExceptionDomainempty set of angles
Parameters
[in]begiterator on the first angle
[in]eniterator after the last angle
Returns
the "circular standard deviation"

Definition at line 476 of file CRNTrigonometry.h.

template<typename ITER >
double crn::CircularVariance ( ITER  beg,
ITER  en 
)

Circular (pseudo) variance of a set of angles.

Exceptions
ExceptionDomainempty set of angles
Parameters
[in]begiterator on the first angle
[in]eniterator after the last angle
Returns
the "circular variance"

Definition at line 456 of file CRNTrigonometry.h.

template<class A >
double crn::Cos ( const A &  a)
inlinenoexcept
Returns
the cosine of the angle

Definition at line 310 of file CRNTrigonometry.h.

double crn::Cos ( double  a)
inlinenoexcept
Returns
the cosine of the angle

Definition at line 312 of file CRNTrigonometry.h.

double crn::Cos ( uint8_t  a)
inlinenoexcept
Returns
the cosine of the angle

Definition at line 314 of file CRNTrigonometry.h.

template<typename Unit >
double crn::Cosine ( typename Unit::type  angle)
inlinenoexcept

Cosine of an angle.

Parameters
[in]anglethe angle in the unit given in template
Returns
the cosine of the angle

Definition at line 61 of file CRNTrigonometry.h.

template<>
double crn::Cosine< ByteAngle > ( uint8_t  angle)
inlinenoexcept

Cosine of a byte angle using a lookup table.

Parameters
[in]anglethe angle in [0..255]
Returns
the cosine of the angle

Definition at line 88 of file CRNTrigonometry.h.

template<typename T , typename std::enable_if< std::is_arithmetic< T >::value, int >::type = 0>
double crn::Distance ( o1,
o2 
)

Distance between two numbers.

Definition at line 166 of file CRNMath.h.

void crn::FFT ( std::vector< std::complex< double > > &  sig,
bool  direct 
)

Fast Fourier transform.

Fast Fourier transform

Date
April 2013
Version
0.1
Exceptions
ExceptionDimensionsignal does not have a power of 2 size
Parameters
[in]sigthe signal to process
[in]directdirect=true, inverse=false

Definition at line 98 of file CRNMatrixComplex.cpp.

double crn::Gauss ( double  x,
double  sigma 
)
inline

Computes Gauss function at x for a given standard deviation (centered in 0)

Definition at line 78 of file CRNMath.h.

template<typename T >
const T& crn::Max ( const T &  a,
const T &  b 
)
inline

Returns the max of two values.

Definition at line 47 of file CRNMath.h.

template<typename T >
const T& crn::Max ( const T &  a,
const T &  b,
const T &  c 
)
inline

Returns the max of three values.

Definition at line 51 of file CRNMath.h.

double crn::MeanGauss ( double  x,
double  sigma 
)
inline

Computes Gauss function at x for a given standard deviation (centered in 0) – to use with matrices.

Definition at line 81 of file CRNMath.h.

template<typename T >
const T& crn::Min ( const T &  a,
const T &  b 
)
inline

Returns the min of two values.

Definition at line 49 of file CRNMath.h.

template<typename T >
const T& crn::Min ( const T &  a,
const T &  b,
const T &  c 
)
inline

Returns the min of three values.

Definition at line 53 of file CRNMath.h.

template<typename Unit >
Angle<Unit> crn::operator* ( double  f,
const Angle< Unit > &  a 
)
inlinenoexcept

Multiplies an scalar with an angle.

Definition at line 284 of file CRNTrigonometry.h.

template<typename Unit >
Angle<Unit> crn::operator+ ( const Angle< Unit > &  a1,
const Angle< Unit > &  a2 
)
inlinenoexcept

Adds two angles.

Definition at line 262 of file CRNTrigonometry.h.

template<typename Unit >
Angle<Unit> crn::operator- ( const Angle< Unit > &  a1,
const Angle< Unit > &  a2 
)
inlinenoexcept

Subtracts two angles.

Definition at line 273 of file CRNTrigonometry.h.

double crn::Pythagoras ( double  a,
double  b 
)
inlinenoexcept

Computes sqrt(a²+b²) without destructive underflow or overflow.

Definition at line 84 of file CRNMath.h.

double crn::Pythagoras ( int  a,
int  b 
)
inlinenoexcept

Computes sqrt(a²+b²) without destructive underflow or overflow.

Definition at line 86 of file CRNMath.h.

double crn::Pythagoras ( double  a,
double  b,
double  c 
)
inlinenoexcept

Computes sqrt(a²+b²+c²)

Definition at line 89 of file CRNMath.h.

template<class ITER >
double crn::Pythagoras ( ITER  it_begin,
ITER  it_end 
)
inline

Computes euclidean norm.

Definition at line 92 of file CRNMath.h.

template<class ITER >
void crn::Scale ( ITER  it_begin,
ITER  it_end,
const double  s 
)
inline

Scale a collection of numbers.

Definition at line 103 of file CRNMath.h.

template<typename T >
constexpr int crn::SignOf ( const T &  x)
noexcept

Returns the sign (-1 or 1) of a value.

Definition at line 59 of file CRNMath.h.

template<class A >
double crn::Sin ( const A &  a)
inlinenoexcept
Returns
the sine of the angle

Definition at line 316 of file CRNTrigonometry.h.

double crn::Sin ( double  a)
inlinenoexcept
Returns
the sine of the angle

Definition at line 318 of file CRNTrigonometry.h.

double crn::Sin ( uint8_t  a)
inlinenoexcept
Returns
the sine of the angle

Definition at line 320 of file CRNTrigonometry.h.

template<typename Unit >
double crn::Sine ( typename Unit::type  angle)
inlinenoexcept

Sine of an angle.

Parameters
[in]anglethe angle in the unit given in template
Returns
the sine of the angle

Definition at line 70 of file CRNTrigonometry.h.

template<>
double crn::Sine< ByteAngle > ( uint8_t  angle)
inlinenoexcept

Sine of a byte angle using a lookup table.

Parameters
[in]anglethe angle in [0..255]
Returns
the sine of the angle

Definition at line 105 of file CRNTrigonometry.h.

template<typename T >
constexpr SumType<T> crn::Sqr ( const T &  v)
noexcept

Returns the square of a value.

Definition at line 61 of file CRNMath.h.

template<class A >
double crn::Tan ( const A &  a)
inlinenoexcept
Returns
the tangent of the angle

Definition at line 322 of file CRNTrigonometry.h.

double crn::Tan ( double  a)
inlinenoexcept
Returns
the tangent of the angle

Definition at line 324 of file CRNTrigonometry.h.

double crn::Tan ( uint8_t  a)
inlinenoexcept
Returns
the tangent of the angle

Definition at line 326 of file CRNTrigonometry.h.

template<typename Unit >
double crn::Tangent ( typename Unit::type  angle)
inlinenoexcept

Tangent of an angle.

Parameters
[in]anglethe angle in the unit given in template
Returns
the tangent of the angle

Definition at line 79 of file CRNTrigonometry.h.

template<>
double crn::Tangent< ByteAngle > ( uint8_t  angle)
inlinenoexcept

Tangent of a byte angle using a lookup table.

Parameters
[in]anglethe angle in [0..255]
Returns
the tangent of the angle

Definition at line 122 of file CRNTrigonometry.h.

template<typename T >
constexpr TypeInfo<T>::SumType crn::Thrice ( const T &  v)
noexcept

Returns three times a value.

Definition at line 57 of file CRNMath.h.

template<typename Unit >
Direction crn::ToDirection ( const Angle< Unit > &  ang)
noexcept

Definition at line 123 of file CRNMath.h.

Orientation crn::ToOrientation ( Direction  d)
noexcept

Constructor from direction

Parameters
[in]dthe direction to import. LEFT and RIGHT map to HORIZONTAL. TOP and BOTTOM map to VERTICAL. Others map to INVALID.

Definition at line 31 of file CRNMath.cpp.

template<typename ITER >
std::complex<double> crn::TrigonometricMoment ( ITER  beg,
ITER  en,
typename std::iterator_traits< ITER >::value_type  refer,
size_t  p 
)

Trigonometric moment.

Exceptions
ExceptionDomainempty set of angles
ExceptionInvalidArgumentnull order
Parameters
[in]begiterator on the first angle
[in]eniterator after the last angle
[in]referthe reference angle (typically, the mean angle)
[in]pthe order of the moment (>= 1)
Returns
the pth trigonometric moment

Definition at line 490 of file CRNTrigonometry.h.

template<typename T >
constexpr TypeInfo<T>::SumType crn::Twice ( const T &  v)
noexcept

Returns the double of a value.

Definition at line 55 of file CRNMath.h.