- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Exponent::MathTools::CMathTools Class Reference

List of all members.

## Detailed Description

A few handy maths functions. Sppedy version of std c++ functions are prefixed fastXXX.

Date:
  14/11/2004

Author:
  Paul Chana

Version:
  1.0.0 Initial version

Deprecated:
  Soon to be replaced with a template version

Note:
  All contents of this source code are copyright 2005 Exp Digital Uk.
  This source file is covered by the licence conditions of the Infinity API. You should have recieved a copy
  with the source code. If you didnt, please refer to http://www.expdigital.co.uk All content is the Intellectual property of Exp Digital Uk.
  Certain sections of this code may come from other sources. They are credited where applicable.
  If you have comments, suggestions or bug reports please visit http://support.expdigital.co.uk

Id
  CMathTools.hpp,v 1.9 2007/02/08 21:06:44 paul Exp

Definition at line 52 of file CMathTools.hpp.

## Static Public Member Functions

- static __forceinline float clamp (const float min, const float max, const float x)
- static __forceinline double clamp (const double x)
- static __forceinline double clamp (const double min, const double max, const double x)
- static __forceinline float cube (const float x)
- static __forceinline double cube (const double x)
- static __forceinline double factorial (const double x)
- static __forceinline float fastAtan (const float x)
- static __forceinline double fastAtan (const double x)
- static __forceinline long fastDoubleToLong (double x)
- static __forceinline long fastDoubleToLongFloor (const double x)
- static __forceinline float fastMaximum (const float a, const float b)
- static __forceinline double fastMaximum (const double a, const double b)
- static __forceinline float fastMinimum (const float a, const float b)
- static __forceinline double fastMinimum (const double a, const double b)
- static __forceinline float fastModulus (const float x)
- static __forceinline double fastModulus (const double x)
- static __forceinline double iZero (const double y)
- static __forceinline long maximum (const long a, const long b)
- static __forceinline float maximum (const float a, const float b)
- static __forceinline double maximum (const double a, const double b)
- static __forceinline long minimum (const long a, const long b)
- static __forceinline float minimum (const float a, const float b)
- static __forceinline double minimum (const double a, const double b)
- static __forceinline float square (const float x)
- static __forceinline double square (const double x)
- static __forceinline double zeroethOrderBessel (const double x)

## Static Public Attributes

- static const double CMATH_2PI_DOUBLE
- static const float CMATH_2PI_FLOAT
- static const double CMATH_4PI_DOUBLE
- static const float CMATH_4PI_FLOAT
- static const double CMATH_HALF_PI_DOUBLE
- static const float CMATH_HALF_PI_FLOAT
- static const double CMATH_LN2_DOUBLE
- static const float CMATH_LN2_FLOAT
- static const double CMATH_LN2_INV_DOUBLE
- static const float CMATH_LN2_INV_FLOAT
- static const double CMATH_ONE_THIRD_DOUBLE
- static const float CMATH_ONE_THIRD_FLOAT
- static const double CMATH_PI_DOUBLE
- static const float CMATH_PI_FLOAT
- static const double CMATH_TWO_THIRDS_DOUBLE
- static const float CMATH_TWO_THIRDS_FLOAT

## Member Function Documentation

static __forceinline float Exponent::MathTools::CMathTools::clamp | ( | const float | min,
|  | const float | max,
|  | const float | x |
| ) |  |  | `[inline, static]`

Clamp to a range - By Duncan S Parsons

Parameters:

  | min | The minimum of the value
  | max | The maximum of the value
  | x | The value

Return values:

  | float | x in range min - max

Definition at line 281 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::clamp | ( | const double | x | ) | `[inline, static]`

Clamp to 0 - 1 - By Duncan S Parsons

Parameters:

  | x | The value

Return values:

  | float | x in range min - max

Definition at line 269 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::clamp | ( | const double | min,
|  | const double | max,
|  | const double | x |
| ) |  |  | `[inline, static]`

Clamp to 0 - 1 - By Duncan S Parsons

Parameters:

  | min | The minimum of the value
  | max | The maximum of the value
  | x | The value

Return values:

  | double | x in range min - max

Definition at line 259 of file CMathTools.hpp.

static __forceinline float Exponent::MathTools::CMathTools::cube | ( | const float | x | ) | `[inline, static]`

Cube a number

Parameters:

  | x | The number to square

Return values:

  | float | x*x*x

Definition at line 303 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::cube | ( | const double | x | ) | `[inline, static]`

Cube a number

Parameters:

  | x | The number to square

Return values:

  | double | x*x*x

Definition at line 293 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::factorial | ( | const double | x | ) | `[inline, static]`

Compute the factorial of a number

