IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5823


Ignore:
Timestamp:
Dec 20, 2005, 2:27:18 PM (21 years ago)
Author:
gusciora
Message:

I've incorporated the 4D polynomial fitting routines from EAM into the CVS
tree and added fairly simple tests. I changed from GaussJordan to LUD since
the former was overflowing.

Location:
trunk/psLib
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psMinimize.c

    r5819 r5823  
    1010 *  @author EAM, IfA
    1111 *
    12  *  @version $Revision: 1.149 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-12-20 23:53:03 $
     12 *  @version $Revision: 1.150 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-12-21 00:27:18 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    33473347    }
    33483348
    3349     // does the solution in place
    3350 
    3351     if (false == psGaussJordan(A, B)) {
    3352         psFree(A);
    3353         psFree(B);
    3354         for (int ix = 0; ix < 2*nXterm; ix++) {
    3355             for (int iy = 0; iy < 2*nYterm; iy++) {
    3356                 for (int iz = 0; iz < 2*nZterm; iz++) {
    3357                     psFree(Sums[ix][iy][iz]);
     3349
     3350    if (0) {
     3351        // does the solution in place
     3352        // XXX: The GaussJordan version was overflowing, so I'm using LUD.
     3353        if (false == psGaussJordan(A, B)) {
     3354            psFree(A);
     3355            psFree(B);
     3356            for (int ix = 0; ix < 2*nXterm; ix++) {
     3357                for (int iy = 0; iy < 2*nYterm; iy++) {
     3358                    for (int iz = 0; iz < 2*nZterm; iz++) {
     3359                        psFree(Sums[ix][iy][iz]);
     3360                    }
     3361                    psFree(Sums[ix][iy]);
    33583362                }
    3359                 psFree(Sums[ix][iy]);
    3360             }
    3361             psFree(Sums[ix]);
    3362         }
    3363         psFree(Sums);
    3364         psError(PS_ERR_UNKNOWN, false, "Failed to perform GaussJordan elimination.\n");
    3365         return(NULL);
    3366     }
    3367 
    3368     // select the appropriate solution entries
    3369     for (int ix = 0; ix < nXterm; ix++) {
    3370         for (int iy = 0; iy < nYterm; iy++) {
    3371             for (int iz = 0; iz < nZterm; iz++) {
    3372                 for (int it = 0; it < nTterm; it++) {
    3373                     int nx = ix+iy*nXterm+iz*nXterm*nYterm+it*nXterm*nYterm*nZterm;
    3374                     myPoly->coeff[ix][iy][iz][it] = B->data.F64[nx];
    3375                     myPoly->coeffErr[ix][iy][iz][it] = sqrt(A->data.F64[nx][nx]);
     3363                psFree(Sums[ix]);
     3364            }
     3365            psFree(Sums);
     3366            psError(PS_ERR_UNKNOWN, false, "Failed to perform GaussJordan elimination.\n");
     3367            return(NULL);
     3368        }
     3369
     3370        // select the appropriate solution entries
     3371        for (int ix = 0; ix < nXterm; ix++) {
     3372            for (int iy = 0; iy < nYterm; iy++) {
     3373                for (int iz = 0; iz < nZterm; iz++) {
     3374                    for (int it = 0; it < nTterm; it++) {
     3375                        int nx = ix+iy*nXterm+iz*nXterm*nYterm+it*nXterm*nYterm*nZterm;
     3376                        myPoly->coeff[ix][iy][iz][it] = B->data.F64[nx];
     3377                        myPoly->coeffErr[ix][iy][iz][it] = sqrt(A->data.F64[nx][nx]);
     3378                    }
    33763379                }
    33773380            }
    33783381        }
     3382    } else {
     3383        // LUD version of the fit
     3384        psImage *ALUD = NULL;
     3385        psVector* outPerm = NULL;
     3386        psVector* coeffs = NULL;
     3387
     3388        ALUD = psImageAlloc(nTerm, nTerm, PS_TYPE_F64);
     3389        ALUD = psMatrixLUD(ALUD, &outPerm, A);
     3390        coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm);
     3391
     3392        // select the appropriate solution entries
     3393        for (int ix = 0; ix < nXterm; ix++) {
     3394            for (int iy = 0; iy < nYterm; iy++) {
     3395                for (int iz = 0; iz < nZterm; iz++) {
     3396                    for (int it = 0; it < nTterm; it++) {
     3397                        int nx = ix+iy*nXterm+iz*nXterm*nYterm+it*nXterm*nYterm*nZterm;
     3398                        myPoly->coeff[ix][iy][iz][it] = coeffs->data.F64[nx];
     3399                        myPoly->coeffErr[ix][iy][iz][it] = sqrt(A->data.F64[nx][nx]);
     3400                    }
     3401                }
     3402            }
     3403        }
     3404
     3405        psFree(ALUD);
     3406        psFree(coeffs);
     3407        psFree(outPerm);
     3408
    33793409    }
    33803410
     
    34693499    PS_ASSERT_VECTORS_SIZE_EQUAL(f, z, NULL);
    34703500    if (z->type.type != PS_TYPE_F64) {
    3471         PS_VECTOR_GEN_F64_FROM_F32(y64, z);
     3501        PS_VECTOR_GEN_F64_FROM_F32(z64, z);
    34723502    } else {
    34733503        z64 = (psVector *) z;
     
    34803510    PS_ASSERT_VECTORS_SIZE_EQUAL(f, t, NULL);
    34813511    if (t->type.type != PS_TYPE_F64) {
    3482         PS_VECTOR_GEN_F64_FROM_F32(y64, t);
     3512        PS_VECTOR_GEN_F64_FROM_F32(t64, t);
    34833513    } else {
    34843514        t64 = (psVector *) t;
Note: See TracChangeset for help on using the changeset viewer.