Changeset 6193
- Timestamp:
- Jan 25, 2006, 2:31:19 PM (20 years ago)
- Location:
- trunk/psLib
- Files:
-
- 7 edited
-
src/imageops/psImageStats.c (modified) (2 diffs)
-
src/math/psConstants.h (modified) (2 diffs)
-
src/math/psMinimizePolyFit.c (modified) (12 diffs)
-
src/math/psPolynomial.c (modified) (7 diffs)
-
src/math/psStats.c (modified) (9 diffs)
-
test/math/Makefile.am (modified) (3 diffs)
-
test/math/tst_psPolyFit1D.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageStats.c
r6186 r6193 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.8 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-01-2 3 22:25:31$11 * @version $Revision: 1.88 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-01-26 00:31:19 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 432 432 for (y = 0; y < input->numCols; y++) { 433 433 double pixel; 434 /*435 if (input->type.type == PS_TYPE_S8) {436 pixel = (double) input->data.S8[x][y];437 } else if (input->type.type == PS_TYPE_U16) {438 pixel = (double) input->data.U16[x][y];439 } else if (input->type.type == PS_TYPE_F32) {440 pixel = (double) input->data.F32[x][y];441 } else if (input->type.type == PS_TYPE_F64) {442 pixel = input->data.F64[x][y];443 }444 */434 if (0) { 435 if (input->type.type == PS_TYPE_S8) { 436 pixel = (double) input->data.S8[x][y]; 437 } else if (input->type.type == PS_TYPE_U16) { 438 pixel = (double) input->data.U16[x][y]; 439 } else if (input->type.type == PS_TYPE_F32) { 440 pixel = (double) input->data.F32[x][y]; 441 } else if (input->type.type == PS_TYPE_F64) { 442 pixel = input->data.F64[x][y]; 443 } 444 } 445 445 pixel = nodes->data.F64[x][y]; 446 446 sums[i][j] += pixel * psPolynomial1DEval(chebPolys[i], rScalingFactors[x]) * -
trunk/psLib/src/math/psConstants.h
r6186 r6193 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.8 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-01-2 3 22:25:31$8 * @version $Revision: 1.83 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-01-26 00:31:19 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 74 74 #define PS_ASSERT_INT_NONNEGATIVE(NAME, RVAL) \ 75 75 if ((NAME) < 0) { \ 76 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 77 "Error: %s is less than 0.", #NAME); \ 76 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Error: %s is less than 0.", #NAME); \ 78 77 return(RVAL); \ 79 78 } -
trunk/psLib/src/math/psMinimizePolyFit.c
r6186 r6193 10 10 * @author EAM, IfA 11 11 * 12 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-01-2 3 22:25:31$12 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-01-26 00:31:19 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 16 * 17 * XXX: psMatrixLUSolve() does not return error codes when the results are NANs. 16 18 * 17 19 * XXX: For clip-fit functions, what should we do if the mask is NULL? … … 279 281 *****************************************************************************/ 280 282 283 static psPolynomial1D* VectorFitPolynomial1DOrd( 284 psPolynomial1D* myPoly, 285 const psVector *mask, 286 psMaskType maskValue, 287 const psVector *f, 288 const psVector *fErr, 289 const psVector *x); 290 291 /****************************************************************************** 292 vectorFitPolynomial1DCheb(): This routine will fit a Chebyshev 293 polynomial of degree myPoly->nX to the data points (x, y) and return the 294 coefficients of that polynomial. 295 296 NOTE: We currently have implemented three algorithms. This one is 297 non-standard. It ignores the orthogonal properties of the Chebyshev 298 polys, and their known zero values. Instead, we first fit a regular 299 ordinary polynomial to the data. This produces the coefficients for the 300 various x^i terms. We then "reverse-engineer" those coefficients to 301 determine the coefficients of the Chebyshev polys: basically for each 302 c_ix^i term in the ordinary polynomial, we sum all x^i terms in the 303 Chebshev polys: these must be equal. This creates a set of nOrder+1 304 linear equations which can be easily solved. The resulting vector is the 305 coefficients of the Chebyshev polys. 306 307 This method is significantly slower than the standard NR algorithm. It 308 was explicitly requested that we not use the NR algorithm. 309 310 Matrix A[[][]: 311 Element A[i][j] is the coefficient of the x^i term in the j-th cheby poly. 312 313 XXX: This can be improved significantly, performance-wise. The second set 314 of linear equations which must be "solved" are already in upper-triangular 315 form. One must only perform the reverse-substitution, LUD decomposition. 316 317 XXX: Also, we don't really need to generate the chebPolys data structure. 318 We simply need the matrix which corresponds to a transpose of each Cheby 319 polys coefficients. 320 *****************************************************************************/ 321 static psPolynomial1D *vectorFitPolynomial1DCheb( 322 psPolynomial1D* myPoly, 323 const psVector *mask, 324 psMaskType maskValue, 325 const psVector* y, 326 const psVector* yErr, 327 const psVector* x) 328 { 329 PS_ASSERT_POLY_NON_NULL(myPoly, NULL); 330 PS_ASSERT_INT_LARGER_THAN_OR_EQUAL(myPoly->nX, 0, NULL); 331 PS_ASSERT_VECTOR_NON_NULL(y, NULL); 332 PS_ASSERT_VECTOR_TYPE(y, PS_TYPE_F64, NULL); 333 if (yErr != NULL) { 334 PS_ASSERT_VECTORS_SIZE_EQUAL(y, yErr, NULL); 335 PS_ASSERT_VECTOR_TYPE(yErr, PS_TYPE_F64, NULL); 336 } 337 if (x != NULL) { 338 PS_ASSERT_VECTORS_SIZE_EQUAL(y, x, NULL); 339 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F64, NULL); 340 } 341 if (mask != NULL) { 342 PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, NULL); 343 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, NULL); 344 } 345 346 psS32 polyOrder = myPoly->nX; 347 psS32 numPoly = polyOrder + 1; 348 349 // 350 // We first fit an ordinary polynomial to the data. 351 // 352 psPolynomial1D *ordPoly = psPolynomial1DAlloc(polyOrder, PS_POLYNOMIAL_ORD); 353 psPolynomial1D *rc = VectorFitPolynomial1DOrd(ordPoly, mask, maskValue, y, yErr, x); 354 if (rc == NULL) { 355 psError(PS_ERR_UNKNOWN, false, "Could not fit a preliminary polynomial to the data vector. Returning NULL.\n"); 356 psFree(myPoly); 357 return(NULL); 358 } 359 360 // 361 // Create the A-matrix and B-vector which correspond to the linear equations 362 // which will be solved and will then yield the Cheby poly coefficients. 363 // 364 psPolynomial1D **chebPolys = p_psCreateChebyshevPolys(numPoly); 365 psImage *A = psImageAlloc(numPoly, numPoly, PS_TYPE_F64); 366 psVector *B = psVectorAlloc(numPoly, PS_TYPE_F64); 367 for (psS32 i = 0 ; i < numPoly ; i++) { 368 for (psS32 j = 0 ; j < numPoly ; j++) { 369 A->data.F64[i][j] = 0.0; 370 } 371 B->data.F64[i] = ordPoly->coeff[i]; 372 } 373 374 for (psS32 i = 0 ; i < numPoly ; i++) { 375 for (psS32 j = 0 ; j < numPoly ; j++) { 376 if (i <= chebPolys[j]->nX) 377 A->data.F64[i][j]+= chebPolys[j]->coeff[i]; 378 } 379 } 380 // The following statement is essential. It derives from (5.8.8) NR. 381 A->data.F64[0][0] = 0.5; 382 psFree(ordPoly); 383 if (psTraceGetLevel(__func__) >= 6) { 384 PS_IMAGE_PRINT_F64(A); 385 PS_VECTOR_PRINT_F64(B); 386 } 387 388 if (0) { 389 // GaussJordan version 390 if (false == psGaussJordan(A, B)) { 391 psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations. Returning NULL.\n"); 392 psFree(myPoly); 393 myPoly = NULL; 394 } else { 395 // the first nTerm entries in B correspond directly to the desired 396 // polynomial coefficients. this is only true for the 1D case 397 for (psS32 k = 0; k < numPoly; k++) { 398 myPoly->coeff[k] = B->data.F64[k]; 399 } 400 } 401 } else { 402 // LUD version of the fit 403 psImage *ALUD = NULL; 404 psVector* outPerm = NULL; 405 psVector* coeffs = NULL; 406 407 ALUD = psImageAlloc(numPoly, numPoly, PS_TYPE_F64); 408 ALUD = psMatrixLUD(ALUD, &outPerm, A); 409 if (ALUD == NULL) { 410 psError(PS_ERR_UNKNOWN, false, "Could not do LUD decomposition on matrix. Returning NULL.\n"); 411 psFree(myPoly); 412 myPoly = NULL; 413 } else { 414 coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm); 415 if (coeffs == NULL) { 416 psError(PS_ERR_UNKNOWN, false, "Could not solve LUD matrix. Returning NULL.\n"); 417 psFree(myPoly); 418 myPoly = NULL; 419 } else { 420 for (psS32 k = 0; k < numPoly; k++) { 421 myPoly->coeff[k] = coeffs->data.F64[k]; 422 } 423 } 424 } 425 426 427 psFree(ALUD); 428 psFree(coeffs); 429 psFree(outPerm); 430 } 431 432 psFree(A); 433 psFree(B); 434 for (psS32 i=0;i<numPoly;i++) { 435 psFree(chebPolys[i]); 436 } 437 psFree(chebPolys); 438 439 return(myPoly); 440 } 441 442 281 443 /****************************************************************************** 282 444 vectorFitPolynomial1DChebSlow(): This routine will fit a Chebyshev polynomial … … 284 446 polynomial. 285 447 286 NOTE: We currently have implemented t woalgorithms. This one is448 NOTE: We currently have implemented three algorithms. This one is 287 449 non-standard. It ignores the orthogonal properties of the Chebyshev 288 450 polys, and their known zero values. Instead, we do build a system of 289 451 linear equations based on minimizing the chi-squared for all data points 290 452 and we then solve those equations. This method is significantly slower 291 than the other algorithm . It was explicitly requested that we implement453 than the other algorithms. It was explicitly requested that we implement 292 454 this algorithm. 293 294 455 *****************************************************************************/ 295 456 static psPolynomial1D *vectorFitPolynomial1DChebySlow( … … 329 490 NUM_DATA = x->n; 330 491 } 331 // psTrace printf("vectorFitPolynomial1DChebySlow(): NUM_DATA is %d\n", NUM_DATA);332 492 333 493 psPolynomial1D **chebPolys = p_psCreateChebyshevPolys(NUM_POLY); … … 408 568 psVector* coeffs = NULL; 409 569 410 // XXX: Check return codes.411 570 ALUD = psImageAlloc(NUM_POLY, NUM_POLY, PS_TYPE_F64); 412 571 ALUD = psMatrixLUD(ALUD, &outPerm, A); 413 coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm); 414 for (psS32 k = 0; k < NUM_POLY; k++) { 415 myPoly->coeff[k] = coeffs->data.F64[k]; 572 if (ALUD == NULL) { 573 psError(PS_ERR_UNKNOWN, false, "Could not do LUD decomposition on matrix. Returning NULL.\n"); 574 psFree(myPoly); 575 myPoly = NULL; 576 } else { 577 coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm); 578 if (coeffs == NULL) { 579 psError(PS_ERR_UNKNOWN, false, "Could not solve LUD matrix. Returning NULL.\n"); 580 psFree(myPoly); 581 myPoly = NULL; 582 } else { 583 for (psS32 k = 0; k < NUM_POLY; k++) { 584 myPoly->coeff[k] = coeffs->data.F64[k]; 585 } 586 } 416 587 } 417 588 … … 437 608 polynomial. 438 609 439 NOTE: We currently have t woalgorithms. This is standard method which610 NOTE: We currently have three algorithms. This is standard method which 440 611 uses the orthogonal properties of the Chebyshev polys, and their known 441 zero values. This is significantly faster than the chi-squared approach. 612 zero values. This is significantly faster than the chi-squared 613 approaches. 442 614 443 615 NOTE: This function will not work properly if the x-vector does not fully span … … 621 793 // Build the B and A data structs. 622 794 // XXX EAM : use temp pointers eg vB = B->data.F64 to save redirects 623 // XXX EAM : this function is only valid for data vectors of F64624 795 for (psS32 k = 0; k < f->n; k++) { 625 796 if ((mask != NULL) && (mask->data.U8[k] && maskValue)) { … … 671 842 psVector* coeffs = NULL; 672 843 673 // XXX: Check return codes.674 844 ALUD = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); 675 845 ALUD = psMatrixLUD(ALUD, &outPerm, A); 676 coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm); 677 for (psS32 k = 0; k < nTerm; k++) { 678 myPoly->coeff[k] = coeffs->data.F64[k]; 679 } 846 if (ALUD == NULL) { 847 psError(PS_ERR_UNKNOWN, false, "Could not do LUD decomposition on matrix. Returning NULL.\n"); 848 psFree(myPoly); 849 myPoly = NULL; 850 } else { 851 coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm); 852 if (coeffs == NULL) { 853 psError(PS_ERR_UNKNOWN, false, "Could not solve LUD matrix. Returning NULL.\n"); 854 psFree(myPoly); 855 myPoly = NULL; 856 } else { 857 for (psS32 k = 0; k < nTerm; k++) { 858 myPoly->coeff[k] = coeffs->data.F64[k]; 859 } 860 } 861 } 862 680 863 psFree(ALUD); 681 864 psFree(coeffs); … … 771 954 772 955 if (1) { 773 poly = vectorFitPolynomial1DCheb ySlow(poly, mask, maskValue, f64, fErr64, x64);956 poly = vectorFitPolynomial1DCheb(poly, mask, maskValue, f64, fErr64, x64); 774 957 } else { 775 poly = vectorFitPolynomial1DChebyFast(poly, mask, maskValue, f64, fErr64, x64); 958 if (0) { 959 poly = vectorFitPolynomial1DChebySlow(poly, mask, maskValue, f64, fErr64, x64); 960 poly = vectorFitPolynomial1DChebyFast(poly, mask, maskValue, f64, fErr64, x64); 961 } 776 962 } 777 963 if (x == NULL) { … … 989 1175 PS_ASSERT_INT_NONNEGATIVE(myPoly->nX, NULL); 990 1176 PS_ASSERT_INT_NONNEGATIVE(myPoly->nY, NULL); 991 992 1177 PS_ASSERT_VECTOR_NON_NULL(f, NULL); 993 1178 PS_ASSERT_VECTOR_TYPE(f, PS_TYPE_F64, NULL); … … 1560 1745 psVector* coeffs = NULL; 1561 1746 1562 // XXX: Check return codes.1563 1747 ALUD = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); 1564 1748 ALUD = psMatrixLUD(ALUD, &outPerm, A); 1565 coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm); 1566 1567 // select the appropriate solution entries 1568 for (psS32 ix = 0; ix < nXterm; ix++) { 1569 for (psS32 iy = 0; iy < nYterm; iy++) { 1570 for (psS32 iz = 0; iz < nZterm; iz++) { 1571 psS32 nx = ix+iy*nXterm+iz*nXterm*nYterm; 1572 myPoly->coeff[ix][iy][iz] = coeffs->data.F64[nx]; 1573 myPoly->coeffErr[ix][iy][iz] = sqrt(A->data.F64[nx][nx]); 1749 if (ALUD == NULL) { 1750 psError(PS_ERR_UNKNOWN, false, "Could not do LUD decomposition on matrix. Returning NULL.\n"); 1751 psFree(myPoly); 1752 myPoly = NULL; 1753 } else { 1754 coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm); 1755 if (coeffs == NULL) { 1756 psError(PS_ERR_UNKNOWN, false, "Could not solve LUD matrix. Returning NULL.\n"); 1757 psFree(myPoly); 1758 myPoly = NULL; 1759 } else { 1760 // select the appropriate solution entries 1761 for (psS32 ix = 0; ix < nXterm; ix++) { 1762 for (psS32 iy = 0; iy < nYterm; iy++) { 1763 for (psS32 iz = 0; iz < nZterm; iz++) { 1764 psS32 nx = ix+iy*nXterm+iz*nXterm*nYterm; 1765 myPoly->coeff[ix][iy][iz] = coeffs->data.F64[nx]; 1766 myPoly->coeffErr[ix][iy][iz] = sqrt(A->data.F64[nx][nx]); 1767 } 1768 } 1574 1769 } 1575 1770 } … … 2108 2303 psVector* coeffs = NULL; 2109 2304 2110 // XXX: Check return codes.2111 2305 ALUD = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); 2112 2306 ALUD = psMatrixLUD(ALUD, &outPerm, A); 2113 coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm); 2114 2115 // select the appropriate solution entries 2116 for (psS32 ix = 0; ix < nXterm; ix++) { 2117 for (psS32 iy = 0; iy < nYterm; iy++) { 2118 for (psS32 iz = 0; iz < nZterm; iz++) { 2119 for (psS32 it = 0; it < nTterm; it++) { 2120 psS32 nx = ix+iy*nXterm+iz*nXterm*nYterm+it*nXterm*nYterm*nZterm; 2121 myPoly->coeff[ix][iy][iz][it] = coeffs->data.F64[nx]; 2122 myPoly->coeffErr[ix][iy][iz][it] = sqrt(A->data.F64[nx][nx]); 2307 if (ALUD == NULL) { 2308 psError(PS_ERR_UNKNOWN, false, "Could not do LUD decomposition on matrix. Returning NULL.\n"); 2309 psFree(myPoly); 2310 myPoly = NULL; 2311 } else { 2312 coeffs = psMatrixLUSolve(coeffs, ALUD, B, outPerm); 2313 if (coeffs == NULL) { 2314 psError(PS_ERR_UNKNOWN, false, "Could not solve LUD matrix. Returning NULL.\n"); 2315 psFree(myPoly); 2316 myPoly = NULL; 2317 } else { 2318 // select the appropriate solution entries 2319 for (psS32 ix = 0; ix < nXterm; ix++) { 2320 for (psS32 iy = 0; iy < nYterm; iy++) { 2321 for (psS32 iz = 0; iz < nZterm; iz++) { 2322 for (psS32 it = 0; it < nTterm; it++) { 2323 psS32 nx = ix+iy*nXterm+iz*nXterm*nYterm+it*nXterm*nYterm*nZterm; 2324 myPoly->coeff[ix][iy][iz][it] = coeffs->data.F64[nx]; 2325 myPoly->coeffErr[ix][iy][iz][it] = sqrt(A->data.F64[nx][nx]); 2326 } 2327 } 2123 2328 } 2124 2329 } -
trunk/psLib/src/math/psPolynomial.c
r6186 r6193 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.13 6$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-01-2 3 22:25:31$9 * @version $Revision: 1.137 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-01-26 00:31:19 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 194 194 } 195 195 196 if (psTraceGetLevel(__func__) >= 6) { 197 for (psS32 j = 0; j < numPolys; j++) { 198 PS_POLY_PRINT_1D(chebPolys[j]); 199 } 200 } 196 201 return (chebPolys); 197 202 } … … 606 611 /***************************************************************************** 607 612 This routine must allocate memory for the polynomial structures. 613 614 XXX: How do we check for an appropriate value for n? 608 615 *****************************************************************************/ 609 616 psPolynomial1D* psPolynomial1DAlloc( … … 611 618 psPolynomialType type) 612 619 { 613 PS_ASSERT_INT_NONNEGATIVE(n, NULL);620 //PS_ASSERT_INT_NONNEGATIVE(n, NULL); 614 621 psU32 nOrder = n; 615 622 psPolynomial1D *newPoly = (psPolynomial1D* ) psAlloc(sizeof(psPolynomial1D)); … … 636 643 psPolynomialType type) 637 644 { 638 PS_ASSERT_INT_NONNEGATIVE(nX, NULL);639 PS_ASSERT_INT_NONNEGATIVE(nY, NULL);645 //PS_ASSERT_INT_NONNEGATIVE(nX, NULL); 646 //PS_ASSERT_INT_NONNEGATIVE(nY, NULL); 640 647 641 648 unsigned int x = 0; … … 674 681 psPolynomialType type) 675 682 { 676 PS_ASSERT_INT_NONNEGATIVE(nX, NULL);677 PS_ASSERT_INT_NONNEGATIVE(nY, NULL);678 PS_ASSERT_INT_NONNEGATIVE(nZ, NULL);683 //PS_ASSERT_INT_NONNEGATIVE(nX, NULL); 684 //PS_ASSERT_INT_NONNEGATIVE(nY, NULL); 685 //PS_ASSERT_INT_NONNEGATIVE(nZ, NULL); 679 686 680 687 unsigned int x = 0; … … 723 730 psPolynomialType type) 724 731 { 725 PS_ASSERT_INT_NONNEGATIVE(nX, NULL);726 PS_ASSERT_INT_NONNEGATIVE(nY, NULL);727 PS_ASSERT_INT_NONNEGATIVE(nZ, NULL);728 PS_ASSERT_INT_NONNEGATIVE(nT, NULL);732 //PS_ASSERT_INT_NONNEGATIVE(nX, NULL); 733 //PS_ASSERT_INT_NONNEGATIVE(nY, NULL); 734 //PS_ASSERT_INT_NONNEGATIVE(nZ, NULL); 735 //PS_ASSERT_INT_NONNEGATIVE(nT, NULL); 729 736 730 737 unsigned int x = 0; -
trunk/psLib/src/math/psStats.c
r6186 r6193 14 14 * stats->binsize 15 15 * 16 * 17 * 18 * 19 * @version $Revision: 1.160 $ $Name: not supported by cvs2svn $ 20 * @date $Date: 2006-01-23 22:25:31 $ 16 * @version $Revision: 1.161 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2006-01-26 00:31:19 $ 21 18 * 22 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 574 571 nValues = p_psVectorNValues(myVector, maskVector, maskVal, stats); 575 572 576 // XXX: Is a warning message appropriate? What value should we set the577 // sampleMedian to? Should we generate an error?578 573 if (nValues <= 0) { 579 574 psLogMsg(__func__, PS_LOG_WARN, "WARNING: p_psVectorSampleMedian(): no valid elements in input vector.\n"); … … 784 779 Returns 785 780 NULL 786 787 XXX: Use static vectors.788 781 *****************************************************************************/ 789 782 bool p_psVectorSampleQuartiles(const psVector* myVector, … … 1133 1126 p_psMemSetPersistent(statsTmp, true); 1134 1127 } else { 1135 // XXXEAM : initialize structure if already allocated1128 // EAM : initialize structure if already allocated 1136 1129 statsTmp->sampleMean = NAN; 1137 1130 statsTmp->sampleMedian = NAN; … … 1226 1219 // Otherwise, use the new results and continue. 1227 1220 if (isnan(statsTmp->sampleMean) || isnan(statsTmp->sampleStdev)) { 1228 // Exit loop. XXX: Should wethrow an error/warning here?1221 // Exit loop. XXX: throw an error/warning here? 1229 1222 iter = stats->clipIter; 1230 1223 rc = -1; … … 1487 1480 // 1488 1481 // XXX: This routine should probably be rewritten in a more general fashion 1489 // so that the follo iwng checks are not necessary.1482 // so that the following checks are not necessary. 1490 1483 // 1491 1484 if (y->data.F64[0] < y->data.F64[1]) { … … 1591 1584 psTrace(__func__, 5, "---- %s(%f) end ----\n", __func__, tmpFloat); 1592 1585 return(tmpFloat); 1593 }1594 1595 /*****************************************************************************1596 XXX: Is there a psLib function for this?1597 *****************************************************************************/1598 psVector *PsVectorDup(psVector *in)1599 {1600 psTrace(__func__, 4, "---- %s() begin ----\n", __func__);1601 PS_ASSERT_VECTOR_NON_NULL(in, NULL);1602 psVector *out = psVectorAlloc(in->n, in->type.type);1603 1604 if (in->type.type == PS_TYPE_F32) {1605 for (psS32 i = 0 ; i < in->n ; i++) {1606 out->data.F32[i] = in->data.F32[i];1607 }1608 } else if (in->type.type == PS_TYPE_F64) {1609 for (psS32 i = 0 ; i < in->n ; i++) {1610 out->data.F64[i] = in->data.F64[i];1611 }1612 } else {1613 psError(PS_ERR_UNKNOWN, true, "Unallowable vector type.\n");1614 psTrace(__func__, 4, "---- %s(NULL) end ----\n", __func__);1615 return(NULL);1616 }1617 psTrace(__func__, 4, "---- %s(psVector) end ----\n", __func__);1618 return(out);1619 1586 } 1620 1587 … … 1832 1799 // ADD: Step 3. 1833 1800 // Interpolate to the exact 50% position: this is the robust histogram median. 1834 // XXX: Check for errors here!1801 // XXX: Check return codes. 1835 1802 // 1836 1803 stats->robustMedian = fitQuadraticSearchForYThenReturnX( … … 2640 2607 2641 2608 XXX: Should the default data type be F64? Since we are buying Opterons... 2609 2610 XXX: Use psLib functions instead. 2642 2611 *****************************************************************************/ 2643 2612 psVector* p_psConvertToF32(psVector* in) -
trunk/psLib/test/math/Makefile.am
r6099 r6193 5 5 6 6 TESTS = \ 7 tst_psFunc00 \8 7 tst_psFunc01 \ 9 8 tst_psFunc08 \ … … 41 40 tst_psSpline1D \ 42 41 tst_psRandom \ 42 tst_psPolynomial \ 43 43 tst_psPolyFit1D \ 44 44 tst_psPolyFit2D \ 45 45 tst_psPolyFit3D \ 46 tst_psPolyFit4D \ 47 tst_psPolyFit2DOrd \ 48 tst_psPolyFit3DOrd \ 49 tst_psPolyFit4DOrd 46 tst_psPolyFit4D 50 47 51 48 … … 85 82 tst_psStats09_SOURCES = tst_psStats09.c 86 83 tst_psRandom_SOURCES = tst_psRandom.c 84 tst_psPolynomial_SOURCES = tst_psPolynomial.c 87 85 tst_psPolyFit1D_SOURCES = tst_psPolyFit1D.c 88 86 tst_psPolyFit2D_SOURCES = tst_psPolyFit2D.c 89 87 tst_psPolyFit3D_SOURCES = tst_psPolyFit3D.c 90 88 tst_psPolyFit4D_SOURCES = tst_psPolyFit4D.c 91 tst_psPolyFit2DOrd_SOURCES = tst_psPolyFit2DOrd.c92 tst_psPolyFit3DOrd_SOURCES = tst_psPolyFit3DOrd.c93 tst_psPolyFit4DOrd_SOURCES = tst_psPolyFit4DOrd.c94 89 95 90 check_DATA = -
trunk/psLib/test/math/tst_psPolyFit1D.c
r6099 r6193 14 14 #include "psTest.h" 15 15 #define NUM_DATA 35 16 #define POLY_ORDER 416 #define POLY_ORDER 5 17 17 #define A 2.0 18 18 #define B 3.0 … … 350 350 psTraceSetLevel("VectorFitPolynomial1DOrd", 0); 351 351 psTraceSetLevel("VectorFitPolynomial1DCheb", 0); 352 psTraceSetLevel("vectorFitPolynomial1DCheb", 10); 352 353 psTraceSetLevel("vectorFitPolynomial1DChebSlow", 0); 353 354 psTraceSetLevel("vectorFitPolynomial1DChebFast", 0); 354 355 psTraceSetLevel("psVectorFitPolynomial1D", 0); 356 psTraceSetLevel("p_psCreateChebyshevPolys", 0); 355 357 356 358 printPositiveTestHeader(stdout, "psMinimize functions: 1D Polynomial Fitting Functions", ""); … … 503 505 testStatus &= genericTest(TS00_MASK_U8 | TS00_FERR_F64 | TS00_X_F32 | TS00_F_F64 | TS00_POLY_CHEB | TS00_CLIP_FIT, POLY_ORDER, NUM_DATA, false); 504 506 507 508 // testStatus &= genericTest(TS00_MASK_U8 | TS00_FERR_F32 | TS00_X_F32 | TS00_F_F32 | TS00_POLY_CHEB, POLY_ORDER, NUM_DATA, true); 509 // testStatus &= genericTest(TS00_MASK_U8 | TS00_FERR_F32 | TS00_X_F32 | TS00_F_F32 | TS00_POLY_ORD, POLY_ORDER, NUM_DATA, true); 510 505 511 printFooter(stdout, "psMinimize functions: 1D Polynomial Fitting Functions", "", testStatus); 506 512 }
Note:
See TracChangeset
for help on using the changeset viewer.
