Changeset 1907
- Timestamp:
- Sep 27, 2004, 1:41:42 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 13 edited
-
src/dataManip/psConstants.h (modified) (2 diffs)
-
src/dataManip/psFunctions.c (modified) (4 diffs)
-
src/dataManip/psMinimize.c (modified) (5 diffs)
-
src/dataManip/psStats.c (modified) (2 diffs)
-
src/dataManip/psStats.h (modified) (2 diffs)
-
src/math/psConstants.h (modified) (2 diffs)
-
src/math/psMinimize.c (modified) (5 diffs)
-
src/math/psPolynomial.c (modified) (4 diffs)
-
src/math/psSpline.c (modified) (4 diffs)
-
src/math/psStats.c (modified) (2 diffs)
-
src/math/psStats.h (modified) (2 diffs)
-
test/dataManip/Makefile (modified) (2 diffs)
-
test/dataManip/tst_psMinimize04.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psConstants.h
r1903 r1907 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-09-2 5 23:05:07$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-09-27 23:41:42 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 48 48 } 49 49 50 /** Preprocessor macro to generate error on a NULL image */ 51 #define PS_CHECK_NULL_IMAGE(NAME) \ 52 if (NAME == NULL || NAME->data.V == NULL) { \ 53 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 54 } 55 56 /** Preprocessor macro to generate error for zero length rows or columns */ 57 #define PS_CHECK_EMPTY_IMAGE(NAME) \ 58 if (NAME->numCols < 1 || NAME->numRows < 1) { \ 59 psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME, \ 60 NAME->numCols, NAME->numRows); \ 61 } 62 63 /** Preprocessor macro to generate error on a NULL 1DPolynomial */ 64 #define PS_CHECK_NULL_1DPOLY(NAME) \ 65 if (NAME == NULL || NAME->coeff == NULL) { \ 66 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 67 } 68 50 69 #define PS_PRINT_VECTOR(NAME) \ 51 70 for (int my_i=0;my_i<NAME->n;my_i++) { \ -
trunk/psLib/src/dataManip/psFunctions.c
r1903 r1907 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.4 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-2 5 23:05:07$9 * @version $Revision: 1.42 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-27 23:41:42 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 111 111 /*****************************************************************************/ 112 112 113 static psPolynomial1D* *CreateChebyshevPolys(int maxChebyPoly) 113 /***************************************************************************** 114 CreateChebyshevPolys(n): this routine takes as input the required order n, 115 and returns as output as a pointer to an array of n psPolynomial1D 116 structures, corresponding to the first n Chebyshev polynomials. 117 118 XXX: The output should be static since the Chebyshev polynomials might be 119 used frequently and the data structure created here does not contain the 120 outer coefficients of the Chebyshev polynomials. 121 *****************************************************************************/ 122 static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly) 114 123 { 115 124 psPolynomial1D **chebPolys = NULL; … … 430 439 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 431 440 432 XXX: Determine, from IfA, whether or not the "mask[]" terms should be used433 in polynomial evaluation. If so, then all of the following polynomial434 evaluation functions must be modified to do so.435 436 441 XXX: Should the "coeffErr[]" should be used as well? 437 442 *****************************************************************************/ … … 502 507 psFree(d); 503 508 return(tmp); 509 /* 510 int n; 511 int i; 512 float tmp; 513 psPolynomial1D **chebPolys = NULL; 514 515 n = myPoly->n; 516 chebPolys = CreateChebyshevPolys(n); 517 518 tmp = 0.0; 519 for (i=0;i<myPoly->n;i++) { 520 tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i])); 521 } 522 tmp-= (myPoly->coeff[0]/2.0); 523 return(tmp); 524 */ 504 525 } 505 526 -
trunk/psLib/src/dataManip/psMinimize.c
r1879 r1907 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.4 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09-2 4 20:08:22 $11 * @version $Revision: 1.49 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-27 23:41:42 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 53 53 /* DEFINE STATEMENTS */ 54 54 /*****************************************************************************/ 55 56 /** Preprocessor macro to generate error on a NULL 1DPolynomial */57 #define PS_CHECK_NULL_1DPOLY(NAME) \58 if (NAME == NULL || NAME->coeff == NULL) { \59 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \60 }61 62 /** Preprocessor macro to generate error on a NULL vector */63 #define PS_CHECK_NULL_VECTOR(NAME) \64 if (NAME == NULL || NAME->data.V == NULL) { \65 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \66 }67 68 /** Preprocessor macro to generate error for zero length vector */69 #define PS_CHECK_EMPTY_VECTOR(NAME) \70 if (NAME->n < 1) { \71 psError(__func__,"Invalid operation: %s has zero n value.", #NAME); \72 }73 74 /** Preprocessor macro to generate error on differing size vectors */75 #define PS_CHECK_VECTOR_SIZE_EQUAL(VEC1, VEC2) \76 if (VEC1->n != VEC2->n) { \77 psError(__func__,"Vector %s has size %d, Vector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \78 }79 80 /** Preprocessor macro to generate error on a NULL image */81 #define PS_CHECK_NULL_IMAGE(NAME) \82 if (NAME == NULL || NAME->data.V == NULL) { \83 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \84 }85 86 /** Preprocessor macro to generate error for zero length rows or columns */87 #define PS_CHECK_EMPTY_IMAGE(NAME) \88 if (NAME->numCols < 1 || NAME->numRows < 1) { \89 psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME, \90 NAME->numCols, NAME->numRows); \91 }92 55 93 56 /*****************************************************************************/ … … 692 655 } 693 656 657 658 /***************************************************************************** 659 CreateChebyshevPolys(n): this routine takes as input the required order n, 660 and returns as output as a pointer to an array of n psPolynomial1D 661 structures, corresponding to the first n Chebyshev polynomials. 662 663 XXX: The output should be static since the Chebyshev polynomials might be 664 used frequently and the data structure created here does not contain the 665 outer coefficients of the Chebyshev polynomials. 666 *****************************************************************************/ 667 static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly) 668 { 669 psPolynomial1D **chebPolys = NULL; 670 int i = 0; 671 int j = 0; 672 673 chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *)); 674 for (i = 0; i < maxChebyPoly; i++) { 675 chebPolys[i] = psPolynomial1DAlloc(i + 1, PS_POLYNOMIAL_ORD); 676 } 677 678 // Create the Chebyshev polynomials. 679 // Polynomial i has i-th order. 680 chebPolys[0]->coeff[0] = 1; 681 chebPolys[1]->coeff[1] = 1; 682 for (i = 2; i < maxChebyPoly; i++) { 683 for (j = 0; j < chebPolys[i - 1]->n; j++) { 684 chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j]; 685 } 686 for (j = 0; j < chebPolys[i - 2]->n; j++) { 687 chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j]; 688 } 689 } 690 691 return (chebPolys); 692 } 693 694 695 696 psPolynomial1D* p_psVectorFitPolynomial1DCheby(psPolynomial1D* myPoly, 697 const psVector* restrict x, 698 const psVector* restrict y, 699 const psVector* restrict yErr) 700 { 701 int j; 702 int k; 703 int n = x->n; 704 psPolynomial1D **chebPolys = CreateChebyshevPolys(myPoly->n); 705 ; 706 float fac; 707 float sum; 708 /* 709 fac = 2.0/((float) n); 710 for (j=0;j<n;j++) { 711 sum = 0.0; 712 for (k=0;k<n;k++) { 713 sum+= y->data.F64[k] * 714 cos(M_PI * ((float) j) * (0.5 + ((float) k)) / ((float) n)); 715 // sum+= y->data.F64[k] * 716 // cos(M_PI * ((float) j) * (-0.5 + ((float) k)) / ((float) n)) * 717 // cos(M_PI * (-0.5 + ((float) k)) / ((float) n)); 718 719 } 720 myPoly->coeff[j] = fac * sum; 721 722 } 723 return(myPoly); 724 */ 725 726 fac = 2.0/((float) n); 727 for (j=0;j<myPoly->n;j++) { 728 sum = 0.0; 729 for (k=1;k<n;k++) { 730 sum+= (y->data.F64[k] * 731 psPolynomial1DEval((float) x->data.F64[k], chebPolys[j])); 732 } 733 myPoly->coeff[j] = fac * sum; 734 } 735 return(myPoly); 736 } 737 694 738 /****************************************************************************** 695 739 psVectorFitPolynomial1D(): This routine must fit a polynomial of degree … … 704 748 705 749 XXX: Must do: if yErr==NULL, set all errors equal. 750 751 XXX: type is currently ignored. Must implement this for Chebyshev 752 polynomials. 706 753 *****************************************************************************/ 707 754 psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* myPoly, … … 710 757 const psVector* restrict yErr) 711 758 { 759 // XXX: Create a p_psVectorFitPolynomial1DOrd() function. Here, we 760 // should only be calling that or the Cheby function. 761 762 if (myPoly->type == PS_POLYNOMIAL_CHEB) { 763 return(p_psVectorFitPolynomial1DCheby(myPoly, x, y, yErr)); 764 } 765 712 766 int polyOrder = myPoly->n; 713 767 psImage* A = NULL; -
trunk/psLib/src/dataManip/psStats.c
r1904 r1907 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.6 0$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09-27 2 0:37:48$11 * @version $Revision: 1.61 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-27 23:41:42 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 858 858 for (i = 0; i < myData->n; i++) { 859 859 myData->data.F32[i] = (myData->data.F32[i] - min) / range; 860 } 861 } 862 863 /***************************************************************************** 864 p_psNormalizeVectorF64(myData): this is a private function which normalizes the 865 elements of a vector to a range between -1.0 and 1.0. 866 867 XXX: incorporate this into above 868 869 XXX: 0-1 or -1:1? 870 *****************************************************************************/ 871 void p_psNormalizeVectorF64(psVector* myData) 872 { 873 float min = (float)HUGE; 874 float max = (float)-HUGE; 875 float range = 0.0; 876 int i = 0; 877 878 for (i = 0; i < myData->n; i++) { 879 if (myData->data.F64[i] < min) { 880 min = myData->data.F64[i]; 881 } 882 if (myData->data.F64[i] > max) { 883 max = myData->data.F64[i]; 884 } 885 } 886 887 range = max - min; 888 for (i = 0; i < myData->n; i++) { 889 myData->data.F64[i] = -1.0 + 2.0 * 890 ((myData->data.F64[i] - min) / range); 860 891 } 861 892 } -
trunk/psLib/src/dataManip/psStats.h
r1898 r1907 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 5 19:11:01$12 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-27 23:41:42 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 174 174 ); 175 175 176 177 void p_psNormalizeVector(psVector* myData); 178 void p_psNormalizeVectorF64(psVector* myData); 179 180 176 181 /// @} 177 182 -
trunk/psLib/src/math/psConstants.h
r1903 r1907 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-09-2 5 23:05:07$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-09-27 23:41:42 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 48 48 } 49 49 50 /** Preprocessor macro to generate error on a NULL image */ 51 #define PS_CHECK_NULL_IMAGE(NAME) \ 52 if (NAME == NULL || NAME->data.V == NULL) { \ 53 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 54 } 55 56 /** Preprocessor macro to generate error for zero length rows or columns */ 57 #define PS_CHECK_EMPTY_IMAGE(NAME) \ 58 if (NAME->numCols < 1 || NAME->numRows < 1) { \ 59 psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME, \ 60 NAME->numCols, NAME->numRows); \ 61 } 62 63 /** Preprocessor macro to generate error on a NULL 1DPolynomial */ 64 #define PS_CHECK_NULL_1DPOLY(NAME) \ 65 if (NAME == NULL || NAME->coeff == NULL) { \ 66 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 67 } 68 50 69 #define PS_PRINT_VECTOR(NAME) \ 51 70 for (int my_i=0;my_i<NAME->n;my_i++) { \ -
trunk/psLib/src/math/psMinimize.c
r1879 r1907 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.4 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09-2 4 20:08:22 $11 * @version $Revision: 1.49 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-27 23:41:42 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 53 53 /* DEFINE STATEMENTS */ 54 54 /*****************************************************************************/ 55 56 /** Preprocessor macro to generate error on a NULL 1DPolynomial */57 #define PS_CHECK_NULL_1DPOLY(NAME) \58 if (NAME == NULL || NAME->coeff == NULL) { \59 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \60 }61 62 /** Preprocessor macro to generate error on a NULL vector */63 #define PS_CHECK_NULL_VECTOR(NAME) \64 if (NAME == NULL || NAME->data.V == NULL) { \65 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \66 }67 68 /** Preprocessor macro to generate error for zero length vector */69 #define PS_CHECK_EMPTY_VECTOR(NAME) \70 if (NAME->n < 1) { \71 psError(__func__,"Invalid operation: %s has zero n value.", #NAME); \72 }73 74 /** Preprocessor macro to generate error on differing size vectors */75 #define PS_CHECK_VECTOR_SIZE_EQUAL(VEC1, VEC2) \76 if (VEC1->n != VEC2->n) { \77 psError(__func__,"Vector %s has size %d, Vector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \78 }79 80 /** Preprocessor macro to generate error on a NULL image */81 #define PS_CHECK_NULL_IMAGE(NAME) \82 if (NAME == NULL || NAME->data.V == NULL) { \83 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \84 }85 86 /** Preprocessor macro to generate error for zero length rows or columns */87 #define PS_CHECK_EMPTY_IMAGE(NAME) \88 if (NAME->numCols < 1 || NAME->numRows < 1) { \89 psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME, \90 NAME->numCols, NAME->numRows); \91 }92 55 93 56 /*****************************************************************************/ … … 692 655 } 693 656 657 658 /***************************************************************************** 659 CreateChebyshevPolys(n): this routine takes as input the required order n, 660 and returns as output as a pointer to an array of n psPolynomial1D 661 structures, corresponding to the first n Chebyshev polynomials. 662 663 XXX: The output should be static since the Chebyshev polynomials might be 664 used frequently and the data structure created here does not contain the 665 outer coefficients of the Chebyshev polynomials. 666 *****************************************************************************/ 667 static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly) 668 { 669 psPolynomial1D **chebPolys = NULL; 670 int i = 0; 671 int j = 0; 672 673 chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *)); 674 for (i = 0; i < maxChebyPoly; i++) { 675 chebPolys[i] = psPolynomial1DAlloc(i + 1, PS_POLYNOMIAL_ORD); 676 } 677 678 // Create the Chebyshev polynomials. 679 // Polynomial i has i-th order. 680 chebPolys[0]->coeff[0] = 1; 681 chebPolys[1]->coeff[1] = 1; 682 for (i = 2; i < maxChebyPoly; i++) { 683 for (j = 0; j < chebPolys[i - 1]->n; j++) { 684 chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j]; 685 } 686 for (j = 0; j < chebPolys[i - 2]->n; j++) { 687 chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j]; 688 } 689 } 690 691 return (chebPolys); 692 } 693 694 695 696 psPolynomial1D* p_psVectorFitPolynomial1DCheby(psPolynomial1D* myPoly, 697 const psVector* restrict x, 698 const psVector* restrict y, 699 const psVector* restrict yErr) 700 { 701 int j; 702 int k; 703 int n = x->n; 704 psPolynomial1D **chebPolys = CreateChebyshevPolys(myPoly->n); 705 ; 706 float fac; 707 float sum; 708 /* 709 fac = 2.0/((float) n); 710 for (j=0;j<n;j++) { 711 sum = 0.0; 712 for (k=0;k<n;k++) { 713 sum+= y->data.F64[k] * 714 cos(M_PI * ((float) j) * (0.5 + ((float) k)) / ((float) n)); 715 // sum+= y->data.F64[k] * 716 // cos(M_PI * ((float) j) * (-0.5 + ((float) k)) / ((float) n)) * 717 // cos(M_PI * (-0.5 + ((float) k)) / ((float) n)); 718 719 } 720 myPoly->coeff[j] = fac * sum; 721 722 } 723 return(myPoly); 724 */ 725 726 fac = 2.0/((float) n); 727 for (j=0;j<myPoly->n;j++) { 728 sum = 0.0; 729 for (k=1;k<n;k++) { 730 sum+= (y->data.F64[k] * 731 psPolynomial1DEval((float) x->data.F64[k], chebPolys[j])); 732 } 733 myPoly->coeff[j] = fac * sum; 734 } 735 return(myPoly); 736 } 737 694 738 /****************************************************************************** 695 739 psVectorFitPolynomial1D(): This routine must fit a polynomial of degree … … 704 748 705 749 XXX: Must do: if yErr==NULL, set all errors equal. 750 751 XXX: type is currently ignored. Must implement this for Chebyshev 752 polynomials. 706 753 *****************************************************************************/ 707 754 psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* myPoly, … … 710 757 const psVector* restrict yErr) 711 758 { 759 // XXX: Create a p_psVectorFitPolynomial1DOrd() function. Here, we 760 // should only be calling that or the Cheby function. 761 762 if (myPoly->type == PS_POLYNOMIAL_CHEB) { 763 return(p_psVectorFitPolynomial1DCheby(myPoly, x, y, yErr)); 764 } 765 712 766 int polyOrder = myPoly->n; 713 767 psImage* A = NULL; -
trunk/psLib/src/math/psPolynomial.c
r1903 r1907 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.4 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-2 5 23:05:07$9 * @version $Revision: 1.42 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-27 23:41:42 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 111 111 /*****************************************************************************/ 112 112 113 static psPolynomial1D* *CreateChebyshevPolys(int maxChebyPoly) 113 /***************************************************************************** 114 CreateChebyshevPolys(n): this routine takes as input the required order n, 115 and returns as output as a pointer to an array of n psPolynomial1D 116 structures, corresponding to the first n Chebyshev polynomials. 117 118 XXX: The output should be static since the Chebyshev polynomials might be 119 used frequently and the data structure created here does not contain the 120 outer coefficients of the Chebyshev polynomials. 121 *****************************************************************************/ 122 static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly) 114 123 { 115 124 psPolynomial1D **chebPolys = NULL; … … 430 439 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 431 440 432 XXX: Determine, from IfA, whether or not the "mask[]" terms should be used433 in polynomial evaluation. If so, then all of the following polynomial434 evaluation functions must be modified to do so.435 436 441 XXX: Should the "coeffErr[]" should be used as well? 437 442 *****************************************************************************/ … … 502 507 psFree(d); 503 508 return(tmp); 509 /* 510 int n; 511 int i; 512 float tmp; 513 psPolynomial1D **chebPolys = NULL; 514 515 n = myPoly->n; 516 chebPolys = CreateChebyshevPolys(n); 517 518 tmp = 0.0; 519 for (i=0;i<myPoly->n;i++) { 520 tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i])); 521 } 522 tmp-= (myPoly->coeff[0]/2.0); 523 return(tmp); 524 */ 504 525 } 505 526 -
trunk/psLib/src/math/psSpline.c
r1903 r1907 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.4 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-2 5 23:05:07$9 * @version $Revision: 1.42 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-27 23:41:42 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 111 111 /*****************************************************************************/ 112 112 113 static psPolynomial1D* *CreateChebyshevPolys(int maxChebyPoly) 113 /***************************************************************************** 114 CreateChebyshevPolys(n): this routine takes as input the required order n, 115 and returns as output as a pointer to an array of n psPolynomial1D 116 structures, corresponding to the first n Chebyshev polynomials. 117 118 XXX: The output should be static since the Chebyshev polynomials might be 119 used frequently and the data structure created here does not contain the 120 outer coefficients of the Chebyshev polynomials. 121 *****************************************************************************/ 122 static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly) 114 123 { 115 124 psPolynomial1D **chebPolys = NULL; … … 430 439 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 431 440 432 XXX: Determine, from IfA, whether or not the "mask[]" terms should be used433 in polynomial evaluation. If so, then all of the following polynomial434 evaluation functions must be modified to do so.435 436 441 XXX: Should the "coeffErr[]" should be used as well? 437 442 *****************************************************************************/ … … 502 507 psFree(d); 503 508 return(tmp); 509 /* 510 int n; 511 int i; 512 float tmp; 513 psPolynomial1D **chebPolys = NULL; 514 515 n = myPoly->n; 516 chebPolys = CreateChebyshevPolys(n); 517 518 tmp = 0.0; 519 for (i=0;i<myPoly->n;i++) { 520 tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i])); 521 } 522 tmp-= (myPoly->coeff[0]/2.0); 523 return(tmp); 524 */ 504 525 } 505 526 -
trunk/psLib/src/math/psStats.c
r1904 r1907 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.6 0$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09-27 2 0:37:48$11 * @version $Revision: 1.61 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-27 23:41:42 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 858 858 for (i = 0; i < myData->n; i++) { 859 859 myData->data.F32[i] = (myData->data.F32[i] - min) / range; 860 } 861 } 862 863 /***************************************************************************** 864 p_psNormalizeVectorF64(myData): this is a private function which normalizes the 865 elements of a vector to a range between -1.0 and 1.0. 866 867 XXX: incorporate this into above 868 869 XXX: 0-1 or -1:1? 870 *****************************************************************************/ 871 void p_psNormalizeVectorF64(psVector* myData) 872 { 873 float min = (float)HUGE; 874 float max = (float)-HUGE; 875 float range = 0.0; 876 int i = 0; 877 878 for (i = 0; i < myData->n; i++) { 879 if (myData->data.F64[i] < min) { 880 min = myData->data.F64[i]; 881 } 882 if (myData->data.F64[i] > max) { 883 max = myData->data.F64[i]; 884 } 885 } 886 887 range = max - min; 888 for (i = 0; i < myData->n; i++) { 889 myData->data.F64[i] = -1.0 + 2.0 * 890 ((myData->data.F64[i] - min) / range); 860 891 } 861 892 } -
trunk/psLib/src/math/psStats.h
r1898 r1907 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 5 19:11:01$12 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-27 23:41:42 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 174 174 ); 175 175 176 177 void p_psNormalizeVector(psVector* myData); 178 void p_psNormalizeVectorF64(psVector* myData); 179 180 176 181 /// @} 177 182 -
trunk/psLib/test/dataManip/Makefile
r1900 r1907 3 3 ## Makefile: test/sysUtils 4 4 ## 5 ## $Revision: 1.4 5$ $Name: not supported by cvs2svn $6 ## $Date: 2004-09-2 5 20:17:43$5 ## $Revision: 1.46 $ $Name: not supported by cvs2svn $ 6 ## $Date: 2004-09-27 23:41:42 $ 7 7 ## 8 8 ## Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 42 42 tst_psMatrixVectorArithmetic03 \ 43 43 tst_psMinimize04 \ 44 tst_psMinimize04b \ 44 45 tst_psMinimize05 \ 45 46 tst_psMinimize06 \ -
trunk/psLib/test/dataManip/tst_psMinimize04.c
r1811 r1907 12 12 #include <math.h> 13 13 #define NUM_DATA 10 14 #define POLY_ORDER 214 #define POLY_ORDER 5 15 15 16 16 double setData(double A, … … 40 40 for (i=0;i<NUM_DATA;i++) { 41 41 x->data.F64[i] = (double) i; 42 y->data.F64[i] = setData( 2.0, 3.0, 2.0, x->data.F64[i]);42 y->data.F64[i] = setData(3.0, 2.0, 3.0, x->data.F64[i]); 43 43 yErr->data.F64[i] = 0.1; 44 44 printf("Original data %d: (%.1f %.1f)\n", i, x->data.F64[i], y->data.F64[i]);
Note:
See TracChangeset
for help on using the changeset viewer.
