VIGRA - Mathematical Functions

[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]

| Mathematical Functions |
--- | --- | ---

## Namespaces
namespace | vigra::detail
namespace | vigra::detail
namespace | vigra::detail
namespace | vigra::detail
namespace | vigra::detail
## Classes
class | BSpline
class | BSplineBase
class | CatmullRomSpline
class | CoscotFunction
class | Gaussian
## Functions
float | round (float t)
template<class T> NumericTraits< T >::Promote | sq (T t)
Int32 | sqrti (Int32 v)
UInt32 | sqrti (UInt32 v)
double | hypot (double a, double b)
template<class T> T | sign (T t)
template<class T1, class T2> T1 | sign (T1 t1, T2 t2)
NormTraits< T >::SquaredNormType | squaredNorm (T const &t)
template<class T> NormTraits< T >::NormType | norm (T const &t)
double | ellipticIntegralF (double x, double k)
double | ellipticIntegralE (double x, double k)
double | erf (double x)
double | chi2 (unsigned int degreesOfFreedom, double arg, double accuracy=1e-7)
double | chi2CDF (unsigned int degreesOfFreedom, double arg, double accuracy=1e-7)
double | noncentralChi2 (unsigned int degreesOfFreedom, double noncentrality, double arg, double accuracy=1e-7)
double | noncentralChi2CDF (unsigned int degreesOfFreedom, double noncentrality, double arg, double accuracy=1e-7)
double | noncentralChi2CDFApprox (unsigned int degreesOfFreedom, double noncentrality, double arg)
template<class T1, class T2> bool | closeAtTolerance (T1 l, T2 r, typename PromoteTraits< T1, T2 >::Promote epsilon)
template<typename IntType> IntType | gcd (IntType n, IntType m)
template<typename IntType> IntType | lcm (IntType n, IntType m)
result_type | operator() (argument_type x) const

## Detailed Description

Useful mathematical functions and functors.

## Define Documentation

#define VIGRA_DEFINE_NORM | ( | T |  | ) |

| Value:
    inline NormTraits<T>::SquaredNormType squaredNorm(T t) { return sq(t); } \
        inline NormTraits<T>::NormType norm(T t) { return abs(t); }

## Function Documentation

double chi2 | ( | unsigned int | degreesOfFreedom,
|  | double | arg,
|  | double | accuracy = 1e-7
| ) | `[inline]`

| Chi square distribution. Computes the density of a chi square distribution with degreesOfFreedom and tolerance accuracy at the given argument arg by calling `noncentralChi2(degreesOfFreedom, 0.0, arg, accuracy)`. #include "vigra/mathutil.hxx" Namespace: vigra

double chi2CDF | ( | unsigned int | degreesOfFreedom,
|  | double | arg,
|  | double | accuracy = 1e-7
| ) | `[inline]`

| Cumulative chi square distribution. Computes the cumulative density of a chi square distribution with degreesOfFreedom and tolerance accuracy at the given argument arg, i.e. the probability that a random number drawn from the distribution is below arg by calling `noncentralChi2CDF(degreesOfFreedom, 0.0, arg, accuracy)`. #include "vigra/mathutil.hxx" Namespace: vigra

bool closeAtTolerance | ( | T1 | l,
|  | T2 | r,
|  | typename PromoteTraits< T1, T2 >::Promote | epsilon
| ) |

| Tolerance based floating-point comparison. Check whether two floating point numbers are equal within the given tolerance. This is useful because floating point numbers that should be equal in theory are rarely exactly equal in practice. If the tolerance epsilon is not given, twice the machine epsilon is used. #include "vigra/mathutil.hxx" Namespace: vigra

double ellipticIntegralE | ( | double | x,
|  | double | k
| ) | `[inline]`

| The incomplete elliptic integral of the second kind. Computes according to the algorithm given in Press et al. "Numerical Recipes". The complete elliptic integral of the second kind is simply `ellipticIntegralE(M_PI/2, k)`. Note: In some libraries (e.g. Mathematica), the second parameter of the elliptic integral functions must be k^2 rather than k. Check the documentation when results disagree! #include "vigra/mathutil.hxx" Namespace: vigra

double ellipticIntegralF | ( | double | x,
|  | double | k
| ) | `[inline]`

| The incomplete elliptic integral of the first kind. Computes according to the algorithm given in Press et al. "Numerical Recipes". Note: In some libraries (e.g. Mathematica), the second parameter of the elliptic integral functions must be k^2 rather than k. Check the documentation when results disagree! #include "vigra/mathutil.hxx" Namespace: vigra

double erf | ( | double | x | ) | `[inline]`

| The error function. If `erf()` is not provided in the C standard math library (as it should according to the new C99 standard ?), VIGRA implements `erf()` as an approximation of the error function according to the formula given in Press et al. "Numerical Recipes". #include "vigra/mathutil.hxx" Namespace: vigra

IntType gcd | ( | IntType | n,
|  | IntType | m
| ) |

| Calculate the greatest common divisor. This function works for arbitrary integer types, including user-defined (e.g. infinite precision) ones. #include "vigra/rational.hxx" Namespace: vigra

