00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef GIMATH_LM_H
00029 #define GIMATH_LM_H
00030
00031 #include <cxtypes.h>
00032
00033 #include <cpl_matrix.h>
00034
00035
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039
00040
00041 #define LMRQ_DCHISQ 0.0001
00042 #define LMRQ_ITERMAX 30
00043 #define LMRQ_TESTMAX 7
00044 #define LMRQ_NPARAMS 3
00045
00046 #define DW_DEGREE 3
00047 #define DW_LOG001 2.302585093
00048
00049
00050 #define LMI_WLEN 0
00051 #define LMI_XFIB 1
00052 #define LMI_YFIB 2
00053
00054
00055 #define LMP_NX 0
00056 #define LMP_NY 0
00057 #define LMP_PXSIZ 1
00058 #define LMP_FCOLL 2
00059 #define LMP_CFACT 3
00060 #define LMP_THETA 4
00061 #define LMP_ORDER 5
00062 #define LMP_SPACE 6
00063 #define LMP_SOFFX 7
00064 #define LMP_SOFFY 8
00065 #define LMP_SPHI 9
00066
00067
00068 #define LMP_AMPL 0
00069 #define LMP_CENT 1
00070 #define LMP_BACK 2
00071 #define LMP_WID1 3
00072 #define LMP_WID2 4
00073
00074
00075 #define LMP_TX 0
00076 #define LMP_TY 1
00077 #define LMP_CX 2
00078 #define LMP_KY 3
00079 #define LMP_TT 4
00080
00081
00082 #define LMI_XCCD 0
00083 #define LMI_NX 1
00084 #define LMI_STRX 2
00085 #define LMI_NCOF 3
00086
00094 typedef void (*fitted_func)(double[], double[], double[], double *, double[], int);
00095
00101 struct lmrq_params {
00102 cxint imax;
00103 cxint tmax;
00104 cxdouble dchsq;
00105 };
00106
00107 typedef struct lmrq_params lmrq_params;
00108
00113 enum _lmrq_model_id_ {
00114 LMRQ_GAUSSUM,
00115 LMRQ_XOPTMOD,
00116 LMRQ_XOPTMODGS,
00117 LMRQ_XOPTMOD2,
00118 LMRQ_PSFCOS,
00119 LMRQ_PSFEXP,
00120 LMRQ_YOPTMOD,
00121 LMRQ_YOPTMOD2,
00122 LMRQ_LOCYWARP,
00123 LMRQ_PSFEXP2,
00124 LMRQ_TEST,
00125 LMRQ_UNDEFINED
00126 };
00127
00128 typedef enum _lmrq_model_id_ lmrq_model_id;
00129
00134 enum lmrq_model_type {
00135 LINE_MODEL,
00136 XOPT_MODEL,
00137 YOPT_MODEL,
00138 LOCY_MODEL
00139 };
00140
00141 typedef enum lmrq_model_type lmrq_model_type;
00142
00147 struct lmrq_model {
00148 lmrq_model_id id;
00149 fitted_func cfunc;
00150 cxint nparams;
00151 cxint ninputs;
00152 cxchar name[256];
00153 lmrq_model_type type;
00154 };
00155
00156 typedef struct lmrq_model lmrq_model;
00157
00158
00159 cxint mrqnlfit(cpl_matrix *, cpl_matrix *, cpl_matrix *, cxint, cpl_matrix *,
00160 cxdouble[], cxint[], cxint, cpl_matrix *, cxdouble *,
00161 lmrq_params, fitted_func);
00162
00163 cxint mymrqmin(cpl_matrix *, cpl_matrix *, cpl_matrix *, cxint, cpl_matrix *,
00164 cxdouble[], cxint[], cxint, cpl_matrix *, cpl_matrix *,
00165 cxdouble *, fitted_func, cxdouble *);
00166
00167 cxint mymrqcof(cpl_matrix *, cpl_matrix *, cpl_matrix *, cxint, cpl_matrix *,
00168 cxdouble[], cxint[], cxint, cpl_matrix *, cpl_matrix *,
00169 cxdouble *, fitted_func);
00170
00171 cxdouble r_squared(cxdouble, cpl_matrix *, cxint);
00172
00173
00174
00175 void mrqgaussum(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00176 cxdouble[], cxint);
00177
00178 void mrqxoptmod(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00179 cxdouble[], cxint);
00180
00181 void mrqxoptmod2(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00182 cxdouble[], cxint);
00183
00184 void mrqyoptmod(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00185 cxdouble[], cxint);
00186
00187 void mrqyoptmod2(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00188 cxdouble[], cxint);
00189
00190 void mrqpsfcos(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00191 cxdouble[], cxint);
00192
00193 void mrqpsfexp(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00194 cxdouble[], cxint);
00195
00196 void mrqpsfexp2(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00197 cxdouble[], cxint);
00198
00199 void mrqlocywarp(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00200 cxdouble[], cxint);
00201
00202 void mrqxoptmodGS(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00203 cxdouble[], cxint);
00204
00205 void mrqtest(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00206 cxdouble[], cxint);
00207
00208 extern lmrq_model lmrq_models[];
00209 extern cxint nr_lmrq_models;
00210
00211
00212 #ifdef __cplusplus
00213 }
00214 #endif
00215
00216 #endif