Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
cminpack.h
1 #ifndef __CMINPACK_H__
2 #define __CMINPACK_H__
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif /* __cplusplus */
7 
8 /* Declarations for minpack */
9 
10 /* Function types: */
11 /* The first argument can be used to store extra function parameters, thus */
12 /* avoiding the use of global variables. */
13 /* the iflag parameter is input-only (with respect to the FORTRAN */
14 /* version), the output iflag value is the return value of the function. */
15 /* If iflag=0, the function should just print the current values (see */
16 /* the nprint parameters below). */
17 
18 /* for hybrd1 and hybrd: */
19 /* calculate the functions at x and */
20 /* return this vector in fvec. */
21 /* return a negative value to terminate hybrd1/hybrd */
22 typedef int (*minpack_func_nn)(void *p, int n, const double *x, double *fvec, int iflag );
23 
24 /* for hybrj1 and hybrj */
25 /* if iflag = 1 calculate the functions at x and */
26 /* return this vector in fvec. do not alter fjac. */
27 /* if iflag = 2 calculate the jacobian at x and */
28 /* return this matrix in fjac. do not alter fvec. */
29 /* return a negative value to terminate hybrj1/hybrj */
30 typedef int (*minpack_funcder_nn)(void *p, int n, const double *x, double *fvec, double *fjac,
31  int ldfjac, int iflag );
32 
33 /* for lmdif1 and lmdif */
34 /* calculate the functions at x and */
35 /* return this vector in fvec. */
36 /* return a negative value to terminate lmdif1/lmdif */
37 typedef int (*minpack_func_mn)(void *p, int m, int n, const double *x, double *fvec,
38  int iflag );
39 
40 /* for lmder1 and lmder */
41 /* if iflag = 1 calculate the functions at x and */
42 /* return this vector in fvec. do not alter fjac. */
43 /* if iflag = 2 calculate the jacobian at x and */
44 /* return this matrix in fjac. do not alter fvec. */
45 /* return a negative value to terminate lmder1/lmder */
46 typedef int (*minpack_funcder_mn)(void *p, int m, int n, const double *x, double *fvec,
47  double *fjac, int ldfjac, int iflag );
48 
49 /* for lmstr1 and lmstr */
50 /* if iflag = 1 calculate the functions at x and */
51 /* return this vector in fvec. */
52 /* if iflag = i calculate the (i-1)-st row of the */
53 /* jacobian at x and return this vector in fjrow. */
54 /* return a negative value to terminate lmstr1/lmstr */
55 typedef int (*minpack_funcderstr_mn)(void *p, int m, int n, const double *x, double *fvec,
56  double *fjrow, int iflag );
57 
58 
59 
60 
61 
62 
63 /* MINPACK functions: */
64 /* the info parameter was removed from most functions: the return */
65 /* value of the function is used instead. */
66 /* The argument 'p' can be used to store extra function parameters, thus */
67 /* avoiding the use of global variables. You can also think of it as a */
68 /* 'this' pointer a la C++. */
69 
70 /* find a zero of a system of N nonlinear functions in N variables by
71  a modification of the Powell hybrid method (Jacobian calculated by
72  a forward-difference approximation) */
73 int hybrd1 ( minpack_func_nn fcn,
74  void *p, int n, double *x, double *fvec, double tol,
75  double *wa, int lwa );
76 
77 /* find a zero of a system of N nonlinear functions in N variables by
78  a modification of the Powell hybrid method (Jacobian calculated by
79  a forward-difference approximation, more general). */
80 int hybrd ( minpack_func_nn fcn,
81  void *p, int n, double *x, double *fvec, double xtol, int maxfev,
82  int ml, int mu, double epsfcn, double *diag, int mode,
83  double factor, int nprint, int *nfev,
84  double *fjac, int ldfjac, double *r, int lr, double *qtf,
85  double *wa1, double *wa2, double *wa3, double *wa4);
86 
87 /* find a zero of a system of N nonlinear functions in N variables by
88  a modification of the Powell hybrid method (user-supplied Jacobian) */
89 int hybrj1 ( minpack_funcder_nn fcn, void *p, int n, double *x,
90  double *fvec, double *fjac, int ldfjac, double tol,
91  double *wa, int lwa );
92 
93 /* find a zero of a system of N nonlinear functions in N variables by
94  a modification of the Powell hybrid method (user-supplied Jacobian,
95  more general) */
96 int hybrj ( minpack_funcder_nn fcn, void *p, int n, double *x,
97  double *fvec, double *fjac, int ldfjac, double xtol,
98  int maxfev, double *diag, int mode, double factor,
99  int nprint, int *nfev, int *njev, double *r,
100  int lr, double *qtf, double *wa1, double *wa2,
101  double *wa3, double *wa4 );
102 
103 /* minimize the sum of the squares of nonlinear functions in N
104  variables by a modification of the Levenberg-Marquardt algorithm
105  (Jacobian calculated by a forward-difference approximation) */
106 int lmdif1 ( minpack_func_mn fcn,
107  void *p, int m, int n, double *x, double *fvec, double tol,
108  int *iwa, double *wa, int lwa );
109 
110 /* minimize the sum of the squares of nonlinear functions in N
111  variables by a modification of the Levenberg-Marquardt algorithm
112  (Jacobian calculated by a forward-difference approximation, more
113  general) */
114 int lmdif ( minpack_func_mn fcn,
115  void *p, int m, int n, double *x, double *fvec, double ftol,
116  double xtol, double gtol, int maxfev, double epsfcn,
117  double *diag, int mode, double factor, int nprint,
118  int *nfev, double *fjac, int ldfjac, int *ipvt,
119  double *qtf, double *wa1, double *wa2, double *wa3,
120  double *wa4 );
121 
122 /* minimize the sum of the squares of nonlinear functions in N
123  variables by a modification of the Levenberg-Marquardt algorithm
124  (user-supplied Jacobian) */
125 int lmder1 ( minpack_funcder_mn fcn,
126  void *p, int m, int n, double *x, double *fvec, double *fjac,
127  int ldfjac, double tol, int *ipvt,
128  double *wa, int lwa );
129 
130 /* minimize the sum of the squares of nonlinear functions in N
131  variables by a modification of the Levenberg-Marquardt algorithm
132  (user-supplied Jacobian, more general) */
133 int lmder ( minpack_funcder_mn fcn,
134  void *p, int m, int n, double *x, double *fvec, double *fjac,
135  int ldfjac, double ftol, double xtol, double gtol,
136  int maxfev, double *diag, int mode, double factor,
137  int nprint, int *nfev, int *njev, int *ipvt,
138  double *qtf, double *wa1, double *wa2, double *wa3,
139  double *wa4 );
140 
141 /* minimize the sum of the squares of nonlinear functions in N
142  variables by a modification of the Levenberg-Marquardt algorithm
143  (user-supplied Jacobian, minimal storage) */
144 int lmstr1 ( minpack_funcderstr_mn fcn, void *p, int m, int n,
145  double *x, double *fvec, double *fjac, int ldfjac,
146  double tol, int *ipvt, double *wa, int lwa );
147 
148 /* minimize the sum of the squares of nonlinear functions in N
149  variables by a modification of the Levenberg-Marquardt algorithm
150  (user-supplied Jacobian, minimal storage, more general) */
151 int lmstr ( minpack_funcderstr_mn fcn, void *p, int m,
152  int n, double *x, double *fvec, double *fjac,
153  int ldfjac, double ftol, double xtol, double gtol,
154  int maxfev, double *diag, int mode, double factor,
155  int nprint, int *nfev, int *njev, int *ipvt,
156  double *qtf, double *wa1, double *wa2, double *wa3,
157  double *wa4 );
158 
159 void chkder ( int m, int n, const double *x, double *fvec, double *fjac,
160  int ldfjac, double *xp, double *fvecp, int mode,
161  double *err );
162 
163 double dpmpar ( int i );
164 
165 double enorm ( int n, const double *x );
166 
167 /* compute a forward-difference approximation to the m by n jacobian
168  matrix associated with a specified problem of m functions in n
169  variables. */
170 int fdjac2(minpack_func_mn fcn,
171  void *p, int m, int n, double *x, const double *fvec, double *fjac,
172  int ldfjac, double epsfcn, double *wa);
173 
174 /* compute a forward-difference approximation to the n by n jacobian
175  matrix associated with a specified problem of n functions in n
176  variables. if the jacobian has a banded form, then function
177  evaluations are saved by only approximating the nonzero terms. */
178 int fdjac1(minpack_func_nn fcn,
179  void *p, int n, double *x, const double *fvec, double *fjac, int ldfjac,
180  int ml, int mu, double epsfcn, double *wa1,
181  double *wa2);
182 
183 /* internal MINPACK subroutines */
184 void dogleg(int n, const double *r__, int lr,
185  const double *diag, const double *qtb, double delta, double *x,
186  double *wa1, double *wa2);
187 void qrfac(int m, int n, double *a, int
188  lda, int pivot, int *ipvt, int lipvt, double *rdiag,
189  double *acnorm, double *wa);
190 void qrsolv(int n, double *r__, int ldr,
191  const int *ipvt, const double *diag, const double *qtb, double *x,
192  double *sdiag, double *wa);
193 void qform(int m, int n, double *q, int
194  ldq, double *wa);
195 void r1updt(int m, int n, double *s, int
196  ls, const double *u, double *v, double *w, int *sing);
197 void r1mpyq(int m, int n, double *a, int
198  lda, const double *v, const double *w);
199 void lmpar(int n, double *r__, int ldr,
200  const int *ipvt, const double *diag, const double *qtb, double delta,
201  double *par, double *x, double *sdiag, double *wa1,
202  double *wa2);
203 void rwupdt(int n, double *r__, int ldr,
204  const double *w, double *b, double *alpha, double *cos__,
205  double *sin__);
206 void covar(int n, double *r__, int ldr,
207  const int *ipvt, double tol, double *wa);
208 #ifdef __cplusplus
209 }
210 #endif /* __cplusplus */
211 
212 
213 #endif /* __CMINPACK_H__ */