IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6432


Ignore:
Timestamp:
Feb 15, 2006, 10:10:27 PM (20 years ago)
Author:
magnier
Message:

fits respect coeff masks, fixed coeff errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psLib/src/math/psMinimizePolyFit.c

    r6305 r6432  
    1010 *  @author EAM, IfA
    1111 *
    12  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-02-02 21:09:07 $
     12 *  @version $Revision: 1.7.6.1 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-02-16 08:10:27 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    810810        }
    811811        for (psS32 i = 0; i < nTerm; i++) {
     812            if (myPoly->mask[i])
     813                continue;
    812814            B->data.F64[i] += f->data.F64[k] * xSums->data.F64[i] * wt;
    813815        }
     
    816818        // we must handle masked orders
    817819        for (psS32 i = 0; i < nTerm; i++) {
     820            if (myPoly->mask[i])
     821                continue;
    818822            for (psS32 j = 0; j < nTerm; j++) {
     823                if (myPoly->mask[j])
     824                    continue;
    819825                A->data.F64[i][j] += xSums->data.F64[i + j] * wt;
    820826            }
     
    822828    }
    823829
    824     if (0) {
     830    // set masked elements in A,B appropriately
     831    for (int i = 0; i < nTerm; i++) {
     832        if (!myPoly->mask[i])
     833            continue;
     834        B->data.F64[i] = 0;
     835        for (int j = 0; j < nTerm; j++) {
     836            A->data.F64[i][j] = (i == j) ? 1 : 0;
     837        }
     838    }
     839
     840
     841    if (1) {
    825842        // GaussJordan version
    826843        if (false == psGaussJordan(A, B)) {
     
    833850            for (psS32 k = 0; k < nTerm; k++) {
    834851                myPoly->coeff[k] = B->data.F64[k];
     852                myPoly->coeffErr[k] = sqrt(A->data.F64[k][k]);
    835853            }
    836854        }
     
    857875                for (psS32 k = 0; k < nTerm; k++) {
    858876                    myPoly->coeff[k] = coeffs->data.F64[k];
     877                    // XXX LUD does not give inverse of A
    859878                }
    860879            }
     
    12361255        for (psS32 n = 0; n < nXterm; n++) {
    12371256            for (psS32 m = 0; m < nYterm; m++) {
     1257                if (myPoly->mask[n][m])
     1258                    continue;
    12381259                B->data.F64[n+m*nXterm] += f->data.F64[k] * Sums->data.F64[n][m] * wt;
    12391260            }
     
    12421263        for (psS32 i = 0; i < nXterm; i++) {
    12431264            for (psS32 j = 0; j < nYterm; j++) {
     1265                if (myPoly->mask[i][j])
     1266                    continue;
    12441267                for (psS32 n = 0; n < nXterm; n++) {
    12451268                    for (psS32 m = 0; m < nYterm; m++) {
     1269                        if (myPoly->mask[n][m])
     1270                            continue;
    12461271                        A->data.F64[i+j*nXterm][n+m*nXterm] += Sums->data.F64[i+n][j+m] * wt;
    12471272                    }
     1273                }
     1274            }
     1275        }
     1276    }
     1277
     1278    // set masked elements appropriately
     1279    for (int i = 0; i < nXterm; i++) {
     1280        for (int j = 0; j < nYterm; j++) {
     1281            if (!myPoly->mask[i][j])
     1282                continue;
     1283            int nx = i+j*nXterm;
     1284            B->data.F64[nx] = 0;
     1285            for (int n = 0; n < nXterm; n++) {
     1286                for (int m = 0; m < nYterm; m++) {
     1287                    int ny = n+m*nXterm;
     1288                    A->data.F64[nx][ny] = (nx == ny) ? 1 : 0;
    12481289                }
    12491290            }
     
    12601301            for (psS32 m = 0; m < nYterm; m++) {
    12611302                myPoly->coeff[n][m] = B->data.F64[n+m*nXterm];
     1303                myPoly->coeffErr[n][m] = sqrt(A->data.F64[n+m*nXterm][n+m*nXterm]);
    12621304            }
    12631305        }
     
    17121754    }
    17131755
    1714     if (0) {
     1756    if (1) {
    17151757        // does the solution in place
    17161758        // The matrices were overflowing, so I switched to LUD.
     
    17641806                            psS32 nx = ix+iy*nXterm+iz*nXterm*nYterm;
    17651807                            myPoly->coeff[ix][iy][iz] = coeffs->data.F64[nx];
    1766                             myPoly->coeffErr[ix][iy][iz] = sqrt(A->data.F64[nx][nx]);
     1808                            // XXX myPoly->coeffErr[ix][iy][iz] = sqrt(A->data.F64[nx][nx]);
     1809                            // XXX this is wrong: A is not replaced with inverse(A), as for GaussJordan
    17671810                        }
    17681811                    }
     
    22652308
    22662309
    2267     if (0) {
     2310    if (1) {
    22682311        // does the solution in place
    22692312        // The GaussJordan version was overflowing, so I'm using LUD.
     
    23232366                                psS32 nx = ix+iy*nXterm+iz*nXterm*nYterm+it*nXterm*nYterm*nZterm;
    23242367                                myPoly->coeff[ix][iy][iz][it] = coeffs->data.F64[nx];
    2325                                 myPoly->coeffErr[ix][iy][iz][it] = sqrt(A->data.F64[nx][nx]);
     2368                                // myPoly->coeffErr[ix][iy][iz][it] = sqrt(A->data.F64[nx][nx]);
     2369                                // XXX this is wrong: LUD does not supply inverse(A)
    23262370                            }
    23272371                        }
Note: See TracChangeset for help on using the changeset viewer.