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