OpenFAST
Wind turbine multiphysics simulator
cminpack.h
1 /* Header file for cminpack, by Frederic Devernay.
2  The documentation for all functions can be found in the file
3  minpack-documentation.txt from the distribution, or in the source
4  code of each function. */
5 
6 #ifndef __CMINPACK_H__
7 #define __CMINPACK_H__
8 
9 /* The default floating-point type is "double" for C/C++ and "float" for CUDA,
10  but you can change this by defining one of the following symbols when
11  compiling the library, and before including cminpack.h when using it:
12  __cminpack_double__ for double
13  __cminpack_float__ for float
14  __cminpack_half__ for half from the OpenEXR library (in this case, you must
15  compile cminpack with a C++ compiler)
16 */
17 #ifdef __cminpack_double__
18 #define __cminpack_real__ double
19 #endif
20 
21 #ifdef __cminpack_float__
22 #define __cminpack_real__ float
23 #endif
24 
25 #ifdef __cminpack_half__
26 #include <OpenEXR/half.h>
27 #define __cminpack_real__ half
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33 
34 /* Cmake will define cminpack_EXPORTS on Windows when it
35 configures to build a shared library. If you are going to use
36 another build system on windows or create the visual studio
37 projects by hand you need to define cminpack_EXPORTS when
38 building a DLL on windows.
39 */
40 #if defined (__GNUC__)
41 #define CMINPACK_DECLSPEC_EXPORT __declspec(__dllexport__)
42 #define CMINPACK_DECLSPEC_IMPORT __declspec(__dllimport__)
43 #endif
44 #if defined (_MSC_VER) || defined (__BORLANDC__)
45 #define CMINPACK_DECLSPEC_EXPORT __declspec(dllexport)
46 #define CMINPACK_DECLSPEC_IMPORT __declspec(dllimport)
47 #endif
48 #ifdef __WATCOMC__
49 #define CMINPACK_DECLSPEC_EXPORT __export
50 #define CMINPACK_DECLSPEC_IMPORT __import
51 #endif
52 #ifdef __IBMC__
53 #define CMINPACK_DECLSPEC_EXPORT _Export
54 #define CMINPACK_DECLSPEC_IMPORT _Import
55 #endif
56 
57 #if !defined(CMINPACK_NO_DLL) && (defined(__WIN32__) || defined(WIN32) || defined (_WIN32))
58 #if defined(cminpack_EXPORTS) || defined(CMINPACK_EXPORTS) || defined(CMINPACK_DLL_EXPORTS)
59  #define CMINPACK_EXPORT CMINPACK_DECLSPEC_EXPORT
60  #else
61  #define CMINPACK_EXPORT CMINPACK_DECLSPEC_IMPORT
62  #endif /* cminpack_EXPORTS */
63 #else /* defined (_WIN32) */
64  #define CMINPACK_EXPORT
65 #endif
66 
67 #if defined(__CUDA_ARCH__) || defined(__CUDACC__)
68 #define __cminpack_attr__ __device__
69 #ifndef __cminpack_real__
70 #define __cminpack_float__
71 #define __cminpack_real__ float
72 #endif
73 #define __cminpack_type_fcn_nn__ __cminpack_attr__ int fcn_nn
74 #define __cminpack_type_fcnder_nn__ __cminpack_attr__ int fcnder_nn
75 #define __cminpack_type_fcn_mn__ __cminpack_attr__ int fcn_mn
76 #define __cminpack_type_fcnder_mn__ __cminpack_attr__ int fcnder_mn
77 #define __cminpack_type_fcnderstr_mn__ __cminpack_attr__ int fcnderstr_mn
78 #define __cminpack_decl_fcn_nn__
79 #define __cminpack_decl_fcnder_nn__
80 #define __cminpack_decl_fcn_mn__
81 #define __cminpack_decl_fcnder_mn__
82 #define __cminpack_decl_fcnderstr_mn__
83 #define __cminpack_param_fcn_nn__
84 #define __cminpack_param_fcnder_nn__
85 #define __cminpack_param_fcn_mn__
86 #define __cminpack_param_fcnder_mn__
87 #define __cminpack_param_fcnderstr_mn__
88 #else
89 #define __cminpack_attr__
90 #ifndef __cminpack_real__
91 #define __cminpack_double__
92 #define __cminpack_real__ double
93 #endif
94 #define __cminpack_type_fcn_nn__ typedef int (*cminpack_func_nn)
95 #define __cminpack_type_fcnder_nn__ typedef int (*cminpack_funcder_nn)
96 #define __cminpack_type_fcn_mn__ typedef int (*cminpack_func_mn)
97 #define __cminpack_type_fcnder_mn__ typedef int (*cminpack_funcder_mn)
98 #define __cminpack_type_fcnderstr_mn__ typedef int (*cminpack_funcderstr_mn)
99 #define __cminpack_decl_fcn_nn__ cminpack_func_nn fcn_nn,
100 #define __cminpack_decl_fcnder_nn__ cminpack_funcder_nn fcnder_nn,
101 #define __cminpack_decl_fcn_mn__ cminpack_func_mn fcn_mn,
102 #define __cminpack_decl_fcnder_mn__ cminpack_funcder_mn fcnder_mn,
103 #define __cminpack_decl_fcnderstr_mn__ cminpack_funcderstr_mn fcnderstr_mn,
104 #define __cminpack_param_fcn_nn__ fcn_nn,
105 #define __cminpack_param_fcnder_nn__ fcnder_nn,
106 #define __cminpack_param_fcn_mn__ fcn_mn,
107 #define __cminpack_param_fcnder_mn__ fcnder_mn,
108 #define __cminpack_param_fcnderstr_mn__ fcnderstr_mn,
109 #endif
110 
111 #ifdef __cminpack_double__
112 #define __cminpack_func__(func) func
113 #endif
114 
115 #ifdef __cminpack_float__
116 #define __cminpack_func__(func) s ## func
117 #endif
118 
119 #ifdef __cminpack_half__
120 #define __cminpack_func__(func) h ## func
121 #endif
122 
123 /* Declarations for minpack */
124 
125 /* Function types: */
126 /* The first argument can be used to store extra function parameters, thus */
127 /* avoiding the use of global variables. */
128 /* the iflag parameter is input-only (with respect to the FORTRAN */
129 /* version), the output iflag value is the return value of the function. */
130 /* If iflag=0, the function shoulkd just print the current values (see */
131 /* the nprint parameters below). */
132 
133 /* for hybrd1 and hybrd: */
134 /* calculate the functions at x and */
135 /* return this vector in fvec. */
136 /* return a negative value to terminate hybrd1/hybrd */
137 __cminpack_type_fcn_nn__(void *p, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, int iflag );
138 
139 /* for hybrj1 and hybrj */
140 /* if iflag = 1 calculate the functions at x and */
141 /* return this vector in fvec. do not alter fjac. */
142 /* if iflag = 2 calculate the jacobian at x and */
143 /* return this matrix in fjac. do not alter fvec. */
144 /* return a negative value to terminate hybrj1/hybrj */
145 __cminpack_type_fcnder_nn__(void *p, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
146  int ldfjac, int iflag );
147 
148 /* for lmdif1 and lmdif */
149 /* calculate the functions at x and */
150 /* return this vector in fvec. */
151 /* if iflag = 1 the result is used to compute the residuals. */
152 /* if iflag = 2 the result is used to compute the Jacobian by finite differences. */
153 /* Jacobian computation requires exactly n function calls with iflag = 2. */
154 /* return a negative value to terminate lmdif1/lmdif */
155 __cminpack_type_fcn_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec,
156  int iflag );
157 
158 /* for lmder1 and lmder */
159 /* if iflag = 1 calculate the functions at x and */
160 /* return this vector in fvec. do not alter fjac. */
161 /* if iflag = 2 calculate the jacobian at x and */
162 /* return this matrix in fjac. do not alter fvec. */
163 /* return a negative value to terminate lmder1/lmder */
164 __cminpack_type_fcnder_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec,
165  __cminpack_real__ *fjac, int ldfjac, int iflag );
166 
167 /* for lmstr1 and lmstr */
168 /* if iflag = 1 calculate the functions at x and */
169 /* return this vector in fvec. */
170 /* if iflag = i calculate the (i-1)-st row of the */
171 /* jacobian at x and return this vector in fjrow. */
172 /* return a negative value to terminate lmstr1/lmstr */
173 __cminpack_type_fcnderstr_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec,
174  __cminpack_real__ *fjrow, int iflag );
175 
176 
177 
178 
179 
180 
181 /* MINPACK functions: */
182 /* the info parameter was removed from most functions: the return */
183 /* value of the function is used instead. */
184 /* The argument 'p' can be used to store extra function parameters, thus */
185 /* avoiding the use of global variables. You can also think of it as a */
186 /* 'this' pointer a la C++. */
187 
188 /* find a zero of a system of N nonlinear functions in N variables by
189  a modification of the Powell hybrid method (Jacobian calculated by
190  a forward-difference approximation) */
191 __cminpack_attr__
192 int CMINPACK_EXPORT __cminpack_func__(hybrd1)( __cminpack_decl_fcn_nn__
193  void *p, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ tol,
194  __cminpack_real__ *wa, int lwa );
195 
196 /* find a zero of a system of N nonlinear functions in N variables by
197  a modification of the Powell hybrid method (Jacobian calculated by
198  a forward-difference approximation, more general). */
199 __cminpack_attr__
200 int CMINPACK_EXPORT __cminpack_func__(hybrd)( __cminpack_decl_fcn_nn__
201  void *p, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ xtol, int maxfev,
202  int ml, int mu, __cminpack_real__ epsfcn, __cminpack_real__ *diag, int mode,
203  __cminpack_real__ factor, int nprint, int *nfev,
204  __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ *r, int lr, __cminpack_real__ *qtf,
205  __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3, __cminpack_real__ *wa4);
206 
207 /* find a zero of a system of N nonlinear functions in N variables by
208  a modification of the Powell hybrid method (user-supplied Jacobian) */
209 __cminpack_attr__
210 int CMINPACK_EXPORT __cminpack_func__(hybrj1)( __cminpack_decl_fcnder_nn__ void *p, int n, __cminpack_real__ *x,
211  __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ tol,
212  __cminpack_real__ *wa, int lwa );
213 
214 /* find a zero of a system of N nonlinear functions in N variables by
215  a modification of the Powell hybrid method (user-supplied Jacobian,
216  more general) */
217 __cminpack_attr__
218 int CMINPACK_EXPORT __cminpack_func__(hybrj)( __cminpack_decl_fcnder_nn__ void *p, int n, __cminpack_real__ *x,
219  __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ xtol,
220  int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor,
221  int nprint, int *nfev, int *njev, __cminpack_real__ *r,
222  int lr, __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2,
223  __cminpack_real__ *wa3, __cminpack_real__ *wa4 );
224 
225 /* minimize the sum of the squares of nonlinear functions in N
226  variables by a modification of the Levenberg-Marquardt algorithm
227  (Jacobian calculated by a forward-difference approximation) */
228 __cminpack_attr__
229 int CMINPACK_EXPORT __cminpack_func__(lmdif1)( __cminpack_decl_fcn_mn__
230  void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ tol,
231  int *iwa, __cminpack_real__ *wa, int lwa );
232 
233 /* minimize the sum of the squares of nonlinear functions in N
234  variables by a modification of the Levenberg-Marquardt algorithm
235  (Jacobian calculated by a forward-difference approximation, more
236  general) */
237 __cminpack_attr__
238 int CMINPACK_EXPORT __cminpack_func__(lmdif)( __cminpack_decl_fcn_mn__
239  void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ ftol,
240  __cminpack_real__ xtol, __cminpack_real__ gtol, int maxfev, __cminpack_real__ epsfcn,
241  __cminpack_real__ *diag, int mode, __cminpack_real__ factor, int nprint,
242  int *nfev, __cminpack_real__ *fjac, int ldfjac, int *ipvt,
243  __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3,
244  __cminpack_real__ *wa4 );
245 
246 /* minimize the sum of the squares of nonlinear functions in N
247  variables by a modification of the Levenberg-Marquardt algorithm
248  (user-supplied Jacobian) */
249 __cminpack_attr__
250 int CMINPACK_EXPORT __cminpack_func__(lmder1)( __cminpack_decl_fcnder_mn__
251  void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
252  int ldfjac, __cminpack_real__ tol, int *ipvt,
253  __cminpack_real__ *wa, int lwa );
254 
255 /* minimize the sum of the squares of nonlinear functions in N
256  variables by a modification of the Levenberg-Marquardt algorithm
257  (user-supplied Jacobian, more general) */
258 __cminpack_attr__
259 int CMINPACK_EXPORT __cminpack_func__(lmder)( __cminpack_decl_fcnder_mn__
260  void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
261  int ldfjac, __cminpack_real__ ftol, __cminpack_real__ xtol, __cminpack_real__ gtol,
262  int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor,
263  int nprint, int *nfev, int *njev, int *ipvt,
264  __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3,
265  __cminpack_real__ *wa4 );
266 
267 /* minimize the sum of the squares of nonlinear functions in N
268  variables by a modification of the Levenberg-Marquardt algorithm
269  (user-supplied Jacobian, minimal storage) */
270 __cminpack_attr__
271 int CMINPACK_EXPORT __cminpack_func__(lmstr1)( __cminpack_decl_fcnderstr_mn__ void *p, int m, int n,
272  __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac,
273  __cminpack_real__ tol, int *ipvt, __cminpack_real__ *wa, int lwa );
274 
275 /* minimize the sum of the squares of nonlinear functions in N
276  variables by a modification of the Levenberg-Marquardt algorithm
277  (user-supplied Jacobian, minimal storage, more general) */
278 __cminpack_attr__
279 int CMINPACK_EXPORT __cminpack_func__(lmstr)( __cminpack_decl_fcnderstr_mn__ void *p, int m,
280  int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
281  int ldfjac, __cminpack_real__ ftol, __cminpack_real__ xtol, __cminpack_real__ gtol,
282  int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor,
283  int nprint, int *nfev, int *njev, int *ipvt,
284  __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3,
285  __cminpack_real__ *wa4 );
286 
287 __cminpack_attr__
288 void CMINPACK_EXPORT __cminpack_func__(chkder)( int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
289  int ldfjac, __cminpack_real__ *xp, __cminpack_real__ *fvecp, int mode,
290  __cminpack_real__ *err );
291 
292 __cminpack_attr__
293 __cminpack_real__ CMINPACK_EXPORT __cminpack_func__(dpmpar)( int i );
294 
295 __cminpack_attr__
296 __cminpack_real__ CMINPACK_EXPORT __cminpack_func__(enorm)( int n, const __cminpack_real__ *x );
297 
298 /* compute a forward-difference approximation to the m by n jacobian
299  matrix associated with a specified problem of m functions in n
300  variables. */
301 __cminpack_attr__
302 int CMINPACK_EXPORT __cminpack_func__(fdjac2)(__cminpack_decl_fcn_mn__
303  void *p, int m, int n, __cminpack_real__ *x, const __cminpack_real__ *fvec, __cminpack_real__ *fjac,
304  int ldfjac, __cminpack_real__ epsfcn, __cminpack_real__ *wa);
305 
306 /* compute a forward-difference approximation to the n by n jacobian
307  matrix associated with a specified problem of n functions in n
308  variables. if the jacobian has a banded form, then function
309  evaluations are saved by only approximating the nonzero terms. */
310 __cminpack_attr__
311 int CMINPACK_EXPORT __cminpack_func__(fdjac1)(__cminpack_decl_fcn_nn__
312  void *p, int n, __cminpack_real__ *x, const __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac,
313  int ml, int mu, __cminpack_real__ epsfcn, __cminpack_real__ *wa1,
314  __cminpack_real__ *wa2);
315 
316 /* compute inverse(JtJ) after a run of lmdif or lmder. The covariance matrix is obtained
317  by scaling the result by enorm(y)**2/(m-n). If JtJ is singular and k = rank(J), the
318  pseudo-inverse is computed, and the result has to be scaled by enorm(y)**2/(m-k). */
319 __cminpack_attr__
320 void CMINPACK_EXPORT __cminpack_func__(covar)(int n, __cminpack_real__ *r, int ldr,
321  const int *ipvt, __cminpack_real__ tol, __cminpack_real__ *wa);
322 
323 /* covar1 estimates the variance-covariance matrix:
324  C = sigma**2 (JtJ)**+
325  where (JtJ)**+ is the inverse of JtJ or the pseudo-inverse of JtJ (in case J does not have full rank),
326  and sigma**2 = fsumsq / (m - k)
327  where fsumsq is the residual sum of squares and k is the rank of J.
328  The function returns 0 if J has full rank, else the rank of J.
329 */
330 __cminpack_attr__
331 int CMINPACK_EXPORT __cminpack_func__(covar1)(int m, int n, __cminpack_real__ fsumsq, __cminpack_real__ *r, int ldr,
332  const int *ipvt, __cminpack_real__ tol, __cminpack_real__ *wa);
333 
334 /* internal MINPACK subroutines */
335 __cminpack_attr__
336 void __cminpack_func__(dogleg)(int n, const __cminpack_real__ *r, int lr,
337  const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ delta, __cminpack_real__ *x,
338  __cminpack_real__ *wa1, __cminpack_real__ *wa2);
339 __cminpack_attr__
340 void __cminpack_func__(qrfac)(int m, int n, __cminpack_real__ *a, int
341  lda, int pivot, int *ipvt, int lipvt, __cminpack_real__ *rdiag,
342  __cminpack_real__ *acnorm, __cminpack_real__ *wa);
343 __cminpack_attr__
344 void __cminpack_func__(qrsolv)(int n, __cminpack_real__ *r, int ldr,
345  const int *ipvt, const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ *x,
346  __cminpack_real__ *sdiag, __cminpack_real__ *wa);
347 __cminpack_attr__
348 void __cminpack_func__(qform)(int m, int n, __cminpack_real__ *q, int
349  ldq, __cminpack_real__ *wa);
350 __cminpack_attr__
351 void __cminpack_func__(r1updt)(int m, int n, __cminpack_real__ *s, int
352  ls, const __cminpack_real__ *u, __cminpack_real__ *v, __cminpack_real__ *w, int *sing);
353 __cminpack_attr__
354 void __cminpack_func__(r1mpyq)(int m, int n, __cminpack_real__ *a, int
355  lda, const __cminpack_real__ *v, const __cminpack_real__ *w);
356 __cminpack_attr__
357 void __cminpack_func__(lmpar)(int n, __cminpack_real__ *r, int ldr,
358  const int *ipvt, const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ delta,
359  __cminpack_real__ *par, __cminpack_real__ *x, __cminpack_real__ *sdiag, __cminpack_real__ *wa1,
360  __cminpack_real__ *wa2);
361 __cminpack_attr__
362 void __cminpack_func__(rwupdt)(int n, __cminpack_real__ *r, int ldr,
363  const __cminpack_real__ *w, __cminpack_real__ *b, __cminpack_real__ *alpha, __cminpack_real__ *cos,
364  __cminpack_real__ *sin);
365 #ifdef __cplusplus
366 }
367 #endif /* __cplusplus */
368 
369 
370 #endif /* __CMINPACK_H__ */