Changeset 2843 for trunk/Ohana/src/opihi/lib.data/mrqmin.c
- Timestamp:
- Dec 28, 2004, 8:40:04 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.data/mrqmin.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.data/mrqmin.c
r2598 r2843 2 2 3 3 /* need to pass in a function of the form: 4 5 4 funcs (x, a, Npar, dyda) 6 7 5 returns f (x) for Npar parameters a, also df/da at x 8 9 6 dy carries 1/sig^2 10 11 7 */ 12 13 8 14 9 static float **alpha, **talpha; … … 52 47 float mrqmin (float *x, float *y, float *dy, int Npts, 53 48 float *par, int Npar, 54 float (funcs)(float, float *, int, float *) ) {49 float (funcs)(float, float *, int, float *), int VERBOSE) { 55 50 56 51 int j, k; … … 66 61 fgaussj (talpha, Npar, tbeta, 1); 67 62 68 /* if we keep some fixed, set partry to just them69 for (j = 0; j < Npar; j++) partry[j] = par[j]; */70 71 63 for (j = 0; j < Npar; j++) partry[j] = par[j] - tbeta[j][0]; 72 64 73 65 chisq = mrqcof (x, y, dy, Npts, partry, Npar, talpha, tbeta, funcs); 66 if (VERBOSE) { 67 fprintf (stderr, "chisq: %f ", chisq); 68 fprintf (stderr, "lambda: %f ", lambda); 69 for (j = 0; j < Npar; j++) { 70 fprintf (stderr, "%f ", partry[j]); 71 } 72 fprintf (stderr, "\n"); 73 } 74 74 75 75 /* if good, save temp values */ … … 91 91 } 92 92 93 int mrqinit (float *x, float *y, float *dy, int Npts,93 float mrqinit (float *x, float *y, float *dy, int Npts, 94 94 float *par, int Npar, 95 float (funcs)(float, float *, int, float *) ) {95 float (funcs)(float, float *, int, float *), int VERBOSE) { 96 96 97 97 int i; … … 109 109 ALLOCATE (tbeta[i], float, Npar); 110 110 } 111 112 111 113 lambda = 0.0 01;112 lambda = 0.01; 114 113 115 114 ochisq = mrqcof (x, y, dy, Npts, par, Npar, alpha, beta, funcs); 116 117 return (TRUE); 115 if (VERBOSE) { 116 fprintf (stderr, "chisq: %f ", ochisq); 117 fprintf (stderr, "lambda: %f ", lambda); 118 for (i = 0; i < Npar; i++) { 119 fprintf (stderr, "%f ", par[i]); 120 } 121 fprintf (stderr, "\n"); 122 } 123 return (ochisq); 118 124 } 119 120 121 125 122 126 /* don't invoke this in the middle of a run, only near the end */ 123 127 float **mrqcovar (int Npar) { 124 125 128 fgaussj (alpha, Npar, beta, 1); 126 129 return (alpha); 127 128 130 } 129 130 131 131 132 void mrqfree (int Npar) { … … 145 146 free (partry); 146 147 free (dyda); 147 148 148 }
Note:
See TracChangeset
for help on using the changeset viewer.
