mutil.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Headers for math utility functions.
  3. */
  4. #ifndef I_MUT_H
  5. #define I_MUT_H
  6. #include <math.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. /* use the following #define's for local versions. */
  11. #ifdef DOS
  12. #define erf mut_erf
  13. #define erfc mut_erfc
  14. #define lgamma mut_lgamma
  15. #endif
  16. #define daws(x) mut_daws(x)
  17. typedef struct {
  18. double *Z; /* jacobian matrix, length p*p */
  19. double *Q; /* eigenvalue matrix, length p*p */
  20. double *wk; /* work vector in eig_solve, length p */
  21. double *dg; /* diag vector in eigd, length p */
  22. int p; /* dimension */
  23. int st; /* status */
  24. int sm; /* requested decomposition */
  25. } jacobian;
  26. /* m_jacob.c */
  27. extern int jac_reqd();
  28. extern double *jac_alloc();
  29. extern void jacob_dec(), chol_dec(), eig_dec();
  30. extern int jacob_solve(), chol_solve(), eig_solve();
  31. extern int jacob_hsolve(),chol_hsolve(),eig_hsolve();
  32. extern int jacob_isolve(),chol_isolve(),eig_isolve();
  33. extern double jacob_qf(), chol_qf(), eig_qf();
  34. /* m_max.c */
  35. extern double max_grid(), max_golden(), max_quad(), max_nr();
  36. /* maxbv.c */
  37. extern double maxbvgrid(), maxbvstep(), maxquadstep(), maxbv(), maxbvq();
  38. /* quadmin.c */
  39. extern void quadmin(), project(), resproj(), conquadmin();
  40. /* m_qr.c */
  41. extern void qr(), qrinvx(), qrtinvx(), qrsolv();
  42. /* m_svd.c */
  43. extern void svd(), hsvdsolve();
  44. extern int svdsolve();
  45. /* m_solve.c */
  46. extern double solve_secant(), solve_nr(), solve_fp();
  47. /* m_vector.c */
  48. extern void setzero(), unitvec(), addouter();
  49. extern void matrixmultiply(), multmatscal(), transpose();
  50. extern double innerprod(), m_trace();
  51. /* math.c */
  52. extern double mut_gamma(), mut_erf(), mut_erfc(), mut_daws(), mut_exp();
  53. extern double ptail(), logit(), expit();
  54. extern int factorial();
  55. #define BDF_NONE 0
  56. #define BDF_EXPLEFT 1
  57. #define BDF_EXPRIGHT 2
  58. /* return codes for functions optimized by max_nr */
  59. #define NR_OK 0
  60. #define NR_INVALID 1
  61. #define NR_BREAK 2
  62. #define NR_REDUCE 3
  63. #define NR_NCON 10
  64. #define NR_NDIV 11
  65. /* jacobian status definitions */
  66. #define JAC_RAW 0
  67. #define JAC_CHOL 1
  68. #define JAC_EIG 2
  69. #define JAC_EIGD 3
  70. /* Numerical Integration Stuff
  71. */
  72. #define MXRESULT 5
  73. #define MXIDIM 10 /* max. dimension */
  74. extern void simpsonm(), simpson4(), integ_disc(), integ_circ();
  75. extern void integ_sphere(), monte(), rn3();
  76. extern double simpson(), sptarea();
  77. /* Density, distribution stuff
  78. */
  79. #ifndef PI
  80. #define PI 3.141592653589793238462643
  81. #endif
  82. #define PIx2 6.283185307179586476925286 /* 2*pi */
  83. #define HF_LG_PIx2 0.918938533204672741780329736406 /* 0.5*log(2*pi) */
  84. #define SQRT2 1.4142135623730950488
  85. #define LOG_ZERO -1e100
  86. #define D_0 ((give_log) ? LOG_ZERO : 0.0)
  87. #define D_1 ((give_log) ? 0.0 : 1.0)
  88. #define DEXP(x) ((give_log) ? (x) : exp(x))
  89. #define FEXP(f,x) ((give_log) ? -0.5*log(f)+(x) : exp(x)/sqrt(f))
  90. #define INVALID_PARAMS 0.0
  91. extern double stirlerr(), bd0();
  92. extern double dbinom_raw(), dpois_raw();
  93. extern double dbinom(), dpois(), dnbinom(), dbeta(), dgamma(), dt(), df(), dhyper();
  94. extern double dchisq();
  95. extern double igamma(), ibeta();
  96. extern double pf(), pchisq(), mut_pnorm();
  97. #define pchisq(x,df) igamma((x)/2.0,(df)/2.0)
  98. #endif /* define I_MUT_H */