Changeset 5823
- Timestamp:
- Dec 20, 2005, 2:27:18 PM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 1 added
- 1 edited
-
src/math/psMinimize.c (modified) (4 diffs)
-
test/math/tst_psPolyFit4DOrd.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psMinimize.c
r5819 r5823 10 10 * @author EAM, IfA 11 11 * 12 * @version $Revision: 1.1 49$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-12-2 0 23:53:03$12 * @version $Revision: 1.150 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-12-21 00:27:18 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 3347 3347 } 3348 3348 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]); 3358 3362 } 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 } 3376 3379 } 3377 3380 } 3378 3381 } 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 3379 3409 } 3380 3410 … … 3469 3499 PS_ASSERT_VECTORS_SIZE_EQUAL(f, z, NULL); 3470 3500 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); 3472 3502 } else { 3473 3503 z64 = (psVector *) z; … … 3480 3510 PS_ASSERT_VECTORS_SIZE_EQUAL(f, t, NULL); 3481 3511 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); 3483 3513 } else { 3484 3514 t64 = (psVector *) t;
Note:
See TracChangeset
for help on using the changeset viewer.
