1 /* ncbimath.h 2 * =========================================================================== 3 * 4 * PUBLIC DOMAIN NOTICE 5 * National Center for Biotechnology Information 6 * 7 * This software/database is a "United States Government Work" under the 8 * terms of the United States Copyright Act. It was written as part of 9 * the author's official duties as a United States Government employee and 10 * thus cannot be copyrighted. This software/database is freely available 11 * to the public for use. The National Library of Medicine and the U.S. 12 * Government have not placed any restriction on its use or reproduction. 13 * 14 * Although all reasonable efforts have been taken to ensure the accuracy 15 * and reliability of the software and data, the NLM and the U.S. 16 * Government do not and cannot warrant the performance or results that 17 * may be obtained by using this software or data. The NLM and the U.S. 18 * Government disclaim all warranties, express or implied, including 19 * warranties of performance, merchantability or fitness for any particular 20 * purpose. 21 * 22 * Please cite the author in any work or product based on this material. 23 * 24 * =========================================================================== 25 * 26 * File Name: ncbimath.h 27 * 28 * Author: Gish, Kans, Ostell, Schuler 29 * 30 * Version Creation Date: 10/23/91 31 * 32 * $Revision: 6.1 $ 33 * 34 * File Description: 35 * prototypes for portable math library 36 * 37 * Modifications: 38 * -------------------------------------------------------------------------- 39 * Date Name Description of modification 40 * ------- ---------- ----------------------------------------------------- 41 * 42 * $Log: ncbimath.h,v $ 43 * Revision 6.1 1999/11/24 17:29:16 sicotte 44 * Added LnFactorial function 45 * 46 * Revision 6.0 1997/08/25 18:16:37 madden 47 * Revision changed to 6.0 48 * 49 * Revision 5.2 1996/12/03 21:48:33 vakatov 50 * Adopted for 32-bit MS-Windows DLLs 51 * 52 * Revision 5.1 1996/06/20 14:08:00 madden 53 * Changed int to Int4, double to Nlm_FloatHi 54 * 55 * Revision 5.0 1996/05/28 13:18:57 ostell 56 * Set to revision 5.0 57 * 58 * Revision 4.0 1995/07/26 13:46:50 ostell 59 * force revision to 4.0 60 * 61 * Revision 2.4 1995/05/15 18:45:58 ostell 62 * added Log line 63 * 64 * 65 * 66 * ========================================================================== 67 */ 68 69 #include <ncbi.h> 70 71 #ifndef _NCBIMATH_ 72 #define _NCBIMATH_ 73 74 #undef NLM_EXTERN 75 #ifdef NLM_IMPORT 76 #define NLM_EXTERN NLM_IMPORT 77 #else 78 #define NLM_EXTERN extern 79 #endif 80 81 82 #ifdef __cplusplus 83 extern "C" { 84 #endif 85 86 /* log(x+1) for all x > -1 */ 87 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_Log1p PROTO((Nlm_FloatHi)); 88 89 /* exp(x)-1 for all x */ 90 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_Expm1 PROTO((Nlm_FloatHi)); 91 92 /* Factorial */ 93 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_Factorial PROTO((Int4)); 94 95 /* Logarithm of the factorial Fn */ 96 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_LnFactorial PROTO((FloatHi x)); 97 98 /* gamma(x) */ 99 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_Gamma PROTO((Nlm_FloatHi)); 100 101 /* log(gamma(x)) */ 102 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_LnGamma PROTO((Nlm_FloatHi)); 103 104 /* log(gamma(n)), integral n */ 105 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_LnGammaInt PROTO((Int4)); 106 107 /* digamma(x) 1st order derivative of log(gamma(x)) */ 108 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_DiGamma PROTO((Nlm_FloatHi)); 109 110 /* trigamma(x) 2nd order derivative of log(gamma(x)) */ 111 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_TriGamma PROTO((Nlm_FloatHi)); 112 113 /* Nth order derivative of log(gamma) */ 114 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_PolyGamma PROTO((Nlm_FloatHi x, Int4 order)); 115 116 /* Change gamma coefficients */ 117 NLM_EXTERN void LIBCALL Nlm_GammaCoeffSet PROTO((Nlm_FloatHi PNTR coef, unsigned dimension)); 118 119 /* Nth order derivative of ln(u) */ 120 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_LogDerivative PROTO((Int4 order, Nlm_FloatHi PNTR u)); 121 122 123 /* Combined Newton-Raphson and Bisection root solver */ 124 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_NRBis PROTO((Nlm_FloatHi y, Nlm_FloatHi (LIBCALL *f) (Nlm_FloatHi), Nlm_FloatHi (LIBCALL *df) (Nlm_FloatHi), Nlm_FloatHi p, Nlm_FloatHi x, Nlm_FloatHi q, Nlm_FloatHi tol)); 125 126 /* Romberg numerical integrator */ 127 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_RombergIntegrate PROTO((Nlm_FloatHi (LIBCALL *f) (Nlm_FloatHi, Nlm_VoidPtr), Nlm_VoidPtr fargs, Nlm_FloatHi p, Nlm_FloatHi q, Nlm_FloatHi eps, Int4 epsit, Int4 itmin)); 128 129 /* Greatest common divisor */ 130 NLM_EXTERN long LIBCALL Nlm_Gcd PROTO((long, long)); 131 132 /* Nearest integer */ 133 NLM_EXTERN long LIBCALL Nlm_Nint PROTO((Nlm_FloatHi)); 134 135 /* Integral power of x */ 136 NLM_EXTERN Nlm_FloatHi LIBCALL Nlm_Powi PROTO((Nlm_FloatHi x, Int4 n)); 137 138 /* Random no. seeder and generator */ 139 NLM_EXTERN void LIBCALL Nlm_RandomSeed PROTO((long n)); 140 NLM_EXTERN long LIBCALL Nlm_RandomNum PROTO((void)); 141 142 143 #define Log1p Nlm_Log1p 144 #define Expm1 Nlm_Expm1 145 #define Factorial Nlm_Factorial 146 #define LnFactorial Nlm_LnFactorial 147 #define Gamma Nlm_Gamma 148 #define LnGamma Nlm_LnGamma 149 #define DiGamma Nlm_DiGamma 150 #define TriGamma Nlm_TriGamma 151 #define PolyGamma Nlm_PolyGamma 152 #define GammaCoeffSet Nlm_GammaCoeffSet 153 #define LogDerivative Nlm_LogDerivative 154 #define NRBis Nlm_NRBis 155 #define RombergIntegrate Nlm_RombergIntegrate 156 #define Gcd Nlm_Gcd 157 #define Nint Nlm_Nint 158 #define Powi Nlm_Powi 159 #define RandomSeed Nlm_RandomSeed 160 #define RandomNum Nlm_RandomNum 161 162 /* Error codes for the CTX_NCBIMATH context */ 163 #define ERR_NCBIMATH_INVAL 1 /* invalid parameter */ 164 #define ERR_NCBIMATH_DOMAIN 2 /* domain error */ 165 #define ERR_NCBIMATH_RANGE 3 /* range error */ 166 #define ERR_NCBIMATH_ITER 4 /* iteration limit exceeded */ 167 168 #define LOGDERIV_ORDER_MAX 4 169 #define POLYGAMMA_ORDER_MAX LOGDERIV_ORDER_MAX 170 171 #define NCBIMATH_PI 3.1415926535897932384626433832795 172 #define NCBIMATH_E 2.7182818284590452353602874713527 173 /* Euler's constant */ 174 #define NCBIMATH_EULER 0.5772156649015328606065120900824 175 /* Catalan's constant */ 176 #define NCBIMATH_CATALAN 0.9159655941772190150546035149324 177 178 /* sqrt(2) */ 179 #define NCBIMATH_SQRT2 1.4142135623730950488016887242097 180 /* sqrt(3) */ 181 #define NCBIMATH_SQRT3 1.7320508075688772935274463415059 182 /* sqrt(PI) */ 183 #define NCBIMATH_SQRTPI 1.7724538509055160272981674833411 184 /* Natural log(2) */ 185 #define NCBIMATH_LN2 0.69314718055994530941723212145818 186 /* Natural log(10) */ 187 #define NCBIMATH_LN10 2.3025850929940456840179914546844 188 /* Natural log(PI) */ 189 #define NCBIMATH_LNPI 1.1447298858494001741434273513531 190 191 #ifdef __cplusplus 192 } 193 #endif 194 195 196 #undef NLM_EXTERN 197 #ifdef NLM_EXPORT 198 #define NLM_EXTERN NLM_EXPORT 199 #else 200 #define NLM_EXTERN 201 #endif 202 203 #endif /* !_NCBIMATH_ */ 204 205