Changeset 2908
- Timestamp:
- Jan 5, 2005, 10:59:03 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 2 edited
-
dataManip/psMinimize.c (modified) (16 diffs)
-
math/psMinimize.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psMinimize.c
r2788 r2908 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.9 6$ $Name: not supported by cvs2svn $12 * @date $Date: 200 4-12-22 05:09:32$11 * @version $Revision: 1.97 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-01-05 20:59:03 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 190 190 n = spline->n; 191 191 klo = p_psVectorBinDisect32(spline->domains, (spline->n)+1, X); 192 if (klo < 0) { 193 psLogMsg(__func__, PS_LOG_WARN, 194 "WARNING: psMinimize.c: p_psNRSpline1DEval(): p_psVectorBinDisect32 returned an error (%d).\n", klo); 195 return(NAN); 196 } 192 197 khi = klo + 1; 193 198 H = (spline->domains)[khi] - (spline->domains)[klo]; … … 245 250 const psVector* restrict yErr) ///< Errors in coordinates, or NULL 246 251 { 247 PS_PTR_CHECK_NULL(mySpline, NULL);248 PS_INT_CHECK_NON_NEGATIVE(mySpline->n, NULL);249 PS_VECTOR_CHECK_NULL(x, NULL);250 252 PS_VECTOR_CHECK_NULL(y, NULL); 251 253 PS_VECTOR_CHECK_TYPE_F32_OR_F64(y, NULL); … … 278 280 // If x==NULL, create an x32 vector with x values set to (0:n). 279 281 if (x == NULL) { 282 280 283 PS_VECTOR_GEN_X_INDEX_STATIC_F32(x32Static, y->n); 281 284 x32 = x32Static; … … 286 289 PS_VECTOR_CHECK_SIZE_EQUAL(x32, y32, NULL); 287 290 PS_VECTOR_CHECK_SIZE_EQUAL(yErr32, y32, NULL); 291 292 /* 293 XXX: 294 This can not be implemented until SDR states what order spline should be 295 created. 296 297 Should we error if mySPline is not NULL? 298 */ 299 if (mySpline == NULL) { 300 mySpline = psSpline1DAllocGeneric(x32, 3); 301 } 302 PS_PTR_CHECK_NULL(mySpline, NULL); 303 PS_INT_CHECK_NON_NEGATIVE(mySpline->n, NULL); 304 288 305 289 306 if (y32->n != (1 + mySpline->n)) { … … 335 352 H = x32->data.F32[i+1] - x32->data.F32[i]; 336 353 psTrace(".psLib.dataManip.psVectorFitSpline1D", 4, 337 "x data (%f - %f) (%f)\n", x->data.F32[i], x->data.F32[i+1], H); 354 "x data (%f - %f) (%f)\n", 355 x32->data.F32[i], 356 x32->data.F32[i+1], H); 338 357 // 339 358 // ******** Calculate 0-order term ******** … … 429 448 deriv = psImageAlloc(params->n, coords->n, PS_TYPE_F32); 430 449 } else { 431 // XXX: Check size of derivative 450 PS_IMAGE_CHECK_SIZE(deriv, params->n, coords->n, NULL); 451 PS_IMAGE_CHECK_TYPE(deriv, PS_TYPE_F32, NULL); 432 452 } 433 453 … … 499 519 } else { 500 520 PS_IMAGE_CHECK_SIZE(deriv, 6, coords->n, NULL); 521 PS_IMAGE_CHECK_TYPE(deriv, PS_TYPE_F32, NULL); 501 522 } 502 523 … … 715 736 // Solve A * alpha = Beta 716 737 // 738 // XXX: How do we know if these functions were successful? 739 // 717 740 aOut = psMatrixLUD(aOut, perm, A); 718 741 paramDeltasF64 = psMatrixLUSolve(paramDeltasF64, aOut, beta, perm); … … 963 986 } 964 987 988 // XXX: How do we know if these routines were successful? 965 989 ALUD = psMatrixLUD(ALUD, outPerm, A); 966 990 coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm); … … 970 994 // printf("myPoly->coeff[%d] is %f\n", k, myPoly->coeff[k]); 971 995 } 972 973 // for (i=0;i<x->n;i++) {974 // printf("HMMM: psEvalPolynomial1D(%f) is %f\n", x->data.F64[i], psEvalPolynomial1D(x->data.F64[i],975 // myPoly));976 // }977 996 978 997 psFree(A); … … 1008 1027 1009 1028 psS32 i; 1010 psPolynomial1D *tmpPoly;1011 1029 psVector *x64 = NULL; 1012 1030 psVector *y64 = NULL; … … 1044 1062 1045 1063 // Call the appropriate vector fitting routine. 1064 psPolynomial1D *rc = NULL; 1046 1065 if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1047 VectorFitPolynomial1DCheby(myPoly, x64, y64, yErr64);1066 rc = VectorFitPolynomial1DCheby(myPoly, x64, y64, yErr64); 1048 1067 } else if (myPoly->type == PS_POLYNOMIAL_ORD) { 1049 tmpPoly= VectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64);1068 rc = VectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64); 1050 1069 } else { 1051 1070 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 1052 1071 "unknown polynomial type.\n"); 1072 return(NULL); 1073 } 1074 if (rc == NULL) { 1075 psError(PS_ERR_UNKNOWN, true, "Could not fit a polynomial to the data. Returning NULL.\n"); 1053 1076 return(NULL); 1054 1077 } … … 1448 1471 if (bracket == NULL) { 1449 1472 psError(PS_ERR_UNKNOWN, false, 1450 "Could not bracket minimum. ");1473 "Could not bracket minimum. Returning NAN.\n"); 1451 1474 return(NAN); 1452 1475 } … … 1636 1659 if (isnan(mul)) { 1637 1660 psError(PS_ERR_UNKNOWN, false, 1638 "Could not perform line minimization ");1661 "Could not perform line minimization. Returning FALSE.\n"); 1639 1662 psFree(v); 1640 1663 return(false); … … 1677 1700 if (isnan(mul)) { 1678 1701 psError(PS_ERR_UNKNOWN, false, 1679 "Could not perform line minimization. ");1702 "Could not perform line minimization. Returning FALSE.\n"); 1680 1703 psFree(v); 1681 1704 return(false); -
trunk/psLib/src/math/psMinimize.c
r2788 r2908 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.9 6$ $Name: not supported by cvs2svn $12 * @date $Date: 200 4-12-22 05:09:32$11 * @version $Revision: 1.97 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-01-05 20:59:03 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 190 190 n = spline->n; 191 191 klo = p_psVectorBinDisect32(spline->domains, (spline->n)+1, X); 192 if (klo < 0) { 193 psLogMsg(__func__, PS_LOG_WARN, 194 "WARNING: psMinimize.c: p_psNRSpline1DEval(): p_psVectorBinDisect32 returned an error (%d).\n", klo); 195 return(NAN); 196 } 192 197 khi = klo + 1; 193 198 H = (spline->domains)[khi] - (spline->domains)[klo]; … … 245 250 const psVector* restrict yErr) ///< Errors in coordinates, or NULL 246 251 { 247 PS_PTR_CHECK_NULL(mySpline, NULL);248 PS_INT_CHECK_NON_NEGATIVE(mySpline->n, NULL);249 PS_VECTOR_CHECK_NULL(x, NULL);250 252 PS_VECTOR_CHECK_NULL(y, NULL); 251 253 PS_VECTOR_CHECK_TYPE_F32_OR_F64(y, NULL); … … 278 280 // If x==NULL, create an x32 vector with x values set to (0:n). 279 281 if (x == NULL) { 282 280 283 PS_VECTOR_GEN_X_INDEX_STATIC_F32(x32Static, y->n); 281 284 x32 = x32Static; … … 286 289 PS_VECTOR_CHECK_SIZE_EQUAL(x32, y32, NULL); 287 290 PS_VECTOR_CHECK_SIZE_EQUAL(yErr32, y32, NULL); 291 292 /* 293 XXX: 294 This can not be implemented until SDR states what order spline should be 295 created. 296 297 Should we error if mySPline is not NULL? 298 */ 299 if (mySpline == NULL) { 300 mySpline = psSpline1DAllocGeneric(x32, 3); 301 } 302 PS_PTR_CHECK_NULL(mySpline, NULL); 303 PS_INT_CHECK_NON_NEGATIVE(mySpline->n, NULL); 304 288 305 289 306 if (y32->n != (1 + mySpline->n)) { … … 335 352 H = x32->data.F32[i+1] - x32->data.F32[i]; 336 353 psTrace(".psLib.dataManip.psVectorFitSpline1D", 4, 337 "x data (%f - %f) (%f)\n", x->data.F32[i], x->data.F32[i+1], H); 354 "x data (%f - %f) (%f)\n", 355 x32->data.F32[i], 356 x32->data.F32[i+1], H); 338 357 // 339 358 // ******** Calculate 0-order term ******** … … 429 448 deriv = psImageAlloc(params->n, coords->n, PS_TYPE_F32); 430 449 } else { 431 // XXX: Check size of derivative 450 PS_IMAGE_CHECK_SIZE(deriv, params->n, coords->n, NULL); 451 PS_IMAGE_CHECK_TYPE(deriv, PS_TYPE_F32, NULL); 432 452 } 433 453 … … 499 519 } else { 500 520 PS_IMAGE_CHECK_SIZE(deriv, 6, coords->n, NULL); 521 PS_IMAGE_CHECK_TYPE(deriv, PS_TYPE_F32, NULL); 501 522 } 502 523 … … 715 736 // Solve A * alpha = Beta 716 737 // 738 // XXX: How do we know if these functions were successful? 739 // 717 740 aOut = psMatrixLUD(aOut, perm, A); 718 741 paramDeltasF64 = psMatrixLUSolve(paramDeltasF64, aOut, beta, perm); … … 963 986 } 964 987 988 // XXX: How do we know if these routines were successful? 965 989 ALUD = psMatrixLUD(ALUD, outPerm, A); 966 990 coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm); … … 970 994 // printf("myPoly->coeff[%d] is %f\n", k, myPoly->coeff[k]); 971 995 } 972 973 // for (i=0;i<x->n;i++) {974 // printf("HMMM: psEvalPolynomial1D(%f) is %f\n", x->data.F64[i], psEvalPolynomial1D(x->data.F64[i],975 // myPoly));976 // }977 996 978 997 psFree(A); … … 1008 1027 1009 1028 psS32 i; 1010 psPolynomial1D *tmpPoly;1011 1029 psVector *x64 = NULL; 1012 1030 psVector *y64 = NULL; … … 1044 1062 1045 1063 // Call the appropriate vector fitting routine. 1064 psPolynomial1D *rc = NULL; 1046 1065 if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1047 VectorFitPolynomial1DCheby(myPoly, x64, y64, yErr64);1066 rc = VectorFitPolynomial1DCheby(myPoly, x64, y64, yErr64); 1048 1067 } else if (myPoly->type == PS_POLYNOMIAL_ORD) { 1049 tmpPoly= VectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64);1068 rc = VectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64); 1050 1069 } else { 1051 1070 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 1052 1071 "unknown polynomial type.\n"); 1072 return(NULL); 1073 } 1074 if (rc == NULL) { 1075 psError(PS_ERR_UNKNOWN, true, "Could not fit a polynomial to the data. Returning NULL.\n"); 1053 1076 return(NULL); 1054 1077 } … … 1448 1471 if (bracket == NULL) { 1449 1472 psError(PS_ERR_UNKNOWN, false, 1450 "Could not bracket minimum. ");1473 "Could not bracket minimum. Returning NAN.\n"); 1451 1474 return(NAN); 1452 1475 } … … 1636 1659 if (isnan(mul)) { 1637 1660 psError(PS_ERR_UNKNOWN, false, 1638 "Could not perform line minimization ");1661 "Could not perform line minimization. Returning FALSE.\n"); 1639 1662 psFree(v); 1640 1663 return(false); … … 1677 1700 if (isnan(mul)) { 1678 1701 psError(PS_ERR_UNKNOWN, false, 1679 "Could not perform line minimization. ");1702 "Could not perform line minimization. Returning FALSE.\n"); 1680 1703 psFree(v); 1681 1704 return(false);
Note:
See TracChangeset
for help on using the changeset viewer.