Parameters:

  | x | The value

Return values:

  | double | The factorial

Definition at line 429 of file CMathTools.hpp.

Referenced by zeroethOrderBessel().

static __forceinline float Exponent::MathTools::CMathTools::fastAtan | ( | const float | x | ) | `[inline, static]`

Fast atan - By antiprosynthesis

Note:
  Documented online at http://www.musicdsp.org/showone.php?id=104

Parameters:

  | x | The phase in radians

Return values:

  | float | atan(x)

Definition at line 245 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::fastAtan | ( | const double | x | ) | `[inline, static]`

Fast atan - By antiprosynthesis

Note:
  Documented online at http://www.musicdsp.org/showone.php?id=104

Parameters:

  | x | The phase in radians

Return values:

  | double | atan(x)

Definition at line 234 of file CMathTools.hpp.

static __forceinline long Exponent::MathTools::CMathTools::fastDoubleToLong | ( | double | x | ) | `[inline, static]`

Double to Long conversion

Note:
  Documented online at http://www.stereopsis.com/FPU.html#convert

Parameters:

  | x | The value to convert to a long

Return values:

  | long | (long)x;

Definition at line 338 of file CMathTools.hpp.

References IMAN.

static __forceinline long Exponent::MathTools::CMathTools::fastDoubleToLongFloor | ( | const double | x | ) | `[inline, static]`

Fast floor

Note:
  Original by Laurent De Soras with additions by Daniel Schaack

  Documented online at http://www.musicdsp.org/showone.php?id=170

Parameters:

  | x | The value to floor

Return values:

  | long | The floored value

Definition at line 359 of file CMathTools.hpp.

static __forceinline float Exponent::MathTools::CMathTools::fastMaximum | ( | const float | a,
|  | const float | b |
| ) |  |  | `[inline, static]`

Get the maximum no branching - By quintosardo

Parameters:

  | a | The A Value
  | b | The B Value

Return values:

  | float | max(a,b);

Definition at line 199 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::fastMaximum | ( | const double | a,
|  | const double | b |
| ) |  |  | `[inline, static]`

Get the maximum no branching - By quintosardo

Parameters:

  | a | The A Value
  | b | The B Value

Return values:

  | double | max(a,b);

Definition at line 188 of file CMathTools.hpp.

static __forceinline float Exponent::MathTools::CMathTools::fastMinimum | ( | const float | a,
|  | const float | b |
| ) |  |  | `[inline, static]`

Get the minimum of two values no branch - By quintosardo

Parameters:

  | a | The A Value
  | b | The B Value

Return values:

  | float | min(a,b);

Definition at line 142 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::fastMinimum | ( | const double | a,
|  | const double | b |
| ) |  |  | `[inline, static]`

Get the minimum of two values no branch - By quintosardo

Parameters:

  | a | The A Value
  | b | The B Value

Return values:

  | double | min(a,b);

Definition at line 131 of file CMathTools.hpp.

static __forceinline float Exponent::MathTools::CMathTools::fastModulus | ( | const float | x | ) | `[inline, static]`

Get the floating point component of a value

Parameters:

  | x | The value to get the floating point component from

Return values:

  | float | The floating point component

Definition at line 221 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::fastModulus | ( | const double | x | ) | `[inline, static]`

Get the floating point component of a value

Parameters:

  | x | The value to get the floating point component from

Return values:

  | double | The floating point component

Definition at line 211 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::iZero | ( | const double | y | ) | `[inline, static]`

Compute bessel function iZero using a series approximation

Parameters:

  | y | value to compute iZero for

Return values:

  | double | iZero

Note:
  Algorithm from C++ algorithms for DSP by Embree & Danielli

Definition at line 382 of file CMathTools.hpp.

static __forceinline long Exponent::MathTools::CMathTools::maximum | ( | const long | a,
|  | const long | b |
| ) |  |  | `[inline, static]`

Get the maximum of two values

Parameters:

  | a | The A Value
  | b | The B Value

Return values:

  | long | max(a,b);

Definition at line 177 of file CMathTools.hpp.

static __forceinline float Exponent::MathTools::CMathTools::maximum | ( | const float | a,
|  | const float | b |
| ) |  |  | `[inline, static]`

Get the maximum of two values

Parameters:

  | a | The A Value
  | b | The B Value

Return values:

  | float | max(a,b);

Definition at line 166 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::maximum | ( | const double | a,
|  | const double | b |
| ) |  |  | `[inline, static]`

Get the maximum of two values

Parameters:

  | a | The A Value
  | b | The B Value

Return values:

  | double | max(a,b);

Definition at line 155 of file CMathTools.hpp.

