Changeset 1837 for trunk/psLib/src/dataManip/psMinimize.h
- Timestamp:
- Sep 20, 2004, 1:43:53 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/dataManip/psMinimize.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psMinimize.h
r1831 r1837 3 3 * @ingroup Math 4 4 * 5 * This file will contain function prototypes... 5 * This file will contain function prototypes for various minimization, 6 * chi-squared minimization, and 1-D polynomial fitting routines. 6 7 * 7 8 * @author George Gusciora, MHPCC 8 9 * 9 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09- 18 01:50:45$10 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-09-20 23:43:53 $ 11 12 * 12 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 27 * \ingroup Stats 27 28 */ 28 29 /** Functions **************************************************************/30 31 29 /** \addtogroup Stats 32 30 * \{ 33 31 */ 34 32 35 /** function of a collection of parameters and coordinate vector. 36 * 37 * @return float value to minimize 38 */ 39 typedef float (*psMinimizeFunction)( 40 const psVector* restrict params, ///< collection of parameters 41 const psVector* restrict coord ///< coordinates 42 ); 33 typedef struct 34 { 35 int maxIter; ///< Convergence limit 36 float tol; ///< Error Tolerance 37 float value; ///< Value of function at minimum 38 int iter; ///< Number of iterations required 39 float lastDelta; ///< The last difference for the fit 40 } 41 psMinimization; 43 42 44 /** derivative function of psMinimizeFunction 45 * 46 * @return float the derivative in respect to params[derivParam] 47 */ 48 typedef float (*psMinimizeFunctionDeriv) ( 49 const psVector* restrict params, ///< collection of parameters 50 const psVector* restrict coord, ///< coordinates 51 int derivParam ///< index of parameter to calculate derivative of 52 ); 53 54 /** Minimizes a non-linear function. 55 * 56 * psMinimize determines and returns the vector that minimizes the specified 57 * function. It takes as input a function, myFunction, an initial guess for 58 * the vector that minimizes the function, initialGuess, the current 59 * coordiate coord, and an optional mask for the vector elements (function 60 * parameters) to minimize, paramMask (all parameters are fit if PSLib SDRS 61 * 25 July 13, 2004 Pan-STARRS Image Processing Pipeline PSDC-430-007-04 62 * NULL). Note that paramMask must be of type psU8, while params must be of 63 * type psF32. The optional function, myFuncDeriv returns the derivative of 64 * the function. This function must be valid only for types psF32, psF64. 65 * 66 * @return psVector* minimized vector 67 */ 68 psVector* psMinimize( 69 psVector* restrict initialGuess, 70 psMinimizeFunction myFunction, 71 psMinimizeFunctionDeriv myFunctionDeriv, 72 const psVector* restrict coord, 73 const psVector* restrict paramMask 74 ); 75 76 /** Minimize chi^2 for input data. 77 * 78 * psMinimizeChi2 fits a model to observations by minimizing chi^2, returning 79 * the best-fit parameters. The input parameters are a function that 80 * evaluates the model for a specified domain, given the parameters, 81 * evalModel; a list of observations, (domain, data, and errors); an initial 82 * guess at the best-fit parameters, initialGuess which is returned with the 83 * best-fit parameters, and an optional mask specifying which parameters are 84 * to be fit, paramMask, which must be of type psU8. All parameters are fit 85 * if this vector is NULL. This function must be valid only for types psF32, 86 * psF64. 87 * 88 * @return psVector* minimized vector 89 */ 90 psVector* psMinimizeChi2( 91 psMinimizeFunction evalModel, ///< Model to fit; (domain and params) 92 psMinimizeFunctionDeriv DevalModel,///< Derivative of model to fit; (domain and params) 93 const psImage* restrict domain, ///< The domain values for the corresponding measurements 94 const psVector* restrict data, ///< Data to fit 95 const psVector* restrict errors, ///< Errors in the data 96 psVector* restrict initialGuess, ///< Initial guess 97 const psVector* restrict paramMask,///< 1 = fit for parameter, 0 = hold parameter constant 98 float *chiSq ///< chi squared 99 ); 43 psMinimization *psMinimizationAlloc(int maxIter, 44 float tol); 100 45 101 46 /** Derive a polynomial fit by chi^2 minimisation (analytically) … … 119 64 ); 120 65 121 typedef struct 122 { 123 int maxIter; ///< Convergence limit 124 float tol; ///< Error Tolerance 125 float value; ///< Value of function at minimum 126 int iter; ///< Number of iterations required 127 float lastDelta; ///< The last difference for the fit 128 } 129 psMinimization; 130 131 psMinimization *psMinimizationAlloc(int maxIter, float tol); 132 133 134 135 typedef float (*psMinimizeLMFunc) (psVector *deriv, 136 const psVector *params, 137 const psArray *coords); 138 139 typedef float (*psMinimizeLMChi2Func) (psVector *deriv, 140 const psVector *params, 141 const psVector *coords); 142 143 bool psMinimizeLM(psMinimization *min, 144 psImage *covar, 145 psVector *params, 146 const psVector *paramMask, 147 const psArray *coords, 148 psMinimizeLMFunc func); 66 typedef 67 float (*psMinimizeLMChi2Func)(psVector *deriv, 68 const psVector *params, 69 const psVector *coords); 149 70 150 71 bool psMinimizeLMChi2(psMinimization *min, … … 156 77 psMinimizeLMChi2Func func); 157 78 158 159 160 typedef float (*psMinimizePowellFunc) (const psVector *params, 161 const psArray *coords); 79 typedef 80 float (*psMinimizePowellFunc)(const psVector *params, 81 const psArray *coords); 162 82 163 83 bool psMinimizePowell(psMinimization *min, … … 167 87 psMinimizePowellFunc func); 168 88 169 typedef psVector* (*psMinimizeChi2PowellFunc) (const psVector *params, 170 const psArray *coords); 89 typedef 90 psVector *(*psMinimizeChi2PowellFunc)(const psVector *params, 91 const psArray *coords); 171 92 172 93 bool psMinimizeChi2Powell(psMinimization *min, … … 178 99 psMinimizeChi2PowellFunc func); 179 100 180 181 bool psMinimize1DFunc(psMinimization *min,182 psVector *params,183 int dim,184 const psArray *coords,185 psMinimizePowellFunc func);186 187 float psLineMin(psMinimization *min,188 psVector *params,189 psVector *line,190 const psVector *paramMask,191 const psArray *coords,192 psMinimizePowellFunc func);193 194 195 101 /* \} */// End of MathGroup Functions 196 102
Note:
See TracChangeset
for help on using the changeset viewer.
