Main Page | Modules | Class List | File List | Class Members | File Members

Numerical Routines
[Common]


Defines

#define ADDRESS(i)   ((void *)CHADDR(i))
#define CHADDR(i)   ((void *)(&(((char *)base)[(i)*size])))
#define SWAP(i, j)   {memcpy(tmpbuf,CHADDR(i),size); memcpy(CHADDR(i),CHADDR(j),size); memcpy(CHADDR(j),tmpbuf,size);}

Functions

double gan_sqr_d (double x)
 Real square function.
float gan_sqr_f (float x)
 Real square function (single precision).
int gan_sqr_i (int x)
 Integer square function.
unsigned gan_sqr_ui (unsigned x)
 Unsigned integer square function.
long gan_sqr_l (long x)
 Long integer square function.
double gan_cbrt (double x)
 Real cube root function.
double gan_normal_sample (double mu, double sigma)
 Returns a sample of a normally distributed random variable.
int gan_solve_quadratic (double a, double b, double c, Gan_Complex x[2])
 Find roots of a quadratic equation with real coefficients.
int gan_solve_cubic (double a, double b, double c, double d, Gan_Complex x[3])
 Find roots of a cubic equation with real coefficients.
void * gan_kth_highest (void *base, size_t nmemb, size_t size, unsigned int k, int(*compar)(const void *, const void *))
 Return k'th highest element of an array.
double gan_sqr (double x)
 Macro: Computes square of a number.
long gan_random (void)
 Macro: Integer random number generator function.
void gan_random_set_seed (unsigned seed)
 Macro: Integer random number seed setter function.
double gan_random_01 (void)
 Macro: Random floating point number between 0 and 1.
double gan_random_m11 (void)
 Macro: Random floating point number between -1 and 1.

Function Documentation

double gan_cbrt double  x  ) 
 

Real cube root function.

Parameters:
x Input real value
Returns:
The cube root of x.
Real cube root function.

double gan_normal_sample double  mu,
double  sigma
 

Returns a sample of a normally distributed random variable.

Parameters:
mu The mean of the normal distribution
sigma The standard deviation of the Gaussian distribution
Returns:
The sample taken from the normal distribution.
Returns a sample from a normal distribution. Two values are computed, but only one is returned.

int gan_solve_cubic double  a,
double  b,
double  c,
double  d,
Gan_Complex  x[3]
 

Find roots of a cubic equation with real coefficients.

Parameters:
a The coeffient in $ x^3 $
b The coeffient in $ x^2 $
c The coeffient in $ x $
d The scalar coeffient
x The roots of the equation
Returns:
The number of roots, or -1 on error.
Solve cubic equation

\[ a\:x^3 + b\:x^2 + c\:x + d = 0 \]

using method given in Numerical Recipes.

int gan_solve_quadratic double  a,
double  b,
double  c,
Gan_Complex  x[2]
 

Find roots of a quadratic equation with real coefficients.

Parameters:
a The coeffient in $ x^2 $
b The coeffient in $ x $
c The scalar coeffient
x The roots of the equation
Returns:
The number of roots, or -1 on error.
Solve quadratic equation

\[ a\:x^2 + b\:x + c = 0 \]

using method given in Numerical Recipes.

double gan_sqr_d double  x  ) 
 

Real square function.

Parameters:
x Input real value
Returns:
The square of x
Real square function.

See also:
gan_sqr_i(), gan_cbrt().

float gan_sqr_f float  x  ) 
 

Real square function (single precision).

Parameters:
x Input real value
Returns:
The square of x
Real square function

See also:
gan_sqr_d(), gan_cbrt().

int gan_sqr_i int  x  ) 
 

Integer square function.

Parameters:
x Input integer value
Returns:
The square of x
Integer square function

See also:
gan_sqr_d(), gan_cbrt().

long gan_sqr_l long  x  ) 
 

Long integer square function.

Parameters:
x Input long integer value
Returns:
The square of x
Long integer square function

See also:
gan_sqr_i(), gan_cbrt().

unsigned gan_sqr_ui unsigned  x  ) 
 

Unsigned integer square function.

Parameters:
x Input unsigned integer value
Returns:
The square of x
Unsigned integer square function.

See also:
gan_sqr_d(), gan_cbrt().


Generated on Fri Mar 17 12:44:54 2006 by  doxygen 1.3.9.1