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
00093 typedef void (*fitted_func)(double[], double[], double[], double *, double[], int);
00094
00100 struct lmrq_params {
00101 cxint imax;
00102 cxint tmax;
00103 cxdouble dchsq;
00104 };
00105
00106 typedef struct lmrq_params lmrq_params;
00107
00112 enum _lmrq_model_id_ {
00113 LMRQ_GAUSSUM,
00114 LMRQ_XOPTMOD,
00115 LMRQ_XOPTMODGS,
00116 LMRQ_XOPTMOD2,
00117 LMRQ_PSFCOS,
00118 LMRQ_PSFEXP,
00119 LMRQ_YOPTMOD,
00120 LMRQ_YOPTMOD2,
00121 LMRQ_LOCYWARP,
00122 LMRQ_PSFEXP2,
00123 LMRQ_TEST,
00124 LMRQ_UNDEFINED
00125 };
00126
00127 typedef enum _lmrq_model_id_ lmrq_model_id;
00128
00133 enum lmrq_model_type {
00134 LINE_MODEL,
00135 XOPT_MODEL,
00136 YOPT_MODEL,
00137 LOCY_MODEL
00138 };
00139
00140 typedef enum lmrq_model_type lmrq_model_type;
00141
00146 struct lmrq_model {
00147 lmrq_model_id id;
00148 fitted_func cfunc;
00149 cxint nparams;
00150 cxint ninputs;
00151 cxchar name[256];
00152 lmrq_model_type type;
00153 };
00154
00155 typedef struct lmrq_model lmrq_model;
00156
00157
00158 cxint mrqnlfit(cpl_matrix *, cpl_matrix *, cpl_matrix *, cxint, cpl_matrix *,
00159 cxdouble[], cxint[], cxint, cpl_matrix *, cxdouble *,
00160 lmrq_params, fitted_func);
00161
00162 cxint mymrqmin(cpl_matrix *, cpl_matrix *, cpl_matrix *, cxint, cpl_matrix *,
00163 cxdouble[], cxint[], cxint, cpl_matrix *, cpl_matrix *,
00164 cxdouble *, fitted_func, cxdouble *);
00165
00166 cxint mymrqcof(cpl_matrix *, cpl_matrix *, cpl_matrix *, cxint, cpl_matrix *,
00167 cxdouble[], cxint[], cxint, cpl_matrix *, cpl_matrix *,
00168 cxdouble *, fitted_func);
00169
00170 cxdouble r_squared(cxdouble, cpl_matrix *, cxint);
00171
00172
00173
00174 void mrqgaussum(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00175 cxdouble[], cxint);
00176
00177 void mrqxoptmod(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00178 cxdouble[], cxint);
00179
00180 void mrqxoptmod2(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00181 cxdouble[], cxint);
00182
00183 void mrqyoptmod(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00184 cxdouble[], cxint);
00185
00186 void mrqyoptmod2(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00187 cxdouble[], cxint);
00188
00189 void mrqpsfcos(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00190 cxdouble[], cxint);
00191
00192 void mrqpsfexp(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00193 cxdouble[], cxint);
00194
00195 void mrqpsfexp2(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00196 cxdouble[], cxint);
00197
00198 void mrqlocywarp(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00199 cxdouble[], cxint);
00200
00201 void mrqxoptmodGS(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00202 cxdouble[], cxint);
00203
00204 void mrqtest(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
00205 cxdouble[], cxint);
00206
00207 extern lmrq_model lmrq_models[];
00208 extern cxint nr_lmrq_models;
00209
00210
00211 #ifdef __cplusplus
00212 }
00213 #endif
00214
00215 #endif