static __forceinline long Exponent::MathTools::CMathTools::minimum | ( | const long | a,
|  | const long | b |
| ) |  |  | `[inline, static]`

Get the minimum of two values

Parameters:

  | a | The A Value
  | b | The B Value

Return values:

  | long | min(a,b);

Definition at line 120 of file CMathTools.hpp.

static __forceinline float Exponent::MathTools::CMathTools::minimum | ( | const float | a,
|  | const float | b |
| ) |  |  | `[inline, static]`

Get the minimum of two values

Parameters:

  | a | The A Value
  | b | The B Value

Return values:

  | float | min(a,b);

Definition at line 109 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::minimum | ( | const double | a,
|  | const double | b |
| ) |  |  | `[inline, static]`

Get the minimum of two values

Parameters:

  | a | The A Value
  | b | The B Value

Return values:

  | double | min(a,b);

Definition at line 98 of file CMathTools.hpp.

static __forceinline float Exponent::MathTools::CMathTools::square | ( | const float | x | ) | `[inline, static]`

Square a number

Parameters:

  | x | The number to square

Return values:

  | float | x*x

Definition at line 325 of file CMathTools.hpp.

static __forceinline double Exponent::MathTools::CMathTools::square | ( | const double | x | ) | `[inline, static]`

Square a number

Parameters:

  | x | The number to square

Return values:

  | double | x*x

Definition at line 315 of file CMathTools.hpp.

Referenced by Exponent::MathTools::TRandomNumberGenerator< TypeName >::gaussian1().

static __forceinline double Exponent::MathTools::CMathTools::zeroethOrderBessel | ( | const double | x | ) | `[inline, static]`

Compute the zeroth order bessel

Parameters:

  | x | The input value

Return values:

  | double | The output zeroth order bessel

Note:
  based on the observations on wikipedia

Definition at line 402 of file CMathTools.hpp.

References factorial().

## Member Data Documentation

const double Exponent::MathTools::CMathTools::CMATH_2PI_DOUBLE`[static]`

pi * 2

Definition at line 67 of file CMathTools.hpp.

Referenced by Exponent::MathTools::TRandomNumberGenerator< TypeName >::gaussian3().

const float Exponent::MathTools::CMathTools::CMATH_2PI_FLOAT`[static]`

pi * 2

Definition at line 60 of file CMathTools.hpp.

const double Exponent::MathTools::CMathTools::CMATH_4PI_DOUBLE`[static]`

pi * 4

Definition at line 68 of file CMathTools.hpp.

const float Exponent::MathTools::CMathTools::CMATH_4PI_FLOAT`[static]`

pi * 4

Definition at line 61 of file CMathTools.hpp.

const double Exponent::MathTools::CMathTools::CMATH_HALF_PI_DOUBLE`[static]`

pi * 0.5

Definition at line 65 of file CMathTools.hpp.

const float Exponent::MathTools::CMathTools::CMATH_HALF_PI_FLOAT`[static]`

pi * 0.5

Definition at line 58 of file CMathTools.hpp.

const double Exponent::MathTools::CMathTools::CMATH_LN2_DOUBLE`[static]`

ln(2)

Definition at line 72 of file CMathTools.hpp.

const float Exponent::MathTools::CMathTools::CMATH_LN2_FLOAT`[static]`

ln(2)

Definition at line 77 of file CMathTools.hpp.

const double Exponent::MathTools::CMathTools::CMATH_LN2_INV_DOUBLE`[static]`

1/ln(2)

Definition at line 73 of file CMathTools.hpp.

const float Exponent::MathTools::CMathTools::CMATH_LN2_INV_FLOAT`[static]`

1/ln(2)

Definition at line 78 of file CMathTools.hpp.

const double Exponent::MathTools::CMathTools::CMATH_ONE_THIRD_DOUBLE`[static]`

1/3

Definition at line 82 of file CMathTools.hpp.

const float Exponent::MathTools::CMathTools::CMATH_ONE_THIRD_FLOAT`[static]`

1/3

Definition at line 87 of file CMathTools.hpp.

const double Exponent::MathTools::CMathTools::CMATH_PI_DOUBLE`[static]`

pi

Definition at line 66 of file CMathTools.hpp.

const float Exponent::MathTools::CMathTools::CMATH_PI_FLOAT`[static]`

pi

Definition at line 59 of file CMathTools.hpp.

const double Exponent::MathTools::CMathTools::CMATH_TWO_THIRDS_DOUBLE`[static]`

2/3

Definition at line 83 of file CMathTools.hpp.

const float Exponent::MathTools::CMathTools::CMATH_TWO_THIRDS_FLOAT`[static]`

2/3

Definition at line 88 of file CMathTools.hpp.