00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef PS_MINIMIZE_LMM_H
00015 #define PS_MINIMIZE_LMM_H
00016
00017
00018
00019
00020 #include "psVector.h"
00021 #include "psMemory.h"
00022 #include "psArray.h"
00023 #include "psImage.h"
00024 #include "psMatrix.h"
00025 #include "psPolynomial.h"
00026 #include "psSpline.h"
00027 #include "psStats.h"
00028 #include "psTrace.h"
00029 #include "psError.h"
00030 #include "psConstants.h"
00031
00032 #define PS_DETERMINE_BRACKET_STEP_SIZE 0.10
00033 #define PS_MAX_LMM_ITERATIONS 100
00034 #define PS_MAX_MINIMIZE_ITERATIONS 100
00035 #define P_PSMINIMIZATION_SET_MAXITER(m,val) *(int*)&m->maxIter = val
00036 #define P_PSMINIMIZATION_SET_TOL(m,val) *(float*)&m->tol = val
00037
00038 typedef enum {
00039 PS_MINIMIZE_BETA_LIMIT,
00040 PS_MINIMIZE_PARAM_MIN,
00041 PS_MINIMIZE_PARAM_MAX
00042 } psMinConstraintMode;
00043
00044
00045
00046
00047
00048
00049
00050 typedef
00051 float (*psMinimizeLMChi2Func)(
00052 psVector *deriv,
00053 const psVector *params,
00054 const psVector *x
00055 );
00056
00057
00058
00059
00060
00061
00062
00063 typedef
00064 bool (*psMinimizeLMLimitFunc)(
00065 psMinConstraintMode mode,
00066 int nParam,
00067 float *params,
00068 float *beta
00069 );
00070
00071
00072
00073
00074
00075 typedef struct
00076 {
00077 const int maxIter;
00078 const float tol;
00079 float value;
00080 int iter;
00081 float lastDelta;
00082 }
00083 psMinimization;
00084
00085
00086
00087
00088
00089 typedef struct
00090 {
00091 psVector *paramMask;
00092 psMinimizeLMLimitFunc checkLimits;
00093 }
00094 psMinConstraint;
00095
00096 psMinConstraint *psMinConstraintAlloc();
00097
00098
00099
00100
00101
00102 psMinimization *psMinimizationAlloc(
00103 int maxIter,
00104 float tol
00105 );
00106
00107
00108
00109
00110
00111
00112
00113 bool psMemCheckMinimization(
00114 psPtr ptr
00115 );
00116
00117
00118
00119
00120
00121 bool psMinimizeLMChi2(
00122 psMinimization *min,
00123 psImage *covar,
00124 psVector *params,
00125 psMinConstraint *constraint,
00126 const psArray *x,
00127 const psVector *y,
00128 const psVector *yWt,
00129 psMinimizeLMChi2Func func
00130 );
00131
00132 bool psMinimizeGaussNewtonDelta (
00133 psVector *delta,
00134 const psVector *params,
00135 const psVector *paramMask,
00136 const psArray *x,
00137 const psVector *y,
00138 const psVector *yErr,
00139 psMinimizeLMChi2Func func
00140 );
00141
00142
00143
00144
00145
00146 psF32 p_psMinLM_SetABX (
00147 psImage *alpha,
00148 psVector *beta,
00149 const psVector *params,
00150 const psVector *paramMask,
00151 const psArray *x,
00152 const psVector *y,
00153 const psVector *dy,
00154 psMinimizeLMChi2Func func
00155 );
00156
00157
00158 psBool p_psMinLM_GuessABP(
00159 psImage *Alpha,
00160 psVector *Beta,
00161 psVector *Params,
00162 const psImage *alpha,
00163 const psVector *beta,
00164 const psVector *params,
00165 const psVector *paramMask,
00166 psMinimizeLMLimitFunc checkLimits,
00167 psF32 lambda
00168 );
00169
00170
00171 #endif // #ifndef PS_MINIMIZE_LMM_H