Changeset 8245 for trunk/psLib/src/math/psMinimizePolyFit.c
- Timestamp:
- Aug 8, 2006, 4:26:44 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psMinimizePolyFit.c (modified) (42 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psMinimizePolyFit.c
r7766 r8245 10 10 * @author EAM, IfA 11 11 * 12 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-0 6-30 02:20:06$12 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-08-09 02:26:44 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 470 470 const psVector *x) 471 471 { 472 psTrace( __func__, 4, "---- %s() begin ----\n", __func__);472 psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__); 473 473 PS_ASSERT_POLY_NON_NULL(myPoly, NULL); 474 474 PS_ASSERT_VECTOR_NON_NULL(f, NULL); … … 488 488 489 489 if (psTraceGetLevel(__func__) >= 6) { 490 psTrace( __func__, 6, "VectorFitPolynomial1D()\n");490 psTrace("psLib.math", 6, "VectorFitPolynomial1D()\n"); 491 491 for (psS32 i = 0; i < f->n; i++) { 492 psTrace( __func__, 6, "(x, f, fErr) is (");492 psTrace("psLib.math", 6, "(x, f, fErr) is ("); 493 493 if (x != NULL) { 494 psTrace( __func__, 6, "%f, %f, ", x->data.F64[i], f->data.F64[i]);494 psTrace("psLib.math", 6, "%f, %f, ", x->data.F64[i], f->data.F64[i]); 495 495 } else { 496 psTrace( __func__, 6, "%f, %f, ", (psF64) i, f->data.F64[i]);496 psTrace("psLib.math", 6, "%f, %f, ", (psF64) i, f->data.F64[i]); 497 497 } 498 498 if (fErr != NULL) { 499 psTrace( __func__, 6, "%f)\n", fErr->data.F64[i]);499 psTrace("psLib.math", 6, "%f)\n", fErr->data.F64[i]); 500 500 } else { 501 psTrace( __func__, 6, "NULL)\n");501 psTrace("psLib.math", 6, "NULL)\n"); 502 502 } 503 503 } … … 516 516 psFree(A); 517 517 psFree(B); 518 psTrace( __func__, 4, "---- %s() End ----\n", __func__);518 psTrace("psLib.math", 4, "---- %s() End ----\n", __func__); 519 519 return(NULL); 520 520 } … … 645 645 psFree(B); 646 646 647 psTrace( __func__, 4, "---- %s() End ----\n", __func__);647 psTrace("psLib.math", 4, "---- %s() End ----\n", __func__); 648 648 return (myPoly); 649 649 } … … 754 754 const psVector *xIn) 755 755 { 756 psTrace( __func__, 3, "---- %s() begin ----\n", __func__);756 psTrace("psLib.math", 3, "---- %s() begin ----\n", __func__); 757 757 PS_ASSERT_POLY_NON_NULL(poly, NULL); 758 758 PS_ASSERT_PTR_NON_NULL(stats, NULL); … … 811 811 // for now, for the SAMPLE_MEDIAN and SAMPLE_STDEV to be used 812 812 stats->options |= (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 813 psTrace( __func__, 4, "stats->clipIter is %d\n", stats->clipIter);814 psTrace( __func__, 4, "(minClipSigma, maxClipSigma) is (%.2f, %.2f)\n", minClipSigma, maxClipSigma);813 psTrace("psLib.math", 4, "stats->clipIter is %d\n", stats->clipIter); 814 psTrace("psLib.math", 4, "(minClipSigma, maxClipSigma) is (%.2f, %.2f)\n", minClipSigma, maxClipSigma); 815 815 816 816 // 817 817 for (psS32 N = 0; N < stats->clipIter; N++) { 818 psTrace( __func__, 6, "Loop iteration %d. Calling psVectorFitPolynomial1D()\n");818 psTrace("psLib.math", 6, "Loop iteration %d. Calling psVectorFitPolynomial1D()\n"); 819 819 psS32 Nkeep = 0; 820 820 if (psTraceGetLevel(__func__) >= 6) { 821 821 if (mask != NULL) { 822 822 for (psS32 i = 0 ; i < mask->n ; i++) { 823 psTrace( __func__, 6, "mask[%d] is %d\n", i, mask->data.U8[i]);823 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data.U8[i]); 824 824 } 825 825 } … … 851 851 for (psS32 i = 0 ; i < mask->n ; i++) { 852 852 if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) { 853 psTrace( __func__, 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n",853 psTrace("psLib.math", 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n", 854 854 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); 855 855 } … … 859 859 860 860 stats = psVectorStats(stats, resid, NULL, mask, maskValue); 861 psTrace( __func__, 6, "Median is %f\n", stats->sampleMedian);862 psTrace( __func__, 6, "Stdev is %f\n", stats->sampleStdev);861 psTrace("psLib.math", 6, "Median is %f\n", stats->sampleMedian); 862 psTrace("psLib.math", 6, "Stdev is %f\n", stats->sampleStdev); 863 863 psF32 minClipValue = -minClipSigma*stats->sampleStdev; 864 864 psF32 maxClipValue = +maxClipSigma*stats->sampleStdev; … … 875 875 (resid->data.F64[i] - stats->sampleMedian < minClipValue)) { 876 876 if (f->type.type == PS_TYPE_F64) { 877 psTrace( __func__, 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n",877 psTrace("psLib.math", 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n", 878 878 i, fit->data.F64[i], i, resid->data.F64[i]); 879 879 } else { 880 psTrace( __func__, 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n",880 psTrace("psLib.math", 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n", 881 881 i, fit->data.F32[i], i, resid->data.F64[i]); 882 882 } … … 894 894 // since the polynomial fit won't change. 895 895 // 896 psTrace( __func__, 6, "keeping %d of %d pts for fit\n", Nkeep, x->n);896 psTrace("psLib.math", 6, "keeping %d of %d pts for fit\n", Nkeep, x->n); 897 897 psFree(fit); 898 898 } … … 905 905 psFree(resid); 906 906 907 psTrace( __func__, 3, "---- %s() end ----\n", __func__);907 psTrace("psLib.math", 3, "---- %s() end ----\n", __func__); 908 908 return (poly); 909 909 } … … 931 931 const psVector *y) 932 932 { 933 psTrace( __func__, 4, "---- %s() begin ----\n", __func__);933 psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__); 934 934 PS_ASSERT_POLY_NON_NULL(myPoly, NULL); 935 935 PS_ASSERT_INT_NONNEGATIVE(myPoly->nX, NULL); … … 967 967 psFree(A); 968 968 psFree(B); 969 psTrace( __func__, 4, "---- %s() End ----\n", __func__);969 psTrace("psLib.math", 4, "---- %s() End ----\n", __func__); 970 970 return(NULL); 971 971 } … … 1045 1045 psFree(B); 1046 1046 1047 psTrace( __func__, 4, "---- %s() end ----\n", __func__);1047 psTrace("psLib.math", 4, "---- %s() end ----\n", __func__); 1048 1048 return (myPoly); 1049 1049 } … … 1201 1201 const psVector *y) 1202 1202 { 1203 psTrace( __func__, 3, "---- %s() begin ----\n", __func__);1203 psTrace("psLib.math", 3, "---- %s() begin ----\n", __func__); 1204 1204 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1205 1205 PS_ASSERT_POLY_TYPE(poly, PS_POLYNOMIAL_ORD, NULL); … … 1246 1246 // for now, for the SAMPLE_MEDIAN and SAMPLE_STDEV to be used 1247 1247 stats->options |= (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 1248 psTrace( __func__, 4, "stats->clipIter is %d\n", stats->clipIter);1249 psTrace( __func__, 4, "(minClipSigma, maxClipSigma) is (%.2f, %.2f)\n", minClipSigma, maxClipSigma);1248 psTrace("psLib.math", 4, "stats->clipIter is %d\n", stats->clipIter); 1249 psTrace("psLib.math", 4, "(minClipSigma, maxClipSigma) is (%.2f, %.2f)\n", minClipSigma, maxClipSigma); 1250 1250 1251 1251 for (psS32 N = 0; N < stats->clipIter; N++) { 1252 psTrace( __func__, 6, "Loop iteration %d. Calling psVectorFitPolynomial1D()\n");1252 psTrace("psLib.math", 6, "Loop iteration %d. Calling psVectorFitPolynomial1D()\n"); 1253 1253 psS32 Nkeep = 0; 1254 1254 if (psTraceGetLevel(__func__) >= 6) { 1255 1255 if (mask != NULL) { 1256 1256 for (psS32 i = 0 ; i < mask->n ; i++) { 1257 psTrace( __func__, 6, "mask[%d] is %d\n", i, mask->data.U8[i]);1257 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data.U8[i]); 1258 1258 } 1259 1259 } … … 1286 1286 for (psS32 i = 0 ; i < mask->n ; i++) { 1287 1287 if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) { 1288 psTrace( __func__, 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n",1288 psTrace("psLib.math", 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n", 1289 1289 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); 1290 1290 } … … 1300 1300 return(NULL); 1301 1301 } 1302 psTrace( __func__, 6, "Median is %f\n", stats->sampleMedian);1303 psTrace( __func__, 6, "Stdev is %f\n", stats->sampleStdev);1302 psTrace("psLib.math", 6, "Median is %f\n", stats->sampleMedian); 1303 psTrace("psLib.math", 6, "Stdev is %f\n", stats->sampleStdev); 1304 1304 psF32 minClipValue = -minClipSigma*stats->sampleStdev; 1305 1305 psF32 maxClipValue = +maxClipSigma*stats->sampleStdev; … … 1316 1316 (resid->data.F64[i] - stats->sampleMedian < minClipValue)) { 1317 1317 if (fit->type.type == PS_TYPE_F64) { 1318 psTrace( __func__, 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n",1318 psTrace("psLib.math", 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n", 1319 1319 i, fit->data.F64[i], i, resid->data.F64[i]); 1320 1320 } else { 1321 psTrace( __func__, 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n",1321 psTrace("psLib.math", 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n", 1322 1322 i, fit->data.F32[i], i, resid->data.F64[i]); 1323 1323 } … … 1331 1331 } 1332 1332 1333 psTrace( __func__, 6, "keeping %d of %d pts for fit\n", Nkeep, x->n);1333 psTrace("psLib.math", 6, "keeping %d of %d pts for fit\n", Nkeep, x->n); 1334 1334 psFree(fit); 1335 1335 } … … 1342 1342 } 1343 1343 1344 psTrace( __func__, 3, "---- %s() end ----\n", __func__);1344 psTrace("psLib.math", 3, "---- %s() end ----\n", __func__); 1345 1345 return(poly); 1346 1346 } … … 1369 1369 const psVector *z) 1370 1370 { 1371 psTrace( __func__, 4, "---- %s() begin ----\n", __func__);1371 psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__); 1372 1372 PS_ASSERT_POLY_NON_NULL(myPoly, NULL); 1373 1373 PS_ASSERT_INT_NONNEGATIVE(myPoly->nX, NULL); … … 1411 1411 psFree(A); 1412 1412 psFree(B); 1413 psTrace( __func__, 4, "---- %s() End ----\n", __func__);1413 psTrace("psLib.math", 4, "---- %s() End ----\n", __func__); 1414 1414 return(NULL); 1415 1415 } … … 1543 1543 psFree(B); 1544 1544 1545 psTrace( __func__, 4, "---- %s() end ----\n", __func__);1545 psTrace("psLib.math", 4, "---- %s() end ----\n", __func__); 1546 1546 return (myPoly); 1547 1547 } … … 1716 1716 const psVector *z) 1717 1717 { 1718 psTrace( __func__, 3, "---- %s() begin ----\n", __func__);1718 psTrace("psLib.math", 3, "---- %s() begin ----\n", __func__); 1719 1719 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1720 1720 PS_ASSERT_POLY_TYPE(poly, PS_POLYNOMIAL_ORD, NULL); … … 1766 1766 // for now, for the SAMPLE_MEDIAN and SAMPLE_STDEV to be used 1767 1767 stats->options |= (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 1768 psTrace( __func__, 4, "stats->clipIter is %d\n", stats->clipIter);1769 psTrace( __func__, 4, "(minClipSigma, maxClipSigma) is (%.2f, %.2f)\n", minClipSigma, maxClipSigma);1768 psTrace("psLib.math", 4, "stats->clipIter is %d\n", stats->clipIter); 1769 psTrace("psLib.math", 4, "(minClipSigma, maxClipSigma) is (%.2f, %.2f)\n", minClipSigma, maxClipSigma); 1770 1770 1771 1771 for (psS32 N = 0; N < stats->clipIter; N++) { 1772 psTrace( __func__, 6, "Loop iteration %d. Calling psVectorFitPolynomial1D()\n");1772 psTrace("psLib.math", 6, "Loop iteration %d. Calling psVectorFitPolynomial1D()\n"); 1773 1773 psS32 Nkeep = 0; 1774 1774 if (psTraceGetLevel(__func__) >= 6) { 1775 1775 if (mask != NULL) { 1776 1776 for (psS32 i = 0 ; i < mask->n ; i++) { 1777 psTrace( __func__, 6, "mask[%d] is %d\n", i, mask->data.U8[i]);1777 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data.U8[i]); 1778 1778 } 1779 1779 } … … 1805 1805 for (psS32 i = 0 ; i < mask->n ; i++) { 1806 1806 if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) { 1807 psTrace( __func__, 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n",1807 psTrace("psLib.math", 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n", 1808 1808 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); 1809 1809 } … … 1820 1820 } 1821 1821 1822 psTrace( __func__, 6, "Median is %f\n", stats->sampleMedian);1823 psTrace( __func__, 6, "Stdev is %f\n", stats->sampleStdev);1822 psTrace("psLib.math", 6, "Median is %f\n", stats->sampleMedian); 1823 psTrace("psLib.math", 6, "Stdev is %f\n", stats->sampleStdev); 1824 1824 psF32 minClipValue = -minClipSigma*stats->sampleStdev; 1825 1825 psF32 maxClipValue = +maxClipSigma*stats->sampleStdev; … … 1836 1836 (resid->data.F64[i] - stats->sampleMedian < minClipValue)) { 1837 1837 if (f->type.type == PS_TYPE_F64) { 1838 psTrace( __func__, 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n",1838 psTrace("psLib.math", 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n", 1839 1839 i, fit->data.F64[i], i, resid->data.F64[i]); 1840 1840 } else { 1841 psTrace( __func__, 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n",1841 psTrace("psLib.math", 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n", 1842 1842 i, fit->data.F32[i], i, resid->data.F64[i]); 1843 1843 } … … 1851 1851 } 1852 1852 1853 psTrace( __func__, 6, "keeping %d of %d pts for fit\n", Nkeep, x->n);1853 psTrace("psLib.math", 6, "keeping %d of %d pts for fit\n", Nkeep, x->n); 1854 1854 psFree(fit); 1855 1855 } … … 1862 1862 } 1863 1863 1864 psTrace( __func__, 3, "---- %s() end ----\n", __func__);1864 psTrace("psLib.math", 3, "---- %s() end ----\n", __func__); 1865 1865 return(poly); 1866 1866 } … … 1888 1888 const psVector *t) 1889 1889 { 1890 psTrace( __func__, 4, "---- %s() begin ----\n", __func__);1890 psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__); 1891 1891 PS_ASSERT_POLY_NON_NULL(myPoly, NULL); 1892 1892 PS_ASSERT_INT_NONNEGATIVE(myPoly->nX, NULL); … … 1934 1934 psFree(A); 1935 1935 psFree(B); 1936 psTrace( __func__, 4, "---- %s() End ----\n", __func__);1936 psTrace("psLib.math", 4, "---- %s() End ----\n", __func__); 1937 1937 return(NULL); 1938 1938 } … … 2079 2079 psFree(B); 2080 2080 2081 psTrace( __func__, 4, "---- %s() end ----\n", __func__);2081 psTrace("psLib.math", 4, "---- %s() end ----\n", __func__); 2082 2082 return (myPoly); 2083 2083 } … … 2277 2277 const psVector *t) 2278 2278 { 2279 psTrace( __func__, 3, "---- %s() begin ----\n", __func__);2279 psTrace("psLib.math", 3, "---- %s() begin ----\n", __func__); 2280 2280 PS_ASSERT_POLY_NON_NULL(poly, NULL); 2281 2281 PS_ASSERT_POLY_TYPE(poly, PS_POLYNOMIAL_ORD, NULL); … … 2331 2331 // for now, for the SAMPLE_MEDIAN and SAMPLE_STDEV to be used 2332 2332 stats->options |= (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 2333 psTrace( __func__, 4, "stats->clipIter is %d\n", stats->clipIter);2334 psTrace( __func__, 4, "(minClipSigma, maxClipSigma) is (%.2f, %.2f)\n", minClipSigma, maxClipSigma);2333 psTrace("psLib.math", 4, "stats->clipIter is %d\n", stats->clipIter); 2334 psTrace("psLib.math", 4, "(minClipSigma, maxClipSigma) is (%.2f, %.2f)\n", minClipSigma, maxClipSigma); 2335 2335 2336 2336 for (psS32 N = 0; N < stats->clipIter; N++) { 2337 psTrace( __func__, 6, "Loop iteration %d. Calling psVectorFitPolynomial4D()\n");2337 psTrace("psLib.math", 6, "Loop iteration %d. Calling psVectorFitPolynomial4D()\n"); 2338 2338 psS32 Nkeep = 0; 2339 2339 if (psTraceGetLevel(__func__) >= 6) { 2340 2340 if (mask != NULL) { 2341 2341 for (psS32 i = 0 ; i < mask->n ; i++) { 2342 psTrace( __func__, 6, "mask[%d] is %d\n", i, mask->data.U8[i]);2342 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data.U8[i]); 2343 2343 } 2344 2344 } … … 2371 2371 for (psS32 i = 0 ; i < mask->n ; i++) { 2372 2372 if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) { 2373 psTrace( __func__, 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n",2373 psTrace("psLib.math", 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n", 2374 2374 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); 2375 2375 } … … 2385 2385 return(NULL); 2386 2386 } 2387 psTrace( __func__, 6, "Median is %f\n", stats->sampleMedian);2388 psTrace( __func__, 6, "Stdev is %f\n", stats->sampleStdev);2387 psTrace("psLib.math", 6, "Median is %f\n", stats->sampleMedian); 2388 psTrace("psLib.math", 6, "Stdev is %f\n", stats->sampleStdev); 2389 2389 psF32 minClipValue = -minClipSigma*stats->sampleStdev; 2390 2390 psF32 maxClipValue = +maxClipSigma*stats->sampleStdev; … … 2401 2401 (resid->data.F64[i] - stats->sampleMedian < minClipValue)) { 2402 2402 if (f->type.type == PS_TYPE_F64) { 2403 psTrace( __func__, 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n",2403 psTrace("psLib.math", 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n", 2404 2404 i, fit->data.F64[i], i, resid->data.F64[i]); 2405 2405 } else { 2406 psTrace( __func__, 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n",2406 psTrace("psLib.math", 6, "Masking element %d (%f). resid->data.F64[%d] is %f\n", 2407 2407 i, fit->data.F32[i], i, resid->data.F64[i]); 2408 2408 } … … 2417 2417 } 2418 2418 2419 psTrace( __func__, 6, "keeping %d of %d pts for fit\n", Nkeep, x->n);2419 psTrace("psLib.math", 6, "keeping %d of %d pts for fit\n", Nkeep, x->n); 2420 2420 psFree (fit); 2421 2421 } … … 2428 2428 } 2429 2429 2430 psTrace( __func__, 3, "---- %s() end ----\n", __func__);2430 psTrace("psLib.math", 3, "---- %s() end ----\n", __func__); 2431 2431 return(poly); 2432 2432 }
Note:
See TracChangeset
for help on using the changeset viewer.
