Astro-PAL

 view release on metacpan or  search on metacpan

palsrc/palFitxy.c  view on Meta::CPAN

*     Boston, MA  02110-1301  USA
*-
*/

#include "pal.h"

void palFitxy ( int itype, int np, double xye[][2], double xym[][2],
                double coeffs[6], int *j) {

  int i, jstat, iw[4], nsol;
  double a, b, c, d, aold, bold, cold, dold, sold,
    p, sxe, sxexm, sxeym, sye, syeym, syexm, sxm,
    sym, sxmxm, sxmym, symym, xe, ye,
    xm, ym, v[4], dm3[3][3], dm4[4][4], det,
    sgn, sxxyy, sxyyx, sx2y2, sdr2, xr, yr;

  /* Preset the status */
  *j = 0;

  /* Variable initializations to avoid compiler warnings */
  a = 0.0;
  b = 0.0;
  c = 0.0;
  d = 0.0;
  aold = 0.0;
  bold = 0.0;
  cold = 0.0;
  dold = 0.0;
  sold = 0.0;

  /* Float the number of samples */
  p = (double) np;

  /* Check ITYPE */
  if (itype == 6) {
    /* Six-coefficient linear model */

palsrc/palFitxy.c  view on Meta::CPAN

          }

        } else {
          /* Singular: set flag */
          sdr2 = -1.0;
        }

        /* If first pass and non-singular, save variables */
        if (nsol == 0 && jstat == 0) {
          aold = a;
          bold = b;
          cold = c;
          dold = d;
          sold = sdr2;
        }
      }

      /* Pick the best of the two solutions */
      if (sold >= 0.0 && (sold <= sdr2 || np == 2)) {
        coeffs[0] = aold;
        coeffs[1] = bold;
        coeffs[2] = -cold;
        coeffs[3] = dold;
        coeffs[4] = cold;
        coeffs[5] = bold;
      } else if (jstat == 0) {
        coeffs[0] = -a;
        coeffs[1] = -b;
        coeffs[2] = c;
        coeffs[3] = d;
        coeffs[4] = c;
        coeffs[5] = b;
      } else {
        /* No 4-coefficient fit possible */
        *j = -3;



( run in 2.417 seconds using v1.01-cache-2.11-cpan-5dc5da66d9d )