double hypot | ( | double | a,
|  | double | b
| ) | `[inline]`

| Compute the Euclidean distance (length of the hypothenuse of a right-angled triangle). The hypot() function returns the sqrt(a*a + b*b). It is implemented in a way that minimizes round-off error. #include "vigra/mathutil.hxx" Namespace: vigra

IntType lcm | ( | IntType | n,
|  | IntType | m
| ) |

| Calculate the lowest common multiple. This function works for arbitrary integer types, including user-defined (e.g. infinite precision) ones. #include "vigra/rational.hxx" Namespace: vigra

double noncentralChi2 | ( | unsigned int | degreesOfFreedom,
|  | double | noncentrality,
|  | double | arg,
|  | double | accuracy = 1e-7
| ) | `[inline]`

| Non-central chi square distribution. Computes the density of a non-central chi square distribution with degreesOfFreedom, noncentrality parameter noncentrality and tolerance accuracy at the given argument arg. It uses Algorithm AS 231 from Appl. Statist. (1987) Vol.36, No.3 (code ported from http://lib.stat.cmu.edu/apstat/231). The algorithm has linear complexity in the number of degrees of freedom. #include "vigra/mathutil.hxx" Namespace: vigra

double noncentralChi2CDF | ( | unsigned int | degreesOfFreedom,
|  | double | noncentrality,
|  | double | arg,
|  | double | accuracy = 1e-7
| ) | `[inline]`

| Cumulative non-central chi square distribution. Computes the cumulative density of a chi square distribution with degreesOfFreedom, noncentrality parameter noncentrality and tolerance accuracy at the given argument arg, i.e. the probability that a random number drawn from the distribution is below arg It uses Algorithm AS 231 from Appl. Statist. (1987) Vol.36, No.3 (code ported from http://lib.stat.cmu.edu/apstat/231). The algorithm has linear complexity in the number of degrees of freedom (see noncentralChi2CDFApprox() for a constant-time algorithm). #include "vigra/mathutil.hxx" Namespace: vigra

double noncentralChi2CDFApprox | ( | unsigned int | degreesOfFreedom,
|  | double | noncentrality,
|  | double | arg
| ) | `[inline]`

| Cumulative non-central chi square distribution (approximate). Computes approximate values of the cumulative density of a chi square distribution with degreesOfFreedom, and noncentrality parameter noncentrality at the given argument arg, i.e. the probability that a random number drawn from the distribution is below arg It uses the approximate transform into a normal distribution due to Wilson and Hilferty (see Abramovitz, Stegun: "Handbook of Mathematical Functions", formula 26.3.32). The algorithm's running time is independent of the inputs, i.e. is should be used when noncentralChi2CDF() is too slow, and approximate values are sufficient. The accuracy is only about 0.1 for few degrees of freedom, but reaches about 0.001 above dof = 5. #include "vigra/mathutil.hxx" Namespace: vigra

NormTraits<T>::NormType norm | ( | T const & | t | ) | `[inline]`

| The norm of a numerical object. For scalar types: implemented as `abs(t)` otherwise: implemented as `sqrt(squaredNorm(t))`. #include "vigra/mathutil.hxx" Namespace: vigra

CatmullRomSpline< T >::result_type operator() | ( | argument_type | x | ) | const`[inherited]`

| function (functor) call

float round | ( | float | t | ) | `[inline]`

| The rounding function. Defined for all floating point types. Rounds towards the nearest integer such that `abs(round(t)) == round(abs(t))` for all `t`. #include "vigra/mathutil.hxx" Namespace: vigra

T1 sign | ( | T1 | t1,
|  | T2 | t2
| ) |

| The binary sign function. Transfers the sign of t2 to t1. #include "vigra/mathutil.hxx" Namespace: vigra

T sign | ( | T | t | ) |

| The sign function. Returns 1, 0, or -1 depending on the sign of t. #include "vigra/mathutil.hxx" Namespace: vigra

NumericTraits<T>::Promote sq | ( | T | t | ) | `[inline]`

| The square function. sq(x) is needed so often that it makes sense to define it as a function. #include "vigra/mathutil.hxx" Namespace: vigra

UInt32 sqrti | ( | UInt32 | v | ) | `[inline]`

| Unsigned integer square root. Useful for fast fixed-point computations. #include "vigra/mathutil.hxx" Namespace: vigra

Int32 sqrti | ( | Int32 | v | ) | `[inline]`

| Signed integer square root. Useful for fast fixed-point computations. #include "vigra/mathutil.hxx" Namespace: vigra

NormTraits<T>::SquaredNormType squaredNorm | ( | T const & | t | ) |

| The squared norm of a numerical object. For scalar types: equals `vigra::sq(t)` . For vectorial types: equals `vigra::dot(t, t)` . For complex types: equals `vigra::sq(t.real()) + vigra::sq(t.imag())` . For matrix types: results in the squared Frobenius norm (sum of squares of the matrix elements).

© Ullrich Köthe (koethe@informatik.uni-hamburg.de) Cognitive Systems Group, University of Hamburg, Germany | html generated using doxygen and Python VIGRA 1.5.0 (7 Dec 2006)