nr.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. /* CAUTION: This is the ANSI C (only) version of the Numerical Recipes
  2. utility file nr.h. Do not confuse this file with the same-named
  3. file nr.h that is supplied in the 'misc' subdirectory.
  4. *That* file is the one from the book, and contains both ANSI and
  5. traditional K&R versions, along with #ifdef macros to select the
  6. correct version. *This* file contains only ANSI C. */
  7. #ifndef _NR_H_
  8. #define _NR_H_
  9. #define REAL double
  10. #ifndef _FCOMPLEX_DECLARE_T_
  11. typedef struct FCOMPLEX {REAL r,i;} fcomplex;
  12. #define _FCOMPLEX_DECLARE_T_
  13. #endif /* _FCOMPLEX_DECLARE_T_ */
  14. #ifndef _ARITHCODE_DECLARE_T_
  15. typedef struct {
  16. unsigned long *ilob,*iupb,*ncumfq,jdif,nc,minint,nch,ncum,nrad;
  17. } arithcode;
  18. #define _ARITHCODE_DECLARE_T_
  19. #endif /* _ARITHCODE_DECLARE_T_ */
  20. #ifndef _HUFFCODE_DECLARE_T_
  21. typedef struct {
  22. unsigned long *icod,*ncod,*left,*right,nch,nodemax;
  23. } huffcode;
  24. #define _HUFFCODE_DECLARE_T_
  25. #endif /* _HUFFCODE_DECLARE_T_ */
  26. #include <stdio.h>
  27. void addint(double **uf, double **uc, double **res, int nf);
  28. void airy(REAL x, REAL *ai, REAL *bi, REAL *aip, REAL *bip);
  29. void amebsa(REAL **p, REAL y[], int ndim, REAL pb[], REAL *yb,
  30. REAL ftol, REAL (*funk)(REAL []), int *iter, REAL temptr);
  31. void amoeba(REAL **p, REAL y[], int ndim, REAL ftol,
  32. REAL (*funk)(REAL []), int *iter);
  33. REAL amotry(REAL **p, REAL y[], REAL psum[], int ndim,
  34. REAL (*funk)(REAL []), int ihi, REAL fac);
  35. REAL amotsa(REAL **p, REAL y[], REAL psum[], int ndim, REAL pb[],
  36. REAL *yb, REAL (*funk)(REAL []), int ihi, REAL *yhi, REAL fac);
  37. void anneal(REAL x[], REAL y[], int iorder[], int ncity);
  38. double anorm2(double **a, int n);
  39. void arcmak(unsigned long nfreq[], unsigned long nchh, unsigned long nradd,
  40. arithcode *acode);
  41. void arcode(unsigned long *ich, unsigned char **codep, unsigned long *lcode,
  42. unsigned long *lcd, int isign, arithcode *acode);
  43. void arcsum(unsigned long iin[], unsigned long iout[], unsigned long ja,
  44. int nwk, unsigned long nrad, unsigned long nc);
  45. void asolve(unsigned long n, double b[], double x[], int itrnsp);
  46. void atimes(unsigned long n, double x[], double r[], int itrnsp);
  47. void avevar(REAL data[], unsigned long n, REAL *ave, REAL *var);
  48. void balanc(REAL **a, int n);
  49. void banbks(REAL **a, unsigned long n, int m1, int m2, REAL **al,
  50. unsigned long indx[], REAL b[]);
  51. void bandec(REAL **a, unsigned long n, int m1, int m2, REAL **al,
  52. unsigned long indx[], REAL *d);
  53. void banmul(REAL **a, unsigned long n, int m1, int m2, REAL x[], REAL b[]);
  54. void bcucof(REAL y[], REAL y1[], REAL y2[], REAL y12[], REAL d1,
  55. REAL d2, REAL **c);
  56. void bcuint(REAL y[], REAL y1[], REAL y2[], REAL y12[],
  57. REAL x1l, REAL x1u, REAL x2l, REAL x2u, REAL x1,
  58. REAL x2, REAL *ansy, REAL *ansy1, REAL *ansy2);
  59. void beschb(double x, double *gam1, double *gam2, double *gampl,
  60. double *gammi);
  61. REAL bessi(int n, REAL x);
  62. REAL bessi0(REAL x);
  63. REAL bessi1(REAL x);
  64. void bessik(REAL x, REAL xnu, REAL *ri, REAL *rk, REAL *rip,
  65. REAL *rkp);
  66. REAL bessj(int n, REAL x);
  67. REAL bessj0(REAL x);
  68. REAL bessj1(REAL x);
  69. void bessjy(REAL x, REAL xnu, REAL *rj, REAL *ry, REAL *rjp,
  70. REAL *ryp);
  71. REAL bessk(int n, REAL x);
  72. REAL bessk0(REAL x);
  73. REAL bessk1(REAL x);
  74. REAL bessy(int n, REAL x);
  75. REAL bessy0(REAL x);
  76. REAL bessy1(REAL x);
  77. REAL beta(REAL z, REAL w);
  78. REAL betacf(REAL a, REAL b, REAL x);
  79. REAL betai(REAL a, REAL b, REAL x);
  80. REAL bico(int n, int k);
  81. void bksub(int ne, int nb, int jf, int k1, int k2, REAL ***c);
  82. REAL bnldev(REAL pp, int n, long *idum);
  83. REAL brent(REAL ax, REAL bx, REAL cx,
  84. REAL (*f)(REAL), REAL tol, REAL *xmin);
  85. void broydn(REAL x[], int n, int *check,
  86. void (*vecfunc)(int, REAL [], REAL []));
  87. void bsstep(REAL y[], REAL dydx[], int nv, REAL *xx, REAL htry,
  88. REAL eps, REAL yscal[], REAL *hdid, REAL *hnext,
  89. void (*derivs)(REAL, REAL [], REAL []));
  90. void caldat(long julian, int *mm, int *id, int *iyyy);
  91. void chder(REAL a, REAL b, REAL c[], REAL cder[], int n);
  92. REAL chebev(REAL a, REAL b, REAL c[], int m, REAL x);
  93. void chebft(REAL a, REAL b, REAL c[], int n, REAL (*func)(REAL));
  94. void chebpc(REAL c[], REAL d[], int n);
  95. void chint(REAL a, REAL b, REAL c[], REAL cint[], int n);
  96. REAL chixy(REAL bang);
  97. void choldc(REAL **a, int n, REAL p[]);
  98. void cholsl(REAL **a, int n, REAL p[], REAL b[], REAL x[]);
  99. void chsone(REAL bins[], REAL ebins[], int nbins, int knstrn,
  100. REAL *df, REAL *chsq, REAL *prob);
  101. void chstwo(REAL bins1[], REAL bins2[], int nbins, int knstrn,
  102. REAL *df, REAL *chsq, REAL *prob);
  103. void cisi(REAL x, REAL *ci, REAL *si);
  104. void cntab1(int **nn, int ni, int nj, REAL *chisq,
  105. REAL *df, REAL *prob, REAL *cramrv, REAL *ccc);
  106. void cntab2(int **nn, int ni, int nj, REAL *h, REAL *hx, REAL *hy,
  107. REAL *hygx, REAL *hxgy, REAL *uygx, REAL *uxgy, REAL *uxy);
  108. void convlv(REAL data[], unsigned long n, REAL respns[], unsigned long m,
  109. int isign, REAL ans[]);
  110. void copy(double **aout, double **ain, int n);
  111. void correl(REAL data1[], REAL data2[], unsigned long n, REAL ans[]);
  112. void cosft(REAL y[], int n, int isign);
  113. void cosft1(REAL y[], int n);
  114. void cosft2(REAL y[], int n, int isign);
  115. void covsrt(REAL **covar, int ma, int ia[], int mfit);
  116. void crank(unsigned long n, REAL w[], REAL *s);
  117. void cyclic(REAL a[], REAL b[], REAL c[], REAL alpha, REAL beta,
  118. REAL r[], REAL x[], unsigned long n);
  119. void daub4(REAL a[], unsigned long n, int isign);
  120. REAL dawson(REAL x);
  121. REAL dbrent(REAL ax, REAL bx, REAL cx,
  122. REAL (*f)(REAL), REAL (*df)(REAL), REAL tol, REAL *xmin);
  123. void ddpoly(REAL c[], int nc, REAL x, REAL pd[], int nd);
  124. int decchk(char string[], int n, char *ch);
  125. void derivs(REAL x, REAL y[], REAL dydx[]);
  126. REAL df1dim(REAL x);
  127. void dfour1(double data[], unsigned long nn, int isign);
  128. void dfpmin(REAL p[], int n, REAL gtol, int *iter, REAL *fret,
  129. REAL (*func)(REAL []), void (*dfunc)(REAL [], REAL []));
  130. REAL dfridr(REAL (*func)(REAL), REAL x, REAL h, REAL *err);
  131. void dftcor(REAL w, REAL delta, REAL a, REAL b, REAL endpts[],
  132. REAL *corre, REAL *corim, REAL *corfac);
  133. void dftint(REAL (*func)(REAL), REAL a, REAL b, REAL w,
  134. REAL *cosint, REAL *sinint);
  135. void difeq(int k, int k1, int k2, int jsf, int is1, int isf,
  136. int indexv[], int ne, REAL **s, REAL **y);
  137. void dlinmin(REAL p[], REAL xi[], int n, REAL *fret,
  138. REAL (*func)(REAL []), void (*dfunc)(REAL [], REAL[]));
  139. double dpythag(double a, double b);
  140. void drealft(double data[], unsigned long n, int isign);
  141. void dsprsax(double sa[], unsigned long ija[], double x[], double b[],
  142. unsigned long n);
  143. void dsprstx(double sa[], unsigned long ija[], double x[], double b[],
  144. unsigned long n);
  145. void dsvbksb(double **u, double w[], double **v, int m, int n, double b[],
  146. double x[]);
  147. void dsvdcmp(double **a, int m, int n, double w[], double **v);
  148. void eclass(int nf[], int n, int lista[], int listb[], int m);
  149. void eclazz(int nf[], int n, int (*equiv)(int, int));
  150. REAL ei(REAL x);
  151. void eigsrt(REAL d[], REAL **v, int n);
  152. REAL elle(REAL phi, REAL ak);
  153. REAL ellf(REAL phi, REAL ak);
  154. REAL ellpi(REAL phi, REAL en, REAL ak);
  155. void elmhes(REAL **a, int n);
  156. REAL erfcc(REAL x);
  157. //REAL erff(REAL x);
  158. REAL erffc(REAL x);
  159. void eulsum(REAL *sum, REAL term, int jterm, REAL wksp[]);
  160. REAL evlmem(REAL fdt, REAL d[], int m, REAL xms);
  161. REAL expdev(long *idum);
  162. REAL expint(int n, REAL x);
  163. REAL f1(REAL x);
  164. REAL f1dim(REAL x);
  165. REAL f2(REAL y);
  166. REAL f3(REAL z);
  167. REAL factln(int n);
  168. REAL factrl(int n);
  169. void fasper(REAL x[], REAL y[], unsigned long n, REAL ofac, REAL hifac,
  170. REAL wk1[], REAL wk2[], unsigned long nwk, unsigned long *nout,
  171. unsigned long *jmax, REAL *prob);
  172. void fdjac(int n, REAL x[], REAL fvec[], REAL **df,
  173. void (*vecfunc)(int, REAL [], REAL []));
  174. void fgauss(REAL x, REAL a[], REAL *y, REAL dyda[], int na);
  175. void fill0(double **u, int n);
  176. void fit(REAL x[], REAL y[], int ndata, REAL sig[], int mwt,
  177. REAL *a, REAL *b, REAL *siga, REAL *sigb, REAL *chi2, REAL *q);
  178. void fitexy(REAL x[], REAL y[], int ndat, REAL sigx[], REAL sigy[],
  179. REAL *a, REAL *b, REAL *siga, REAL *sigb, REAL *chi2, REAL *q);
  180. void fixrts(REAL d[], int m);
  181. void fleg(REAL x, REAL pl[], int nl);
  182. void flmoon(int n, int nph, long *jd, REAL *frac);
  183. REAL fmin(REAL x[]);
  184. void four1(REAL data[], unsigned long nn, int isign);
  185. void fourew(FILE *file[5], int *na, int *nb, int *nc, int *nd);
  186. void fourfs(FILE *file[5], unsigned long nn[], int ndim, int isign);
  187. void fourn(REAL data[], unsigned long nn[], int ndim, int isign);
  188. void fpoly(REAL x, REAL p[], int np);
  189. void fred2(int n, REAL a, REAL b, REAL t[], REAL f[], REAL w[],
  190. REAL (*g)(REAL), REAL (*ak)(REAL, REAL));
  191. REAL fredin(REAL x, int n, REAL a, REAL b, REAL t[], REAL f[], REAL w[],
  192. REAL (*g)(REAL), REAL (*ak)(REAL, REAL));
  193. void frenel(REAL x, REAL *s, REAL *c);
  194. void frprmn(REAL p[], int n, REAL ftol, int *iter, REAL *fret,
  195. REAL (*func)(REAL []), void (*dfunc)(REAL [], REAL []));
  196. void ftest(REAL data1[], unsigned long n1, REAL data2[], unsigned long n2,
  197. REAL *f, REAL *prob);
  198. REAL gamdev(int ia, long *idum);
  199. REAL gammln(REAL xx);
  200. REAL gammp(REAL a, REAL x);
  201. REAL gammq(REAL a, REAL x);
  202. REAL gasdev(long *idum);
  203. void gaucof(int n, REAL a[], REAL b[], REAL amu0, REAL x[], REAL w[]);
  204. void gauher(REAL x[], REAL w[], int n);
  205. void gaujac(REAL x[], REAL w[], int n, REAL alf, REAL bet);
  206. void gaulag(REAL x[], REAL w[], int n, REAL alf);
  207. void gauleg(REAL x1, REAL x2, REAL x[], REAL w[], int n);
  208. void gaussj(REAL **a, int n, REAL **b, int m);
  209. void gcf(REAL *gammcf, REAL a, REAL x, REAL *gln);
  210. REAL golden(REAL ax, REAL bx, REAL cx, REAL (*f)(REAL), REAL tol,
  211. REAL *xmin);
  212. void gser(REAL *gamser, REAL a, REAL x, REAL *gln);
  213. void hpsel(unsigned long m, unsigned long n, REAL arr[], REAL heap[]);
  214. void hpsort(unsigned long n, REAL ra[]);
  215. void hqr(REAL **a, int n, REAL wr[], REAL wi[]);
  216. void hufapp(unsigned long index[], unsigned long nprob[], unsigned long n,
  217. unsigned long i);
  218. void hufdec(unsigned long *ich, unsigned char *code, unsigned long lcode,
  219. unsigned long *nb, huffcode *hcode);
  220. void hufenc(unsigned long ich, unsigned char **codep, unsigned long *lcode,
  221. unsigned long *nb, huffcode *hcode);
  222. void hufmak(unsigned long nfreq[], unsigned long nchin, unsigned long *ilong,
  223. unsigned long *nlong, huffcode *hcode);
  224. void hunt(REAL xx[], unsigned long n, REAL x, unsigned long *jlo);
  225. void hypdrv(REAL s, REAL yy[], REAL dyyds[]);
  226. fcomplex hypgeo(fcomplex a, fcomplex b, fcomplex c, fcomplex z);
  227. void hypser(fcomplex a, fcomplex b, fcomplex c, fcomplex z,
  228. fcomplex *series, fcomplex *deriv);
  229. unsigned short icrc(unsigned short crc, unsigned char *bufptr,
  230. unsigned long len, short jinit, int jrev);
  231. unsigned short icrc1(unsigned short crc, unsigned char onech);
  232. unsigned long igray(unsigned long n, int is);
  233. void iindexx(unsigned long n, long arr[], unsigned long indx[]);
  234. void indexx(unsigned long n, REAL arr[], unsigned long indx[]);
  235. void interp(double **uf, double **uc, int nf);
  236. int irbit1(unsigned long *iseed);
  237. int irbit2(unsigned long *iseed);
  238. void jacobi(REAL **a, int n, REAL d[], REAL **v, int *nrot);
  239. void jacobn(REAL x, REAL y[], REAL dfdx[], REAL **dfdy, int n);
  240. long julday(int mm, int id, int iyyy);
  241. void kendl1(REAL data1[], REAL data2[], unsigned long n, REAL *tau, REAL *z,
  242. REAL *prob);
  243. void kendl2(REAL **tab, int i, int j, REAL *tau, REAL *z, REAL *prob);
  244. void kermom(double w[], double y, int m);
  245. void ks2d1s(REAL x1[], REAL y1[], unsigned long n1,
  246. void (*quadvl)(REAL, REAL, REAL *, REAL *, REAL *, REAL *),
  247. REAL *d1, REAL *prob);
  248. void ks2d2s(REAL x1[], REAL y1[], unsigned long n1, REAL x2[], REAL y2[],
  249. unsigned long n2, REAL *d, REAL *prob);
  250. void ksone(REAL data[], unsigned long n, REAL (*func)(REAL), REAL *d,
  251. REAL *prob);
  252. void kstwo(REAL data1[], unsigned long n1, REAL data2[], unsigned long n2,
  253. REAL *d, REAL *prob);
  254. void laguer(fcomplex a[], int m, fcomplex *x, int *its);
  255. void lfit(REAL x[], REAL y[], REAL sig[], int ndat, REAL a[], int ia[],
  256. int ma, REAL **covar, REAL *chisq, void (*funcs)(REAL, REAL [], int));
  257. void linbcg(unsigned long n, double b[], double x[], int itol, double tol,
  258. int itmax, int *iter, double *err);
  259. void linmin(REAL p[], REAL xi[], int n, REAL *fret,
  260. REAL (*func)(REAL []));
  261. void lnsrch(int n, REAL xold[], REAL fold, REAL g[], REAL p[], REAL x[],
  262. REAL *f, REAL stpmax, int *check, REAL (*func)(REAL []));
  263. void load(REAL x1, REAL v[], REAL y[]);
  264. void load1(REAL x1, REAL v1[], REAL y[]);
  265. void load2(REAL x2, REAL v2[], REAL y[]);
  266. void locate(REAL xx[], unsigned long n, REAL x, unsigned long *j);
  267. void lop(double **out, double **u, int n);
  268. void lubksb(REAL **a, int n, int *indx, REAL b[]);
  269. void ludcmp(REAL **a, int n, int *indx, REAL *d);
  270. void machar(int *ibeta, int *it, int *irnd, int *ngrd,
  271. int *machep, int *negep, int *iexp, int *minexp, int *maxexp,
  272. REAL *eps, REAL *epsneg, REAL *xmin, REAL *xmax);
  273. void matadd(double **a, double **b, double **c, int n);
  274. void matsub(double **a, double **b, double **c, int n);
  275. void medfit(REAL x[], REAL y[], int ndata, REAL *a, REAL *b, REAL *abdev);
  276. void memcof(REAL data[], int n, int m, REAL *xms, REAL d[]);
  277. int metrop(REAL de, REAL t);
  278. void mgfas(double **u, int n, int maxcyc);
  279. void mglin(double **u, int n, int ncycle);
  280. REAL midexp(REAL (*funk)(REAL), REAL aa, REAL bb, int n);
  281. REAL midinf(REAL (*funk)(REAL), REAL aa, REAL bb, int n);
  282. REAL midpnt(REAL (*func)(REAL), REAL a, REAL b, int n);
  283. REAL midsql(REAL (*funk)(REAL), REAL aa, REAL bb, int n);
  284. REAL midsqu(REAL (*funk)(REAL), REAL aa, REAL bb, int n);
  285. void miser(REAL (*func)(REAL []), REAL regn[], int ndim, unsigned long npts,
  286. REAL dith, REAL *ave, REAL *var);
  287. void mmid(REAL y[], REAL dydx[], int nvar, REAL xs, REAL htot,
  288. int nstep, REAL yout[], void (*derivs)(REAL, REAL[], REAL[]));
  289. void mnbrak(REAL *ax, REAL *bx, REAL *cx, REAL *fa, REAL *fb,
  290. REAL *fc, REAL (*func)(REAL));
  291. void mnewt(int ntrial, REAL x[], int n, REAL tolx, REAL tolf);
  292. void moment(REAL data[], int n, REAL *ave, REAL *adev, REAL *sdev,
  293. REAL *var, REAL *skew, REAL *curt);
  294. void mp2dfr(unsigned char a[], unsigned char s[], int n, int *m);
  295. void mpadd(unsigned char w[], unsigned char u[], unsigned char v[], int n);
  296. void mpdiv(unsigned char q[], unsigned char r[], unsigned char u[],
  297. unsigned char v[], int n, int m);
  298. void mpinv(unsigned char u[], unsigned char v[], int n, int m);
  299. void mplsh(unsigned char u[], int n);
  300. void mpmov(unsigned char u[], unsigned char v[], int n);
  301. void mpmul(unsigned char w[], unsigned char u[], unsigned char v[], int n,
  302. int m);
  303. void mpneg(unsigned char u[], int n);
  304. void mppi(int n);
  305. void mprove(REAL **a, REAL **alud, int n, int indx[], REAL b[],
  306. REAL x[]);
  307. void mpsad(unsigned char w[], unsigned char u[], int n, int iv);
  308. void mpsdv(unsigned char w[], unsigned char u[], int n, int iv, int *ir);
  309. void mpsmu(unsigned char w[], unsigned char u[], int n, int iv);
  310. void mpsqrt(unsigned char w[], unsigned char u[], unsigned char v[], int n,
  311. int m);
  312. void mpsub(int *is, unsigned char w[], unsigned char u[], unsigned char v[],
  313. int n);
  314. void mrqcof(REAL x[], REAL y[], REAL sig[], int ndata, REAL a[],
  315. int ia[], int ma, REAL **alpha, REAL beta[], REAL *chisq,
  316. void (*funcs)(REAL, REAL [], REAL *, REAL [], int));
  317. void mrqmin(REAL x[], REAL y[], REAL sig[], int ndata, REAL a[],
  318. int ia[], int ma, REAL **covar, REAL **alpha, REAL *chisq,
  319. void (*funcs)(REAL, REAL [], REAL *, REAL [], int), REAL *alamda);
  320. void newt(REAL x[], int n, int *check,
  321. void (*vecfunc)(int, REAL [], REAL []));
  322. void odeint(REAL ystart[], int nvar, REAL x1, REAL x2,
  323. REAL eps, REAL h1, REAL hmin, int *nok, int *nbad,
  324. void (*derivs)(REAL, REAL [], REAL []),
  325. void (*rkqs)(REAL [], REAL [], int, REAL *, REAL, REAL,
  326. REAL [], REAL *, REAL *, void (*)(REAL, REAL [], REAL [])));
  327. void orthog(int n, REAL anu[], REAL alpha[], REAL beta[], REAL a[],
  328. REAL b[]);
  329. void pade(double cof[], int n, REAL *resid);
  330. void pccheb(REAL d[], REAL c[], int n);
  331. void pcshft(REAL a, REAL b, REAL d[], int n);
  332. void pearsn(REAL x[], REAL y[], unsigned long n, REAL *r, REAL *prob,
  333. REAL *z);
  334. void period(REAL x[], REAL y[], int n, REAL ofac, REAL hifac,
  335. REAL px[], REAL py[], int np, int *nout, int *jmax, REAL *prob);
  336. void piksr2(int n, REAL arr[], REAL brr[]);
  337. void piksrt(int n, REAL arr[]);
  338. void pinvs(int ie1, int ie2, int je1, int jsf, int jc1, int k,
  339. REAL ***c, REAL **s);
  340. REAL plgndr(int l, int m, REAL x);
  341. REAL poidev(REAL xm, long *idum);
  342. void polcoe(REAL x[], REAL y[], int n, REAL cof[]);
  343. void polcof(REAL xa[], REAL ya[], int n, REAL cof[]);
  344. void poldiv(REAL u[], int n, REAL v[], int nv, REAL q[], REAL r[]);
  345. void polin2(REAL x1a[], REAL x2a[], REAL **ya, int m, int n,
  346. REAL x1, REAL x2, REAL *y, REAL *dy);
  347. void polint(REAL xa[], REAL ya[], int n, REAL x, REAL *y, REAL *dy);
  348. void powell(REAL p[], REAL **xi, int n, REAL ftol, int *iter, REAL *fret,
  349. REAL (*func)(REAL []));
  350. void predic(REAL data[], int ndata, REAL d[], int m, REAL future[], int nfut);
  351. REAL probks(REAL alam);
  352. void psdes(unsigned long *lword, unsigned long *irword);
  353. void pwt(REAL a[], unsigned long n, int isign);
  354. void pwtset(int n);
  355. REAL pythag(REAL a, REAL b);
  356. void pzextr(int iest, REAL xest, REAL yest[], REAL yz[], REAL dy[],
  357. int nv);
  358. REAL qgaus(REAL (*func)(REAL), REAL a, REAL b);
  359. void qrdcmp(REAL **a, int n, REAL *c, REAL *d, int *sing);
  360. REAL qromb(REAL (*func)(REAL), REAL a, REAL b);
  361. REAL qromo(REAL (*func)(REAL), REAL a, REAL b,
  362. REAL (*choose)(REAL (*)(REAL), REAL, REAL, int));
  363. void qroot(REAL p[], int n, REAL *b, REAL *c, REAL eps);
  364. void qrsolv(REAL **a, int n, REAL c[], REAL d[], REAL b[]);
  365. void qrupdt(REAL **r, REAL **qt, int n, REAL u[], REAL v[]);
  366. REAL qsimp(REAL (*func)(REAL), REAL a, REAL b);
  367. REAL qtrap(REAL (*func)(REAL), REAL a, REAL b);
  368. REAL quad3d(REAL (*func)(REAL, REAL, REAL), REAL x1, REAL x2);
  369. void quadct(REAL x, REAL y, REAL xx[], REAL yy[], unsigned long nn,
  370. REAL *fa, REAL *fb, REAL *fc, REAL *fd);
  371. void quadmx(REAL **a, int n);
  372. void quadvl(REAL x, REAL y, REAL *fa, REAL *fb, REAL *fc, REAL *fd);
  373. REAL ran0(long *idum);
  374. REAL ran1(long *idum);
  375. REAL ran2(long *idum);
  376. REAL ran3(long *idum);
  377. REAL ran4(long *idum);
  378. void rank(unsigned long n, unsigned long indx[], unsigned long irank[]);
  379. void ranpt(REAL pt[], REAL regn[], int n);
  380. void ratint(REAL xa[], REAL ya[], int n, REAL x, REAL *y, REAL *dy);
  381. void ratlsq(double (*fn)(double), double a, double b, int mm, int kk,
  382. double cof[], double *dev);
  383. double ratval(double x, double cof[], int mm, int kk);
  384. REAL rc(REAL x, REAL y);
  385. REAL rd(REAL x, REAL y, REAL z);
  386. void realft(REAL data[], unsigned long n, int isign);
  387. void rebin(REAL rc, int nd, REAL r[], REAL xin[], REAL xi[]);
  388. void red(int iz1, int iz2, int jz1, int jz2, int jm1, int jm2, int jmf,
  389. int ic1, int jc1, int jcf, int kc, REAL ***c, REAL **s);
  390. void relax(double **u, double **rhs, int n);
  391. void relax2(double **u, double **rhs, int n);
  392. void resid(double **res, double **u, double **rhs, int n);
  393. REAL revcst(REAL x[], REAL y[], int iorder[], int ncity, int n[]);
  394. void reverse(int iorder[], int ncity, int n[]);
  395. REAL rf(REAL x, REAL y, REAL z);
  396. REAL rj(REAL x, REAL y, REAL z, REAL p);
  397. void rk4(REAL y[], REAL dydx[], int n, REAL x, REAL h, REAL yout[],
  398. void (*derivs)(REAL, REAL [], REAL []));
  399. void rkck(REAL y[], REAL dydx[], int n, REAL x, REAL h,
  400. REAL yout[], REAL yerr[], void (*derivs)(REAL, REAL [], REAL []));
  401. void rkdumb(REAL vstart[], int nvar, REAL x1, REAL x2, int nstep,
  402. void (*derivs)(REAL, REAL [], REAL []));
  403. void rkqs(REAL y[], REAL dydx[], int n, REAL *x,
  404. REAL htry, REAL eps, REAL yscal[], REAL *hdid, REAL *hnext,
  405. void (*derivs)(REAL, REAL [], REAL []));
  406. void rlft3(REAL ***data, REAL **speq, unsigned long nn1,
  407. unsigned long nn2, unsigned long nn3, int isign);
  408. REAL rofunc(REAL b);
  409. void rotate(REAL **r, REAL **qt, int n, int i, REAL a, REAL b);
  410. void rsolv(REAL **a, int n, REAL d[], REAL b[]);
  411. void rstrct(double **uc, double **uf, int nc);
  412. REAL rtbis(REAL (*func)(REAL), REAL x1, REAL x2, REAL xacc);
  413. REAL rtflsp(REAL (*func)(REAL), REAL x1, REAL x2, REAL xacc);
  414. REAL rtnewt(void (*funcd)(REAL, REAL *, REAL *), REAL x1, REAL x2,
  415. REAL xacc);
  416. REAL rtsafe(void (*funcd)(REAL, REAL *, REAL *), REAL x1, REAL x2,
  417. REAL xacc);
  418. REAL rtsec(REAL (*func)(REAL), REAL x1, REAL x2, REAL xacc);
  419. void rzextr(int iest, REAL xest, REAL yest[], REAL yz[], REAL dy[], int nv);
  420. void savgol(REAL c[], int np, int nl, int nr, int ld, int m);
  421. void score(REAL xf, REAL y[], REAL f[]);
  422. void scrsho(REAL (*fx)(REAL));
  423. REAL select_(unsigned long k, unsigned long n, REAL arr[]);
  424. REAL selip(unsigned long k, unsigned long n, REAL arr[]);
  425. void shell(unsigned long n, REAL a[]);
  426. void shoot(int n, REAL v[], REAL f[]);
  427. void shootf(int n, REAL v[], REAL f[]);
  428. void simp1(REAL **a, int mm, int ll[], int nll, int iabf, int *kp,
  429. REAL *bmax);
  430. void simp2(REAL **a, int n, int l2[], int nl2, int *ip, int kp, REAL *q1);
  431. void simp3(REAL **a, int i1, int k1, int ip, int kp);
  432. void simplx(REAL **a, int m, int n, int m1, int m2, int m3, int *icase,
  433. int izrov[], int iposv[]);
  434. void simpr(REAL y[], REAL dydx[], REAL dfdx[], REAL **dfdy,
  435. int n, REAL xs, REAL htot, int nstep, REAL yout[],
  436. void (*derivs)(REAL, REAL [], REAL []));
  437. void sinft(REAL y[], int n);
  438. void slvsm2(double **u, double **rhs);
  439. void slvsml(double **u, double **rhs);
  440. void sncndn(REAL uu, REAL emmc, REAL *sn, REAL *cn, REAL *dn);
  441. double snrm(unsigned long n, double sx[], int itol);
  442. void sobseq(int *n, REAL x[]);
  443. void solvde(int itmax, REAL conv, REAL slowc, REAL scalv[],
  444. int indexv[], int ne, int nb, int m, REAL **y, REAL ***c, REAL **s);
  445. void sor(double **a, double **b, double **c, double **d, double **e,
  446. double **f, double **u, int jmax, double rjac);
  447. void sort(unsigned long n, REAL arr[]);
  448. void sort2(unsigned long n, REAL arr[], REAL brr[]);
  449. void sort3(unsigned long n, REAL ra[], REAL rb[], REAL rc[]);
  450. void spctrm(FILE *fp, REAL p[], int m, int k, int ovrlap);
  451. void spear(REAL data1[], REAL data2[], unsigned long n, REAL *d, REAL *zd,
  452. REAL *probd, REAL *rs, REAL *probrs);
  453. void sphbes(int n, REAL x, REAL *sj, REAL *sy, REAL *sjp, REAL *syp);
  454. void splie2(REAL x1a[], REAL x2a[], REAL **ya, int m, int n, REAL **y2a);
  455. void splin2(REAL x1a[], REAL x2a[], REAL **ya, REAL **y2a, int m, int n,
  456. REAL x1, REAL x2, REAL *y);
  457. void spline(REAL x[], REAL y[], int n, REAL yp1, REAL ypn, REAL y2[]);
  458. void splint(REAL xa[], REAL ya[], REAL y2a[], int n, REAL x, REAL *y);
  459. void spread(REAL y, REAL yy[], unsigned long n, REAL x, int m);
  460. void sprsax(REAL sa[], unsigned long ija[], REAL x[], REAL b[],
  461. unsigned long n);
  462. void sprsin(REAL **a, int n, REAL thresh, unsigned long nmax, REAL sa[],
  463. unsigned long ija[]);
  464. void sprspm(REAL sa[], unsigned long ija[], REAL sb[], unsigned long ijb[],
  465. REAL sc[], unsigned long ijc[]);
  466. void sprstm(REAL sa[], unsigned long ija[], REAL sb[], unsigned long ijb[],
  467. REAL thresh, unsigned long nmax, REAL sc[], unsigned long ijc[]);
  468. void sprstp(REAL sa[], unsigned long ija[], REAL sb[], unsigned long ijb[]);
  469. void sprstx(REAL sa[], unsigned long ija[], REAL x[], REAL b[],
  470. unsigned long n);
  471. void stifbs(REAL y[], REAL dydx[], int nv, REAL *xx,
  472. REAL htry, REAL eps, REAL yscal[], REAL *hdid, REAL *hnext,
  473. void (*derivs)(REAL, REAL [], REAL []));
  474. void stiff(REAL y[], REAL dydx[], int n, REAL *x,
  475. REAL htry, REAL eps, REAL yscal[], REAL *hdid, REAL *hnext,
  476. void (*derivs)(REAL, REAL [], REAL []));
  477. void stoerm(REAL y[], REAL d2y[], int nv, REAL xs,
  478. REAL htot, int nstep, REAL yout[],
  479. void (*derivs)(REAL, REAL [], REAL []));
  480. void svbksb(REAL **u, REAL w[], REAL **v, int m, int n, REAL b[],
  481. REAL x[]);
  482. void svdcmp(REAL **a, int m, int n, REAL w[], REAL **v);
  483. void svdfit(REAL x[], REAL y[], REAL sig[], int ndata, REAL a[],
  484. int ma, REAL **u, REAL **v, REAL w[], REAL *chisq,
  485. void (*funcs)(REAL, REAL [], int));
  486. void svdvar(REAL **v, int ma, REAL w[], REAL **cvm);
  487. void toeplz(REAL r[], REAL x[], REAL y[], int n);
  488. void tptest(REAL data1[], REAL data2[], unsigned long n, REAL *t, REAL *prob);
  489. void tqli(REAL d[], REAL e[], int n, REAL **z);
  490. REAL trapzd(REAL (*func)(REAL), REAL a, REAL b, int n);
  491. void tred2(REAL **a, int n, REAL d[], REAL e[]);
  492. void tridag(REAL a[], REAL b[], REAL c[], REAL r[], REAL u[],
  493. unsigned long n);
  494. REAL trncst(REAL x[], REAL y[], int iorder[], int ncity, int n[]);
  495. void trnspt(int iorder[], int ncity, int n[]);
  496. void ttest(REAL data1[], unsigned long n1, REAL data2[], unsigned long n2,
  497. REAL *t, REAL *prob);
  498. void tutest(REAL data1[], unsigned long n1, REAL data2[], unsigned long n2,
  499. REAL *t, REAL *prob);
  500. void twofft(REAL data1[], REAL data2[], REAL fft1[], REAL fft2[],
  501. unsigned long n);
  502. void vander(double x[], double w[], double q[], int n);
  503. void vegas(REAL regn[], int ndim, REAL (*fxn)(REAL [], REAL), int init,
  504. unsigned long ncall, int itmx, int nprn, REAL *tgral, REAL *sd,
  505. REAL *chi2a);
  506. void voltra(int n, int m, REAL t0, REAL h, REAL *t, REAL **f,
  507. REAL (*g)(int, REAL), REAL (*ak)(int, int, REAL, REAL));
  508. void wt1(REAL a[], unsigned long n, int isign,
  509. void (*wtstep)(REAL [], unsigned long, int));
  510. void wtn(REAL a[], unsigned long nn[], int ndim, int isign,
  511. void (*wtstep)(REAL [], unsigned long, int));
  512. void wwghts(REAL wghts[], int n, REAL h,
  513. void (*kermom)(double [], double ,int));
  514. int zbrac(REAL (*func)(REAL), REAL *x1, REAL *x2);
  515. void zbrak(REAL (*fx)(REAL), REAL x1, REAL x2, int n, REAL xb1[],
  516. REAL xb2[], int *nb);
  517. REAL zbrent(REAL (*func)(REAL), REAL x1, REAL x2, REAL tol);
  518. void zrhqr(REAL a[], int m, REAL rtr[], REAL rti[]);
  519. REAL zriddr(REAL (*func)(REAL), REAL x1, REAL x2, REAL xacc);
  520. void zroots(fcomplex a[], int m, fcomplex roots[], int polish);
  521. #endif /* _NR_H_ */