NCBI C++ ToolKit
|
Prototypes for portable math library (ported from C Toolkit) More...
Go to the source code of this file.
Go to the SVN repository for this file.
Macros | |
#define | LOGDERIV_ORDER_MAX 4 |
Number of derivatives of log(x) to carry in gamma-related computations. More... | |
#define | POLYGAMMA_ORDER_MAX LOGDERIV_ORDER_MAX |
Number of derivatives of polygamma(x) to carry in gamma-related computations for non-integral values of x. More... | |
#define | NCBIMATH_PI 3.1415926535897932384626433832795 |
value of pi is only used in gamma-related computations More... | |
#define | NCBIMATH_LN2 0.69314718055994530941723212145818 |
Natural log(2) More... | |
#define | NCBIMATH_LNPI 1.1447298858494001741434273513531 |
Natural log(PI) More... | |
Functions | |
double | BLAST_Log1p (double x) |
Natural logarithm with shifted input. More... | |
double | BLAST_Expm1 (double x) |
Exponentional with base e. More... | |
double | BLAST_Factorial (Int4 n) |
Factorial function. More... | |
double | BLAST_LnFactorial (double x) |
Logarithm of the factorial. More... | |
double | BLAST_LnGammaInt (Int4 n) |
log(gamma(n)), integral n More... | |
double | BLAST_RombergIntegrate (double(*f)(double, void *), void *fargs, double p, double q, double eps, Int4 epsit, Int4 itmin) |
Romberg numerical integrator. More... | |
Int4 | BLAST_Gcd (Int4 a, Int4 b) |
Greatest common divisor. More... | |
Int4 | BLAST_Gdb3 (Int4 *a, Int4 *b, Int4 *c) |
Divide 3 numbers by their greatest common divisor. More... | |
long | BLAST_Nint (double x) |
Nearest integer. More... | |
double | BLAST_Powi (double x, Int4 n) |
Integral power of x. More... | |
double | BLAST_Erf (double x) |
The error function of x: the integral from 0 to x of e(-t*t) dt, scaled by 2/sqrt(pi) to fall within the range (-1,1). More... | |
double | BLAST_ErfC (double x) |
The complementary error function of x: 1 - erf(x), but calculated more accurately for large x (where erf(x) approaches unity). More... | |
Prototypes for portable math library (ported from C Toolkit)
Definition in file ncbi_math.h.
#define LOGDERIV_ORDER_MAX 4 |
Number of derivatives of log(x) to carry in gamma-related computations.
Definition at line 152 of file ncbi_math.h.
#define NCBIMATH_LN2 0.69314718055994530941723212145818 |
Natural log(2)
Definition at line 161 of file ncbi_math.h.
#define NCBIMATH_LNPI 1.1447298858494001741434273513531 |
Natural log(PI)
Definition at line 163 of file ncbi_math.h.
#define NCBIMATH_PI 3.1415926535897932384626433832795 |
value of pi is only used in gamma-related computations
Definition at line 158 of file ncbi_math.h.
#define POLYGAMMA_ORDER_MAX LOGDERIV_ORDER_MAX |
Number of derivatives of polygamma(x) to carry in gamma-related computations for non-integral values of x.
Definition at line 155 of file ncbi_math.h.
double BLAST_Erf | ( | double | x | ) |
The error function of x: the integral from 0 to x of e(-t*t) dt, scaled by 2/sqrt(pi) to fall within the range (-1,1).
double BLAST_ErfC | ( | double | x | ) |
The complementary error function of x: 1 - erf(x), but calculated more accurately for large x (where erf(x) approaches unity).
double BLAST_Expm1 | ( | double | x | ) |
Exponentional with base e.
x | input operand |
Definition at line 33 of file ncbi_math.c.
References ABS.
Referenced by BLAST_KarlinEtoP(), BlastKarlinLHtoK(), s_BlastSumP(), and s_BlastSumPCalc().
double BLAST_Factorial | ( | Int4 | n | ) |
Factorial function.
n | input operand |
Definition at line 312 of file ncbi_math.c.
References DIM, kPrecomputedFactorial, n, and s_LnGamma().
Referenced by s_GeneralLnGamma(), and s_PolyGamma().
Greatest common divisor.
a | First operand (any integer) |
b | Second operand (any integer) |
Definition at line 405 of file ncbi_math.c.
Referenced by BLAST_Gdb3(), Blast_KarlinLambdaNR(), BlastKarlinLHtoK(), and s_GetNuclValuesArray().
Divide 3 numbers by their greatest common divisor.
a | First integer [in] [out] |
b | Second integer [in] [out] |
c | Third integer [in] [out] |
Definition at line 422 of file ncbi_math.c.
References a, b, BLAST_Gcd(), and g().
Referenced by BLAST_AffineGreedyAlign(), and s_BlastGreedyAlignMemAlloc().
double BLAST_LnFactorial | ( | double | x | ) |
Logarithm of the factorial.
x | input operand |
Definition at line 473 of file ncbi_math.c.
References s_LnGamma().
Referenced by BLAST_LargeGapSumE(), BLAST_SmallGapSumE(), and BLAST_UnevenGapSumE().
double BLAST_LnGammaInt | ( | Int4 | n | ) |
log(gamma(n)), integral n
n | input operand |
Definition at line 323 of file ncbi_math.c.
References DIM, kPrecomputedFactorial, log, n, and s_LnGamma().
Referenced by s_BlastSumP(), and s_BlastSumPCalc().
double BLAST_Log1p | ( | double | x | ) |
Natural logarithm with shifted input.
x | input operand (x > -1) |
Definition at line 64 of file ncbi_math.c.
References ABS, DBL_EPSILON, i, and log.
Referenced by BLAST_KarlinPtoE().
long BLAST_Nint | ( | double | x | ) |
Nearest integer.
x | Input to round (rounded value must be representable as a 32-bit signed integer) |
Definition at line 437 of file ncbi_math.c.
Referenced by _PSIConvertFreqRatiosToPSSM(), _PSIScaleMatrix(), Blast_GumbelBlkLoadFromTables(), Blast_KarlinBlkGappedLoadFromTables(), BLAST_PrintAllowedValues(), BlastKarlinReportAllowedValues(), BlastScoreBlkNuclMatrixCreate(), BOOST_AUTO_TEST_CASE(), CalculateLinkHSPCutoffs(), impalaScaleMatrix(), RPSRescalePssm(), s_BuildCompressedScoreMatrix(), s_HSPListNormalizeScores(), s_RescaleSearch(), and CMakeProfileDBApp::x_UpdateFreqRatios().
double BLAST_Powi | ( | double | x, |
Int4 | n | ||
) |
Integral power of x.
x | floating-point base of the exponential |
n | (integer) exponent |
Definition at line 444 of file ncbi_math.c.
References n.
Referenced by BLAST_GapDecayDivisor(), BlastKarlinLtoH(), s_GeneralLnGamma(), and s_PolyGamma().
double BLAST_RombergIntegrate | ( | double(*)(double, void *) | f, |
void * | fargs, | ||
double | p, | ||
double | q, | ||
double | eps, | ||
Int4 | epsit, | ||
Int4 | itmin | ||
) |
Romberg numerical integrator.
f | Pointer to the function to integrate; the first argument is the variable to integrate over, the second is a pointer to a list of additional arguments that f may need |
fargs | Pointer to an array of extra arguments or parameters needed to compute the function to be integrated. None of the items in this list may vary over the region of integration |
p | Left-hand endpoint of the integration interval |
q | Right-hand endpoint of the integration interval (q is assumed > p) |
eps | The relative error tolerance that indicates convergence |
epsit | The number of consecutive diagonal entries in the Romberg array whose relative difference must be less than eps before convergence is assumed. This is presently limited to 1, 2, or 3 |
itmin | The minimum number of diagnonal Romberg entries that will be computed |
Definition at line 346 of file ncbi_math.c.
References ABS, F, i, MAX, MAX_DIAGS, MIN, and n.
Referenced by s_BlastSumPCalc(), and s_InnerIntegralCback().