Changeset 1734
- Timestamp:
- Sep 8, 2004, 1:32:03 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 7 edited
-
dataManip/psFunctions.c (modified) (5 diffs)
-
dataManip/psMinimize.c (modified) (9 diffs)
-
dataManip/psMinimize.h (modified) (4 diffs)
-
math/psMinimize.c (modified) (9 diffs)
-
math/psMinimize.h (modified) (4 diffs)
-
math/psPolynomial.c (modified) (5 diffs)
-
math/psSpline.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psFunctions.c
r1725 r1734 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-08 07:11:22$9 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-08 23:32:03 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 125 125 float tmp = 1.0; 126 126 127 psTrace(".psLib.dataManip.psFunctions.psGaussian", 4, 128 "---- psGaussian() begin ----\n"); 129 127 130 if (normal == true) { 128 131 #ifdef DARWIN … … 135 138 } 136 139 140 psTrace(".psLib.dataManip.psFunctions.psGaussian", 4, 141 "---- psGaussian() end ----\n"); 137 142 return(tmp * exp(-((x - mean) * (x - mean)) / (2.0 * sigma * sigma))); 138 143 } … … 1368 1373 1369 1374 /***************************************************************************** 1370 1371 1375 NOTE: "n" specifies the number of spline polynomials. Therefore, there 1372 1376 must exist n+1 points in "domains". … … 1504 1508 return(tmpVector); 1505 1509 } 1506 -
trunk/psLib/src/dataManip/psMinimize.c
r1719 r1734 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09-08 06:02:23 $11 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-08 23:32:03 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 15 * 16 * XXX: must follow coding name standards on local functions. 17 * 15 18 */ 16 19 17 20 /*****************************************************************************/ 18 19 21 /* INCLUDE FILES */ 20 21 22 /*****************************************************************************/ 22 23 #include <stdlib.h> … … 46 47 47 48 /*****************************************************************************/ 48 49 49 /* DEFINE STATEMENTS */ 50 51 50 /*****************************************************************************/ 51 52 52 #define MAX_LMM_ITERATIONS 100 53 53 #define MAX_MINIMIZE_ITERATIONS 100 … … 91 91 92 92 /*****************************************************************************/ 93 94 93 /* TYPE DEFINITIONS */ 95 96 94 /*****************************************************************************/ 95 97 96 typedef struct 98 97 { … … 121 120 122 121 /*****************************************************************************/ 123 124 122 /* GLOBAL VARIABLES */ 125 126 123 /*****************************************************************************/ 127 124 125 static psMinimizeChi2PowellFunc Chi2PowellFunc = NULL; 126 //static psMinimizePowellFunc PowellFunc = NULL; 127 static psVector *myValue; 128 static psVector *myError; 129 130 /*****************************************************************************/ 131 /* FILE STATIC VARIABLES */ 132 /*****************************************************************************/ 133 128 134 // None 129 135 130 136 /*****************************************************************************/ 131 132 /* FILE STATIC VARIABLES */133 134 /*****************************************************************************/135 136 // None137 138 /*****************************************************************************/139 140 137 /* FUNCTION IMPLEMENTATION - LOCAL */ 141 142 138 /*****************************************************************************/ 143 139 … … 543 539 544 540 /*****************************************************************************/ 545 546 541 /* FUNCTION IMPLEMENTATION - PUBLIC */ 547 548 542 /*****************************************************************************/ 549 543 … … 850 844 return (initialGuess); 851 845 } 846 /****************************************************************************** 847 GUS 848 849 XXX: bug report for the psMatrix covar argument. 850 *****************************************************************************/ 851 bool psMinimizeLM(psMinimization *min, 852 psImage *covar, 853 psVector *params, 854 const psVector *paramMask, 855 const psArray *coords, 856 psMinimizeLMFunc func) 857 { 858 /* 859 psVector *beta = psVectorAlloc(params->n, PS_TYPE_F32); 860 psImage *alpha = psImageAlloc(params->n, params->n, PS_TYPE_F32); 861 psVector *deriv; 862 int i; 863 int k; 864 float tmp; 865 866 tmp = func(deriv, params, coords); 867 for (k=0;k<params->n;k++) { 868 beta->data.F32[k] = 0.0; 869 for (i=0;i<params->n;i++) { 870 beta->data.F32[k]+= deriv 871 } 872 */ 873 return(false); 874 } 875 852 876 853 877 /****************************************************************************** … … 856 880 error for each data point (yErr). 857 881 858 NOTE: yErr is currently ignored.882 XXX: NOTE: yErr is currently ignored. 859 883 *****************************************************************************/ 860 884 psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* myPoly, … … 1505 1529 1506 1530 /****************************************************************************** 1507 This routine must minimize a possibly multi-dimensional function. 1531 This routine must minimize a possibly multi-dimensional function. The 1532 function to be minimized "func" is: 1533 float func(psVector *params, psArray *coords) 1534 The "params" are the parameters of the function which are varied. The data 1535 points at which the function is varied are in the argument "coords" which is 1536 a psArray of psVectors: each vector represents a different coordinate. 1537 1538 XXX: We do not use Brent's method. 1539 1540 XXX: We do not use the 1508 1541 *****************************************************************************/ 1509 1542 bool psMinimizePowell(psMinimization *min, … … 1672 1705 return(false); 1673 1706 } 1707 1708 /****************************************************************************** 1709 This routine is to be used with the psMinimizeChi2Powell() function below. 1710 and the psMinimizePowell() function above. 1711 1712 The basic idea is calculate chi-squared for a set of params/coords/errors. 1713 This functions uses globale variables to receive the function pointer, the 1714 data values, and the data errors. 1715 *****************************************************************************/ 1716 float myPowellChi2Func(const psVector *params, 1717 const psArray *coords) 1718 { 1719 float chi2 = 0.0; 1720 float d; 1721 int i; 1722 psVector *tmp; 1723 1724 tmp = Chi2PowellFunc(params, coords); 1725 for (i=0;i<coords->n;i++) { 1726 d = (tmp->data.F32[i] - myValue->data.F32[i]) / myError->data.F32[i]; 1727 chi2+= d * d; 1728 } 1729 psFree(tmp); 1730 return(chi2); 1731 } 1732 1733 1734 /****************************************************************************** 1735 This routine must minimize the chi-squared match of a set of data points and 1736 values for a possibly multi-dimensional function. 1737 1738 The basic idea is to use the psMinimizePowell() function defined above. In 1739 order to do so, we defined above a function myPowellChi2Func() which takes 1740 the "func" function and returns chi-squared over the params/coords/values. 1741 We then use that function myPowellChi2Func() in the call to 1742 psMinimizePowell(). 1743 *****************************************************************************/ 1744 bool psMinimizeChi2Powell(psMinimization *min, 1745 psVector *params, 1746 const psVector *paramMask, 1747 const psArray *coords, 1748 const psVector *value, 1749 const psVector *error, 1750 psMinimizeChi2PowellFunc func) 1751 { 1752 myValue = (psVector *) value; 1753 myError = (psVector *) error; 1754 Chi2PowellFunc = func; 1755 1756 return(psMinimizePowell(min, params, paramMask, coords, myPowellChi2Func)); 1757 } -
trunk/psLib/src/dataManip/psMinimize.h
r1719 r1734 1 /** @file psMinimize.c 2 * \brief basic minimization functions 3 * @ingroup Math 4 * 5 * This file will contain function prototypes... 6 * 7 * @author George Gusciora, MHPCC 8 * 9 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-08 23:32:03 $ 11 * 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 13 * 14 */ 15 1 16 #if !defined(PS_MINIMIZE_H) 2 17 #define PS_MINIMIZE_H … … 5 20 #include "psArray.h" 6 21 #include "psVector.h" 22 #include "psMatrix.h" 7 23 8 24 /** \file psMinimize.h … … 115 131 psMinimization *psMinimizationAlloc(int maxIter, float tol); 116 132 133 134 135 typedef float (*psMinimizeLMFunc) (psVector *deriv, 136 const psVector *params, 137 const psArray *coords); 138 139 bool psMinimizeLM(psMinimization *min, 140 psImage *covar, 141 psVector *params, 142 const psVector *paramMask, 143 const psArray *coords, 144 psMinimizeLMFunc func); 145 146 147 117 148 typedef float (*psMinimizePowellFunc) (const psVector *params, 118 149 const psArray *coords); … … 124 155 psMinimizePowellFunc func); 125 156 126 typedef psVector* ( psMinimizeChi2PowellFunc) (const psVector *params,157 typedef psVector* (*psMinimizeChi2PowellFunc) (const psVector *params, 127 158 const psArray *coords); 128 159 -
trunk/psLib/src/math/psMinimize.c
r1719 r1734 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09-08 06:02:23 $11 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-08 23:32:03 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 15 * 16 * XXX: must follow coding name standards on local functions. 17 * 15 18 */ 16 19 17 20 /*****************************************************************************/ 18 19 21 /* INCLUDE FILES */ 20 21 22 /*****************************************************************************/ 22 23 #include <stdlib.h> … … 46 47 47 48 /*****************************************************************************/ 48 49 49 /* DEFINE STATEMENTS */ 50 51 50 /*****************************************************************************/ 51 52 52 #define MAX_LMM_ITERATIONS 100 53 53 #define MAX_MINIMIZE_ITERATIONS 100 … … 91 91 92 92 /*****************************************************************************/ 93 94 93 /* TYPE DEFINITIONS */ 95 96 94 /*****************************************************************************/ 95 97 96 typedef struct 98 97 { … … 121 120 122 121 /*****************************************************************************/ 123 124 122 /* GLOBAL VARIABLES */ 125 126 123 /*****************************************************************************/ 127 124 125 static psMinimizeChi2PowellFunc Chi2PowellFunc = NULL; 126 //static psMinimizePowellFunc PowellFunc = NULL; 127 static psVector *myValue; 128 static psVector *myError; 129 130 /*****************************************************************************/ 131 /* FILE STATIC VARIABLES */ 132 /*****************************************************************************/ 133 128 134 // None 129 135 130 136 /*****************************************************************************/ 131 132 /* FILE STATIC VARIABLES */133 134 /*****************************************************************************/135 136 // None137 138 /*****************************************************************************/139 140 137 /* FUNCTION IMPLEMENTATION - LOCAL */ 141 142 138 /*****************************************************************************/ 143 139 … … 543 539 544 540 /*****************************************************************************/ 545 546 541 /* FUNCTION IMPLEMENTATION - PUBLIC */ 547 548 542 /*****************************************************************************/ 549 543 … … 850 844 return (initialGuess); 851 845 } 846 /****************************************************************************** 847 GUS 848 849 XXX: bug report for the psMatrix covar argument. 850 *****************************************************************************/ 851 bool psMinimizeLM(psMinimization *min, 852 psImage *covar, 853 psVector *params, 854 const psVector *paramMask, 855 const psArray *coords, 856 psMinimizeLMFunc func) 857 { 858 /* 859 psVector *beta = psVectorAlloc(params->n, PS_TYPE_F32); 860 psImage *alpha = psImageAlloc(params->n, params->n, PS_TYPE_F32); 861 psVector *deriv; 862 int i; 863 int k; 864 float tmp; 865 866 tmp = func(deriv, params, coords); 867 for (k=0;k<params->n;k++) { 868 beta->data.F32[k] = 0.0; 869 for (i=0;i<params->n;i++) { 870 beta->data.F32[k]+= deriv 871 } 872 */ 873 return(false); 874 } 875 852 876 853 877 /****************************************************************************** … … 856 880 error for each data point (yErr). 857 881 858 NOTE: yErr is currently ignored.882 XXX: NOTE: yErr is currently ignored. 859 883 *****************************************************************************/ 860 884 psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* myPoly, … … 1505 1529 1506 1530 /****************************************************************************** 1507 This routine must minimize a possibly multi-dimensional function. 1531 This routine must minimize a possibly multi-dimensional function. The 1532 function to be minimized "func" is: 1533 float func(psVector *params, psArray *coords) 1534 The "params" are the parameters of the function which are varied. The data 1535 points at which the function is varied are in the argument "coords" which is 1536 a psArray of psVectors: each vector represents a different coordinate. 1537 1538 XXX: We do not use Brent's method. 1539 1540 XXX: We do not use the 1508 1541 *****************************************************************************/ 1509 1542 bool psMinimizePowell(psMinimization *min, … … 1672 1705 return(false); 1673 1706 } 1707 1708 /****************************************************************************** 1709 This routine is to be used with the psMinimizeChi2Powell() function below. 1710 and the psMinimizePowell() function above. 1711 1712 The basic idea is calculate chi-squared for a set of params/coords/errors. 1713 This functions uses globale variables to receive the function pointer, the 1714 data values, and the data errors. 1715 *****************************************************************************/ 1716 float myPowellChi2Func(const psVector *params, 1717 const psArray *coords) 1718 { 1719 float chi2 = 0.0; 1720 float d; 1721 int i; 1722 psVector *tmp; 1723 1724 tmp = Chi2PowellFunc(params, coords); 1725 for (i=0;i<coords->n;i++) { 1726 d = (tmp->data.F32[i] - myValue->data.F32[i]) / myError->data.F32[i]; 1727 chi2+= d * d; 1728 } 1729 psFree(tmp); 1730 return(chi2); 1731 } 1732 1733 1734 /****************************************************************************** 1735 This routine must minimize the chi-squared match of a set of data points and 1736 values for a possibly multi-dimensional function. 1737 1738 The basic idea is to use the psMinimizePowell() function defined above. In 1739 order to do so, we defined above a function myPowellChi2Func() which takes 1740 the "func" function and returns chi-squared over the params/coords/values. 1741 We then use that function myPowellChi2Func() in the call to 1742 psMinimizePowell(). 1743 *****************************************************************************/ 1744 bool psMinimizeChi2Powell(psMinimization *min, 1745 psVector *params, 1746 const psVector *paramMask, 1747 const psArray *coords, 1748 const psVector *value, 1749 const psVector *error, 1750 psMinimizeChi2PowellFunc func) 1751 { 1752 myValue = (psVector *) value; 1753 myError = (psVector *) error; 1754 Chi2PowellFunc = func; 1755 1756 return(psMinimizePowell(min, params, paramMask, coords, myPowellChi2Func)); 1757 } -
trunk/psLib/src/math/psMinimize.h
r1719 r1734 1 /** @file psMinimize.c 2 * \brief basic minimization functions 3 * @ingroup Math 4 * 5 * This file will contain function prototypes... 6 * 7 * @author George Gusciora, MHPCC 8 * 9 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-08 23:32:03 $ 11 * 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 13 * 14 */ 15 1 16 #if !defined(PS_MINIMIZE_H) 2 17 #define PS_MINIMIZE_H … … 5 20 #include "psArray.h" 6 21 #include "psVector.h" 22 #include "psMatrix.h" 7 23 8 24 /** \file psMinimize.h … … 115 131 psMinimization *psMinimizationAlloc(int maxIter, float tol); 116 132 133 134 135 typedef float (*psMinimizeLMFunc) (psVector *deriv, 136 const psVector *params, 137 const psArray *coords); 138 139 bool psMinimizeLM(psMinimization *min, 140 psImage *covar, 141 psVector *params, 142 const psVector *paramMask, 143 const psArray *coords, 144 psMinimizeLMFunc func); 145 146 147 117 148 typedef float (*psMinimizePowellFunc) (const psVector *params, 118 149 const psArray *coords); … … 124 155 psMinimizePowellFunc func); 125 156 126 typedef psVector* ( psMinimizeChi2PowellFunc) (const psVector *params,157 typedef psVector* (*psMinimizeChi2PowellFunc) (const psVector *params, 127 158 const psArray *coords); 128 159 -
trunk/psLib/src/math/psPolynomial.c
r1725 r1734 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-08 07:11:22$9 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-08 23:32:03 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 125 125 float tmp = 1.0; 126 126 127 psTrace(".psLib.dataManip.psFunctions.psGaussian", 4, 128 "---- psGaussian() begin ----\n"); 129 127 130 if (normal == true) { 128 131 #ifdef DARWIN … … 135 138 } 136 139 140 psTrace(".psLib.dataManip.psFunctions.psGaussian", 4, 141 "---- psGaussian() end ----\n"); 137 142 return(tmp * exp(-((x - mean) * (x - mean)) / (2.0 * sigma * sigma))); 138 143 } … … 1368 1373 1369 1374 /***************************************************************************** 1370 1371 1375 NOTE: "n" specifies the number of spline polynomials. Therefore, there 1372 1376 must exist n+1 points in "domains". … … 1504 1508 return(tmpVector); 1505 1509 } 1506 -
trunk/psLib/src/math/psSpline.c
r1725 r1734 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-08 07:11:22$9 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-08 23:32:03 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 125 125 float tmp = 1.0; 126 126 127 psTrace(".psLib.dataManip.psFunctions.psGaussian", 4, 128 "---- psGaussian() begin ----\n"); 129 127 130 if (normal == true) { 128 131 #ifdef DARWIN … … 135 138 } 136 139 140 psTrace(".psLib.dataManip.psFunctions.psGaussian", 4, 141 "---- psGaussian() end ----\n"); 137 142 return(tmp * exp(-((x - mean) * (x - mean)) / (2.0 * sigma * sigma))); 138 143 } … … 1368 1373 1369 1374 /***************************************************************************** 1370 1371 1375 NOTE: "n" specifies the number of spline polynomials. Therefore, there 1372 1376 must exist n+1 points in "domains". … … 1504 1508 return(tmpVector); 1505 1509 } 1506
Note:
See TracChangeset
for help on using the changeset viewer.
