mut.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright 1996-2006 Catherine Loader.
  3. */
  4. /*
  5. * Headers for math utility functions.
  6. */
  7. #ifndef I_MUT_H
  8. #define I_MUT_H
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <math.h>
  13. typedef int (*prf)();
  14. extern prf mut_printf;
  15. extern void mut_redirect();
  16. typedef struct {
  17. double *Z; /* jacobian matrix, length p*p */
  18. double *Q; /* eigenvalue matrix, length p*p */
  19. double *wk; /* work vector in eig_solve, length p */
  20. double *dg; /* diag vector in eigd, length p */
  21. int p; /* dimension */
  22. int st; /* status */
  23. int sm; /* requested decomposition */
  24. } jacobian;
  25. /* m_jacob.c */
  26. extern int jac_reqd();
  27. extern double *jac_alloc();
  28. extern void jacob_dec(), chol_dec(), eig_dec();
  29. extern int jacob_solve(), chol_solve(), eig_solve();
  30. extern int jacob_hsolve(),chol_hsolve(),eig_hsolve();
  31. extern int jacob_isolve(),chol_isolve(),eig_isolve();
  32. extern double jacob_qf(), chol_qf(), eig_qf();
  33. extern int jacob_mult(), chol_mult();
  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_bisect(), 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(), vecsum();
  51. #define BDF_NONE 0
  52. #define BDF_EXPLEFT 1
  53. #define BDF_EXPRIGHT 2
  54. /* return codes for functions optimized by max_nr */
  55. #define NR_OK 0
  56. #define NR_INVALID 1
  57. #define NR_BREAK 2
  58. #define NR_REDUCE 3
  59. #define NR_NCON 10
  60. #define NR_NDIV 11
  61. /* jacobian status definitions */
  62. #define JAC_RAW 0
  63. #define JAC_CHOL 1
  64. #define JAC_EIG 2
  65. #define JAC_EIGD 3
  66. /* Numerical Integration Stuff
  67. */
  68. #define MXRESULT 5
  69. #define MXIDIM 10 /* max. dimension */
  70. extern void simpsonm(), simpson4(), integ_disc(), integ_circ();
  71. extern void integ_sphere(), monte(), rn3();
  72. extern double simpson(), sptarea();
  73. /* Density, distribution stuff
  74. */
  75. #ifndef PI
  76. #define PI 3.141592653589793238462643
  77. #endif
  78. #define S2PI 2.506628274631000502415765 /* sqrt(2*pi) */
  79. #define PIx2 6.283185307179586476925286 /* 2*pi */
  80. #define SQRPI 1.772453850905516027298 /* sqrt(pi) */
  81. #define HF_LG_PIx2 0.918938533204672741780329736406 /* 0.5*log(2*pi) */
  82. #define SQRT2 1.4142135623730950488 /* sqrt(2.0) */
  83. #define gold_rat 0.6180339887498948482045870 /* (sqrt(5.0)-1)/2 */
  84. #define LOG_ZERO -1e100
  85. #define D_0 ((give_log) ? LOG_ZERO : 0.0)
  86. #define D_1 ((give_log) ? 0.0 : 1.0)
  87. #define DEXP(x) ((give_log) ? (x) : exp(x))
  88. #define FEXP(f,x) ((give_log) ? -0.5*log(f)+(x) : exp(x)/sqrt(f))
  89. #define INVALID_PARAMS 0.0
  90. extern double stirlerr(), bd0();
  91. extern double dbinom_raw(), dpois_raw();
  92. extern double dbinom(), dpois(), dnbinom(), dbeta(), dgamma(), dt(), df(), dhyper();
  93. extern double dchisq();
  94. extern double igamma(), ibeta();
  95. extern double pf(), pchisq();
  96. #define pchisq(x,df) igamma((x)/2.0,(df)/2.0)
  97. /* order.c */
  98. extern void mut_order();
  99. /* erf.c */
  100. extern double mut_erf(), mut_erfc(), mut_pnorm();
  101. /* lgamma.c */
  102. extern double mut_lgamma(), mut_lgammai();
  103. /* math.c */
  104. extern double mut_exp(), mut_daws(), ptail(), logit(), expit();
  105. extern int factorial();
  106. #endif /* define I_MUT_H */