IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8301


Ignore:
Timestamp:
Aug 11, 2006, 4:58:18 PM (20 years ago)
Author:
eugene
Message:

moved gaussj to libohana

Location:
trunk/Ohana/src
Files:
1 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/misc/src/fitdist.c

    r7080 r8301  
    626626 
    627627}
    628 
    629 
    630 /***************************************************************************/
    631 
    632 int
    633 gaussj (a, n, b, m)
    634 double **a, **b;
    635 int n,m;
    636 {
    637   int *indxc,*indxr,*ipiv;
    638   int i, icol, irow, j, k, l, ll, status;
    639   double big,dum,pivinv;
    640  
    641   ALLOCATE (indxc, int, n);
    642   ALLOCATE (indxr, int, n);
    643   ALLOCATE (ipiv, int, n);
    644   for (j = 0; j < n; j++)
    645     ipiv[j] = 0;
    646  
    647   for (i = 0; i < n; i++) {
    648     big = 0.0;
    649     for (j = 0; j < n; j++) {
    650       if (ipiv[j] != 1) {
    651         for (k = 0; k < n; k++) {
    652           if (ipiv[k] == 0) {
    653             if (fabs (a[j][k]) >= big) {
    654               big  = fabs (a[j][k]);
    655               irow = j;
    656               icol = k;
    657             }
    658           }
    659           else
    660             if (ipiv[k] > 1) {
    661               fprintf (stderr, "GAUSSJ: Singular Matrix! (1)\n");
    662               return (0);
    663             }
    664         }
    665       }
    666     }
    667     ipiv[icol]++;
    668     if (irow != icol) {
    669       for (l = 0; l < n; l++)
    670         SWAP (a[irow][l], a[icol][l]);
    671       for (l = 0; l < m; l++)
    672         SWAP (b[irow][l], b[icol][l]);
    673     }
    674     indxr[i] = irow;
    675     indxc[i] = icol;
    676     if (a[icol][icol] == 0.0) {
    677       fprintf (stderr, "GAUSSJ: Singular Matrix! (2)\n");
    678       return (0);
    679     }
    680     pivinv = 1.0 / a[icol][icol];
    681     a[icol][icol] = 1.0;
    682     for (l = 0; l < n; l++)
    683       a[icol][l] *= pivinv;
    684     for (l = 0; l < m; l++)
    685       b[icol][l] *= pivinv;
    686     for (ll = 0; ll < n; ll++) {
    687       if (ll != icol) {
    688         dum = a[ll][icol];
    689         a[ll][icol] = 0.0;
    690         for (l = 0; l < n; l++)
    691           a[ll][l] -= a[icol][l]*dum;
    692         for (l = 0; l < m; l++)
    693           b[ll][l] -= b[icol][l]*dum;
    694       }
    695     }
    696   }
    697  
    698   for (l = n - 1; l >= 0; l--) {
    699     if (indxr[l] != indxc[l])
    700       for (k = 0; k < n; k++)
    701         SWAP (a[k][indxr[l]], a[k][indxc[l]]);
    702   }
    703   free (ipiv);
    704   free (indxr);
    705   free (indxc);
    706   return (1);
    707 }
    708  
  • trunk/Ohana/src/misc/src/list_astro.c

    r2417 r8301  
    9797  RA = R/N - RX*x/N - RY*y/N;
    9898
    99 /*
    100   gaussj (a, 4, b, 1);
    101 
    102   RA = b[0][0];
    103   RX = b[1][0];
    104   RY = b[2][0];
    105   RX2 = b[3][0];
    106 */
    107  
    10899  DX  = (Sdx*Sy2 - Sdy*Sxy) / (Sx2*Sy2 - Sxy*Sxy);
    109100  DY  = (Sdy*Sx2 - Sdx*Sxy) / (Sx2*Sy2 - Sxy*Sxy);
     
    125116  exit (0);
    126117}
    127 
    128 
    129 int gaussj (double **a, int n, double **b, int m) {
    130 
    131   int *indxc,*indxr,*ipiv;
    132   int i, icol, irow, j, k, l, ll;
    133   double big,dum,pivinv;
    134  
    135   ALLOCATE (indxc, int, n);
    136   ALLOCATE (indxr, int, n);
    137   ALLOCATE (ipiv, int, n);
    138   for (j = 0; j < n; j++)
    139     ipiv[j] = 0;
    140 
    141   for (i = 0; i < n; i++) {
    142     big = 0.0;
    143     for (j = 0; j < n; j++) {
    144       if (ipiv[j] != 1) {
    145         for (k = 0; k < n; k++) {
    146           if (ipiv[k] == 0) {
    147             if (fabs (a[j][k]) >= big) {
    148               big  = fabs (a[j][k]);
    149               irow = j;
    150               icol = k;
    151             }
    152           }
    153           else
    154             if (ipiv[k] > 1) {
    155               fprintf (stderr, "GAUSSJ: Singular Matrix! (1)\n");
    156               return (0);
    157             }
    158         }
    159       }
    160     }
    161     ipiv[icol]++;
    162     if (irow != icol) {
    163       for (l = 0; l < n; l++)
    164         SWAP (a[irow][l], a[icol][l]);
    165       for (l = 0; l < m; l++)
    166         SWAP (b[irow][l], b[icol][l]);
    167     }
    168     indxr[i] = irow;
    169     indxc[i] = icol;
    170     if (a[icol][icol] == 0.0) {
    171       fprintf (stderr, "GAUSSJ: Singular Matrix! (2)\n");
    172       return (0);
    173     }
    174     pivinv = 1.0 / a[icol][icol];
    175     a[icol][icol] = 1.0;
    176     for (l = 0; l < n; l++)
    177       a[icol][l] *= pivinv;
    178     for (l = 0; l < m; l++)
    179       b[icol][l] *= pivinv;
    180     for (ll = 0; ll < n; ll++) {
    181       if (ll != icol) {
    182         dum = a[ll][icol];
    183         a[ll][icol] = 0.0;
    184         for (l = 0; l < n; l++)
    185           a[ll][l] -= a[icol][l]*dum;
    186         for (l = 0; l < m; l++)
    187           b[ll][l] -= b[icol][l]*dum;
    188       }
    189     }
    190   }
    191 
    192   for (l = n - 1; l >= 0; l--) {
    193     if (indxr[l] != indxc[l])
    194       for (k = 0; k < n; k++)
    195         SWAP (a[k][indxr[l]], a[k][indxc[l]]);
    196   }
    197   free (ipiv);
    198   free (indxr);
    199   free (indxc);
    200   return (1);
    201 }
    202 
  • trunk/Ohana/src/misc/src/mosastro.c

    r3466 r8301  
    1818int mrqinit (int *index, int Npts, double *par, int Npar,                             double (funcs)(int, double *, int, double *));
    1919int mrqfree (int Npar);
    20 int gaussj (double **a, int n, double **b, int m);
    2120int fit (double *X, double *Y, int N, double *A, double *B);
    2221
  • trunk/Ohana/src/mosastro/Makefile

    r6242 r8301  
    5252$(SRC)/output.$(ARCH).o \
    5353$(SRC)/wstars.$(ARCH).o \
    54 $(SRC)/gaussj.$(ARCH).o \
    5554$(SRC)/mkpolyterm.$(ARCH).o \
    5655$(SRC)/mkmosaic.$(ARCH).o \
  • trunk/Ohana/src/mosastro/src/GetGradients.c

    r3323 r8301  
    9090
    9191        if (Npts < 5) continue;
    92         if (!gaussj (a, 3, b, 2)) continue;
     92        if (!dgaussj (a, 3, b, 2)) continue;
    9393
    9494        /* we only care about the slopes, not the offsets */
  • trunk/Ohana/src/mosastro/src/fitpoly.c

    r3401 r8301  
    109109# endif
    110110
    111   gaussj (matrix, NPARS, vector, 2);
     111  dgaussj (matrix, NPARS, vector, 2);
    112112
    113113# if (0)
Note: See TracChangeset for help on using the changeset viewer.