![]() |
Bsoft 2.1.4
Bernard's software package
|
Mathematics utility functions. More...
Functions | |
double | bfloor (double value, int places) |
Truncates a value to a specified number of decimal places. More... | |
double | bround (double value, int places) |
Rounds a value to a specified number of decimal places. More... | |
double | sinc (double d) |
Returns the normalized cardinal sine. More... | |
double | factorial (int n) |
Calculates the factorial of n. More... | |
double | number_of_combinations (int n, int r) |
Calculates the number of combinations of size r in set of size n. More... | |
int | partition (vector< double > &a, int n, int k) |
Determines the index k'th value in the array. More... | |
long * | prime_factors (long number, long &n) |
Finds all the prime factor for the input number. More... | |
long | smallest_prime (long number) |
Finds the smallest prime number factor of the input number. More... | |
int | next_permutation (Bstring &s) |
Produces the next permutation in lexical order. More... | |
double | fishers_z_transform (double value) |
Calculates Fisher's z-transform. More... | |
double | betacf (double a, double b, double x) |
Evaluates the continued fraction for the incomplete beta function. More... | |
double | betai (double a, double b, double x) |
Calculates the incomplete beta function Ix(a,b). More... | |
double | kmeans_threshold (long n, double *v) |
Finds a threshold that partitions an array into foreground and background clusters. More... | |
Variables | |
int | verbose |
Mathematics utility functions.
double betacf | ( | double | a, |
double | b, | ||
double | x | ||
) |
Evaluates the continued fraction for the incomplete beta function.
a | first parameter. |
b | second parameter. |
x | domain variable [0,1]. |
Lentz's method.Reference: Press W.H. et al (1992) Numerical Recipes in C.
double betai | ( | double | a, |
double | b, | ||
double | x | ||
) |
Calculates the incomplete beta function Ix(a,b).
a | first parameter. |
b | second parameter. |
x | domain variable [0,1]. |
Limiting values: I0(a,b) = 0, I1(a,b) = 1. Symmetry relation: Ix(a,b) = 1 - I1-x(b,a).Reference: Press W.H. et al (1992) Numerical Recipes in C.
double bfloor | ( | double | value, |
int | places | ||
) |
Truncates a value to a specified number of decimal places.
value | value to be truncated. |
places | number of decimal places. |
double bround | ( | double | value, |
int | places | ||
) |
Rounds a value to a specified number of decimal places.
value | value to be rounded. |
places | number of decimal places. |
double factorial | ( | int | n | ) |
Calculates the factorial of n.
n | integer. |
All values of n less than 1 returns 1. An exact calculation is done for 1 < n <= 50. The Lancos approximation is used for n > 50. Factorials of integers larger than 170 exceeds the capacity of a double and causes program termination. The largest relative error is for 170: 1.22378e-13.Reference: Press W.H. et al (1992) Numerical Recipes in C.
double fishers_z_transform | ( | double | value | ) |
Calculates Fisher's z-transform.
value | a value. |
Fisher's z-transform is given by: z = 0.5*log((1+v)/(1-v))Reference: Press W.H. et al (1992) Numerical Recipes in C.
double kmeans_threshold | ( | long | n, |
double * | v | ||
) |
Finds a threshold that partitions an array into foreground and background clusters.
n | number of array elements. |
v | array. |
Limiting values: I0(a,b) = 0, I1(a,b) = 1. Symmetry relation: Ix(a,b) = 1 - I1-x(b,a).Reference: Press W.H. et al (1992) Numerical Recipes in C.
int next_permutation | ( | Bstring & | s | ) |
Produces the next permutation in lexical order.
&s | string of symbols to permute. |
To get all permutations, the first string needs to be ordered in ascending order.Reference: Press W.H. et al (1992) Numerical Recipes in C.
double number_of_combinations | ( | int | n, |
int | r | ||
) |
Calculates the number of combinations of size r in set of size n.
n | number in set. |
r | number in subset. |
All values of n less than 1 returns 1. An exact calculation is done for 1 < n <= 50. The Lancos approximation is used for n > 50.Reference: Press W.H. et al (1992) Numerical Recipes in C.
int partition | ( | vector< double > & | a, |
int | n, | ||
int | k | ||
) |
Determines the index k'th value in the array.
*a | array. |
n | number of array elements. |
k | rank index to look for. |
The array is partioned into 2 sides, with the left side lower or equal to and the right side higher or equal to the k'th element. This is useful to determine the median without full sorting.Reference: Press W.H. et al (1992) Numerical Recipes in C.
long * prime_factors | ( | long | number, |
long & | n | ||
) |
Finds all the prime factor for the input number.
number | integer. |
&n | number of prime factors. |
Calculates the prime factors from the smallest to the largest.Reference: Press W.H. et al (1992) Numerical Recipes in C.
double sinc | ( | double | d | ) |
Returns the normalized cardinal sine.
d | value. |
long smallest_prime | ( | long | number | ) |
Finds the smallest prime number factor of the input number.
number | integer. |
Tries to divide the given positive integer number by primes from 2 to the square root of the integer. Returns the first prime divisor found, which may be the input number if it is prime.Reference: Press W.H. et al (1992) Numerical Recipes in C.
|
extern |