Gadget
Functions | Variables
mathfunc.h File Reference
#include "gadget.h"
Include dependency graph for mathfunc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int max (int a, int b)
 This function will calculate the maximum of 2 numbers (integers) More...
 
double max (double a, double b)
 This function will calculate the maximum of 2 numbers (doubles) More...
 
int min (int a, int b)
 This function will calculate the minimum of 2 numbers (integers) More...
 
double min (double a, double b)
 This function will calculate the minimum of 2 numbers (doubles) More...
 
int isZero (double a)
 This function will check to see if a number is very close to zero. More...
 
int isEqual (double a, double b)
 This function will check to see if two numbers are equal. More...
 
int isSmall (double a)
 This function will check to see if a number is rather small (or zero) More...
 
double logFactorial (double n)
 This function will calculate the value of the logarithm of n factorial. More...
 
double expRep (double n)
 This function will calculate the value of the exponential of n. More...
 
double randomNumber ()
 This function will generate a random number in the range 0.0 to 1.0. More...
 
double calcMortality (double pred, double pop, double t)
 This function will calculate the calculate the effective annual mortality caused by a given predation on a specified population during a timestep. More...
 

Variables

const double pivalue = atan(1.0) * 4.0
 This is the value of pi used in the simulation. More...
 

Function Documentation

◆ calcMortality()

double calcMortality ( double  pred,
double  pop,
double  t 
)
inline

This function will calculate the calculate the effective annual mortality caused by a given predation on a specified population during a timestep.

Parameters
predis the number that is removed from the population by the predation
popis the population size (before predation)
tis the inverse of proportion of the year covered by the current timestep
Returns
calculated mortality

◆ expRep()

double expRep ( double  n)
inline

This function will calculate the value of the exponential of n.

Parameters
nis the number that the exponential will be calculated for
Returns
the value of exp (n)
Note
This function replaces 'exp' to return a value in the range 0.0 to 1.0

◆ isEqual()

int isEqual ( double  a,
double  b 
)
inline

This function will check to see if two numbers are equal.

Parameters
ais the first number that is being checked
bis the second number that is being checked
Returns
1 if the two numbers are equal, 0 otherwise
Note
This function replaces 'a == b' to take account of numerical inaccuracies when calculating the exact value of a double

◆ isSmall()

int isSmall ( double  a)
inline

This function will check to see if a number is rather small (or zero)

Parameters
ais the number that is being checked
Returns
1 if the number is rather small, 0 otherwise

◆ isZero()

int isZero ( double  a)
inline

This function will check to see if a number is very close to zero.

Parameters
ais the number that is being checked
Returns
1 if the number is very close to zero, 0 otherwise
Note
This function replaces 'a == 0' to take account of numerical inaccuracies when calculating the exact value of a double

◆ logFactorial()

double logFactorial ( double  n)
inline

This function will calculate the value of the logarithm of n factorial.

Parameters
nis the number that the logfactorial will be calculated for
Returns
the value of log(n!)
Note
This function is not an ANSI function and so will not compile correctly if gadget is compiled with the -ansi flag, unless we include #define __GNU_SOURCE in this file

◆ max() [1/2]

double max ( double  a,
double  b 
)
inline

This function will calculate the maximum of 2 numbers (doubles)

Parameters
ais the first number
bis the second number
Returns
a if a is greater than b, b otherwise

◆ max() [2/2]

int max ( int  a,
int  b 
)
inline

This function will calculate the maximum of 2 numbers (integers)

Parameters
ais the first number
bis the second number
Returns
a if a is greater than b, b otherwise

◆ min() [1/2]

double min ( double  a,
double  b 
)
inline

This function will calculate the minimum of 2 numbers (doubles)

Parameters
ais the first number
bis the second number
Returns
a if a is less than b, b otherwise

◆ min() [2/2]

int min ( int  a,
int  b 
)
inline

This function will calculate the minimum of 2 numbers (integers)

Parameters
ais the first number
bis the second number
Returns
a if a is less than b, b otherwise

◆ randomNumber()

double randomNumber ( )
inline

This function will generate a random number in the range 0.0 to 1.0.

Returns
random number
Note
This function generates uniformly-distributed doubles in the range 0.0 to 1.0

Variable Documentation

◆ pivalue

const double pivalue = atan(1.0) * 4.0

This is the value of pi used in the simulation.