annotate rDiff/src/locfit/Source/mut.h @ 0:0f80a5141704

version 0.3 uploaded
author vipints
date Thu, 14 Feb 2013 23:38:36 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
1 /*
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2 * Copyright 1996-2006 Catherine Loader.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3 */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 /*
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5 * Headers for math utility functions.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 #ifndef I_MUT_H
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 #define I_MUT_H
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 #include <stdio.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 #include <stdlib.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13 #include <string.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14 #include <math.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 typedef int (*prf)();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17 extern prf mut_printf;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 extern void mut_redirect();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 typedef struct {
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21 double *Z; /* jacobian matrix, length p*p */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 double *Q; /* eigenvalue matrix, length p*p */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 double *wk; /* work vector in eig_solve, length p */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 double *dg; /* diag vector in eigd, length p */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 int p; /* dimension */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 int st; /* status */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 int sm; /* requested decomposition */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28 } jacobian;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
30 /* m_jacob.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31 extern int jac_reqd();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
32 extern double *jac_alloc();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
33 extern void jacob_dec(), chol_dec(), eig_dec();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
34 extern int jacob_solve(), chol_solve(), eig_solve();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
35 extern int jacob_hsolve(),chol_hsolve(),eig_hsolve();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
36 extern int jacob_isolve(),chol_isolve(),eig_isolve();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
37 extern double jacob_qf(), chol_qf(), eig_qf();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
38 extern int jacob_mult(), chol_mult();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
39
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
40 /* m_max.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
41 extern double max_grid(), max_golden(), max_quad(), max_nr();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
42
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
43 /* maxbv.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
44 extern double maxbvgrid(), maxbvstep(), maxquadstep(), maxbv(), maxbvq();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
45
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
46 /* quadmin.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
47 extern void quadmin(), project(), resproj(), conquadmin();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
48
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
49 /* m_qr.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
50 extern void qr(), qrinvx(), qrtinvx(), qrsolv();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
51
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
52 /* m_svd.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
53 extern void svd(), hsvdsolve();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
54 extern int svdsolve();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
55
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
56 /* m_solve.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
57 extern double solve_bisect(), solve_secant(), solve_nr(), solve_fp();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
58
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
59 /* m_vector.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
60 extern void setzero(), unitvec(), addouter();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
61 extern void matrixmultiply(), multmatscal(), transpose();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
62 extern double innerprod(), m_trace(), vecsum();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
63
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
64 #define BDF_NONE 0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
65 #define BDF_EXPLEFT 1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
66 #define BDF_EXPRIGHT 2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
67
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
68 /* return codes for functions optimized by max_nr */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
69 #define NR_OK 0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
70 #define NR_INVALID 1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
71 #define NR_BREAK 2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
72 #define NR_REDUCE 3
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
73 #define NR_NCON 10
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
74 #define NR_NDIV 11
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
75
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
76
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
77 /* jacobian status definitions */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
78 #define JAC_RAW 0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
79 #define JAC_CHOL 1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
80 #define JAC_EIG 2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
81 #define JAC_EIGD 3
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
82
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
83 /* Numerical Integration Stuff
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
84 */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
85 #define MXRESULT 5
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
86 #define MXIDIM 10 /* max. dimension */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
87 extern void simpsonm(), simpson4(), integ_disc(), integ_circ();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
88 extern void integ_sphere(), monte(), rn3();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
89 extern double simpson(), sptarea();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
90
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
91 /* Density, distribution stuff
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
92 */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
93
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
94 #ifndef PI
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
95 #define PI 3.141592653589793238462643
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
96 #endif
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
97 #define S2PI 2.506628274631000502415765 /* sqrt(2*pi) */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
98 #define PIx2 6.283185307179586476925286 /* 2*pi */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
99 #define SQRPI 1.772453850905516027298 /* sqrt(pi) */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
100 #define HF_LG_PIx2 0.918938533204672741780329736406 /* 0.5*log(2*pi) */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
101 #define SQRT2 1.4142135623730950488 /* sqrt(2.0) */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
102 #define gold_rat 0.6180339887498948482045870 /* (sqrt(5.0)-1)/2 */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
103
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
104 #define LOG_ZERO -1e100
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
105 #define D_0 ((give_log) ? LOG_ZERO : 0.0)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
106 #define D_1 ((give_log) ? 0.0 : 1.0)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
107 #define DEXP(x) ((give_log) ? (x) : exp(x))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
108 #define FEXP(f,x) ((give_log) ? -0.5*log(f)+(x) : exp(x)/sqrt(f))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
109
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
110 #define INVALID_PARAMS 0.0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
111
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
112 extern double stirlerr(), bd0();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
113 extern double dbinom_raw(), dpois_raw();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
114 extern double dbinom(), dpois(), dnbinom(), dbeta(), dgamma(), dt(), df(), dhyper();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
115 extern double dchisq();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
116
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
117 extern double igamma(), ibeta();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
118 extern double pf(), pchisq();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
119 #define pchisq(x,df) igamma((x)/2.0,(df)/2.0)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
120
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
121 /* order.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
122 extern void mut_order();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
123
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
124 /* erf.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
125 extern double mut_erf(), mut_erfc(), mut_pnorm();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
126
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
127 /* lgamma.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
128 extern double mut_lgamma(), mut_lgammai();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
129
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
130 /* math.c */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
131 extern double mut_exp(), mut_daws(), ptail(), logit(), expit();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
132 extern int factorial();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
133 #endif /* define I_MUT_H */