gml_Math.h File Reference


Detailed Description

Overloaded and optimized math functions.

Probably no performance improvement will occur if inlining is disabled.

#include <math.h>
#include <assert.h>
#include <stdlib.h>
#include "gml/base/gml_Types.h"

Go to the source code of this file.


Classes

union  UInt64_union

Overloaded mathematical functions.

Standard C library mathematical functions, overloaded to accept any precision.

Float32 Cos (Float32 a)
Float64 Cos (Float64 a)
Float32 Acos (Float32 a)
Float64 Acos (Float64 a)
Float32 Sin (Float32 a)
Float64 Sin (Float64 a)
Float32 Asin (Float32 a)
Float64 Asin (Float64 a)
Float32 Tan (Float32 a)
Float64 Tan (Float64 a)
Float32 Atan (Float32 a)
Float64 Atan (Float64 a)
Float32 Atan2 (Float32 y, Float32 x)
Float64 Atan2 (Float64 y, Float64 x)
Float32 Hypot (Float32 y, Float32 x)
Float64 Hypot (Float64 y, Float64 x)
Float32 Exp (Float32 a)
Float64 Exp (Float64 a)
Float32 Exp2 (Float32 a)
Float64 Exp2 (Float64 a)
UInt8 Abs (SInt8 a)
UInt16 Abs (SInt16 a)
UInt32 Abs (SInt32 a)
UInt64 Abs (SInt64 a)
Float32 Abs (Float32 a)
Float64 Abs (Float64 a)
Float32 Sqrt (Float32 a)
Float64 Sqrt (Float64 a)
Float32 Cbrt (Float32 a)
Float64 Cbrt (Float64 a)
Float32 Log1p (Float32 a)
Float64 Log1p (Float64 a)
Float32 Log (Float32 a)
Float64 Log (Float64 a)
UInt8 Log2 (UInt32 a)
 Count the digits in a.

Not A Number functions

Generate and check NaNs.

void Nan (Float32 &a)
void Nan (Float64 &a)
int Isnan (Float32 a)
int Isnan (Float64 a)

Optimized selection functions

Select() is equivalent to: (a < b) ? alt1 : alt2 Whenever possible, Select() is implemented without branching.

UInt8 Select (UInt8 a, UInt8 b, UInt8 alt1, UInt8 alt2)
SInt8 Select (SInt8 a, SInt8 b, SInt8 alt1, SInt8 alt2)
UInt16 Select (UInt16 a, UInt16 b, UInt16 alt1, UInt16 alt2)
SInt16 Select (SInt16 a, SInt16 b, SInt16 alt1, SInt16 alt2)
UInt32 Select (UInt32 a, UInt32 b, UInt32 alt1, UInt32 alt2)
SInt32 Select (SInt32 a, SInt32 b, SInt32 alt1, SInt32 alt2)
UInt64 Select (UInt64 a, UInt64 b, UInt64 alt1, UInt64 alt2)
SInt64 Select (SInt64 a, SInt64 b, SInt64 alt1, SInt64 alt2)
Float32 Select (Float32 a, Float32 b, Float32 alt1, Float32 alt2)
Float64 Select (Float64 a, Float64 b, Float64 alt1, Float64 alt2)

Fast minimum, maximum, clamping and clipping functions

These functions use the optimized Select() flavours above to acheive performance. They work with any integer or floating-point type.

template<typename T>
Min (T n, T p)
template<typename T>
Max (T n, T p)
template<typename T>
Min (T a, T b, T c)
template<typename T>
Max (T a, T b, T c)
template<typename T>
Clamp (T v, T min, T max)
template<typename T>
Clip (T v, T min, T max)

Rounding

UInt32 LFloor (Float32 a)
UInt32 LFloor (Float64 a)
SInt32 LRound (Float32 d)
Float32 Floor (Float32 a)
Float64 Floor (Float64 a)
Float32 Ceil (Float32 a)
Float64 Ceil (Float64 a)

Euclidian vector norm

UInt32 Norm (UInt32 a, UInt32 b)
Float32 Norm (Float32 a, Float32 b)
UInt32 Norm (UInt32 a1, UInt32 b1, UInt32 a2, UInt32 b2)
Float32 Norm (Float32 a1, Float32 b1, Float32 a2, Float32 b2)

Square function

UInt32 Sqr (SInt32 a)
UInt32 Sqr (UInt32 a)
Float32 Sqr (Float32 a)
Float64 Sqr (Float64 a)

Fast bit shifting

template<typename T>
ShiftLeft (T const integer, SInt8 const offset)
 Shift integer left by a signed offset: if negative, a right shift is applied. If offset is a compile-time constant, no branch should be generated by your compiler -- it should actually only output one assembly instruction.
template<typename T>
ShiftRight (T const integer, SInt8 const offset)
 Shift integer right by a signed offset: if negative, a left shift is applied. If offset is a compile-time constant, no branch should be generated by your compiler -- it should actually only output one assembly instruction.
UInt64 ShiftLeft (UInt64 const integer, UInt8 const s)
 Fast, Select()-based bit shifting for 64-bit integers on 32-bit machines.
UInt64 ShiftRight (UInt64 const integer, UInt8 const s)
 Fast, Select()-based bit shifting for 64-bit integers on 32-bit machines.

Functions

Float32 Divide (Float32 x, Float32 y)
 Floating-point division.
UInt32 Average (UInt32 a, UInt32 b, UInt32 c)
 Average of three integers.
UInt16 Sqrt (UInt32 a)
 Integer square root.
template<typename T>
Select (T a, T b, T alt1, T alt2)
Float32 Sqrtr (Float32 a)
Float64 Sqrtr (Float64 a)
Generated on Tue Jun 12 14:03:28 2007 for gml by Doxygen 1.5.2.