IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 28, 2004, 8:40:04 PM (22 years ago)
Author:
eugene
Message:

fixes for -Wall -Werror (mostly get_argument lines)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.data/mrqmin.c

    r2598 r2843  
    22
    33/* need to pass in a function of the form:
    4 
    54   funcs (x, a, Npar, dyda)
    6 
    75   returns f (x) for Npar parameters a, also df/da at x
    8 
    96   dy carries 1/sig^2
    10 
    117*/
    12 
    138
    149static float **alpha, **talpha;
     
    5247float mrqmin (float *x, float *y, float *dy, int Npts,
    5348              float *par, int Npar,
    54               float (funcs)(float, float *, int, float *)) {
     49              float (funcs)(float, float *, int, float *), int VERBOSE) {
    5550
    5651  int j, k;
     
    6661  fgaussj (talpha, Npar, tbeta, 1);
    6762
    68   /* if we keep some fixed, set partry to just them
    69      for (j = 0; j < Npar; j++) partry[j] = par[j]; */
    70 
    7163  for (j = 0; j < Npar; j++) partry[j] = par[j] - tbeta[j][0];
    7264
    7365  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  }
    7474
    7575  /* if good, save temp values */
     
    9191}
    9292
    93 int mrqinit (float *x, float *y, float *dy, int Npts,
     93float mrqinit (float *x, float *y, float *dy, int Npts,
    9494              float *par, int Npar,
    95               float (funcs)(float, float *, int, float *)) {
     95              float (funcs)(float, float *, int, float *), int VERBOSE) {
    9696
    9797  int i;
     
    109109    ALLOCATE (tbeta[i], float, Npar);
    110110  }
    111 
    112111 
    113   lambda = 0.001;
     112  lambda = 0.01;
    114113 
    115114  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);
    118124}
    119 
    120 
    121125
    122126/* don't invoke this in the middle of a run, only near the end */
    123127float **mrqcovar (int Npar) {
    124 
    125128  fgaussj (alpha, Npar, beta, 1);
    126129  return (alpha);
    127 
    128130}
    129 
    130131
    131132void mrqfree (int Npar) {
     
    145146  free (partry);
    146147  free (dyda);
    147 
    148148}
Note: See TracChangeset for help on using the changeset viewer.