Skip to content

Commit de8c29c

Browse files
committed
Export minpack API via bind(c)
1 parent 8479bd3 commit de8c29c

File tree

4 files changed

+784
-0
lines changed

4 files changed

+784
-0
lines changed

fpm.toml

+5
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ main = "test_lmdif.f90"
4646
name = "test_lmstr"
4747
source-dir = "test"
4848
main = "test_lmstr.f90"
49+
50+
[[test]]
51+
name = "c-test"
52+
source-dir = "test/api"
53+
main = "tester.c"

include/minpack.h

+292
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
#ifdef __cplusplus
2+
#define MINPACK_EXTERN extern "C"
3+
#else
4+
#define MINPACK_EXTERN extern
5+
#endif
6+
7+
MINPACK_EXTERN double
8+
minpack_dpmpar(int /* i */);
9+
10+
typedef
11+
void (*minpack_func)(
12+
int /* n */,
13+
const double* /* x */,
14+
double* /* fvec */,
15+
int* /* iflag */,
16+
void* /* udata */);
17+
18+
/*
19+
* the purpose of hybrd is to find a zero of a system of
20+
* n nonlinear functions in n variables by a modification
21+
* of the powell hybrid method. the user must provide a
22+
* subroutine which calculates the functions. the jacobian is
23+
* then calculated by a forward-difference approximation.
24+
*/
25+
MINPACK_EXTERN void
26+
minpack_hybrd(
27+
minpack_func /* fcn */,
28+
int /* n */,
29+
double* /* x */,
30+
double* /* fvec */,
31+
double /* xtol */,
32+
int /* maxfev */,
33+
int /* ml */,
34+
int /* mu */,
35+
double /* epsfcn */,
36+
double* /* diag */,
37+
int /* mode */,
38+
double /* factor */,
39+
int /* nprint */,
40+
int* /* info */,
41+
int* /* nfev */,
42+
double* /* fjac */,
43+
int /* ldfjac */,
44+
double* /* r */,
45+
int /* lr */,
46+
double* /* qtf */,
47+
double* /* wa1 */,
48+
double* /* wa2 */,
49+
double* /* wa3 */,
50+
double* /* wa4 */,
51+
void* /* udata */);
52+
53+
/*
54+
* the purpose of hybrd1 is to find a zero of a system of
55+
* n nonlinear functions in n variables by a modification
56+
* of the powell hybrid method. this is done by using the
57+
* more general nonlinear equation solver hybrd. the user
58+
* must provide a subroutine which calculates the functions.
59+
* the jacobian is then calculated by a forward-difference
60+
* approximation.
61+
*/
62+
MINPACK_EXTERN void
63+
minpack_hybrd1 (
64+
minpack_func /* fcn */,
65+
int /* n */,
66+
double* /* x */,
67+
double* /* fvec */,
68+
double /* tol */,
69+
int* /* info */,
70+
double* /* wa */,
71+
int /* lwa */,
72+
void* /* udata */);
73+
74+
typedef
75+
void (*minpack_fcn_hybrj)(
76+
int /* n */,
77+
const double* /* x */,
78+
double* /* fvec */,
79+
double* /* fjac */,
80+
int /* ldfjac */,
81+
int* /* iflag */,
82+
void* /* udata */);
83+
84+
/*
85+
* the purpose of hybrj is to find a zero of a system of
86+
* n nonlinear functions in n variables by a modification
87+
* of the powell hybrid method. the user must provide a
88+
* subroutine which calculates the functions and the jacobian.
89+
*/
90+
MINPACK_EXTERN void
91+
minpack_hybrj(
92+
minpack_fcn_hybrj /* fcn */,
93+
int /* n */,
94+
double* /* x */,
95+
double* /* fvec */,
96+
double* /* fjac */,
97+
int /* ldfjac */,
98+
double /* xtol */,
99+
int /* maxfev */,
100+
double* /* diag */,
101+
int /* mode */,
102+
double /* factor */,
103+
int /* nprint */,
104+
int* /* info */,
105+
int* /* nfev */,
106+
int* /* njev */,
107+
double* /* r */,
108+
int /* lr */,
109+
double* /* qtf */,
110+
double* /* wa1 */,
111+
double* /* wa2 */,
112+
double* /* wa3 */,
113+
double* /* wa4 */,
114+
void* /* udata */);
115+
116+
/*
117+
* The purpose of hybrj1 is to find a zero of a system of
118+
* n nonlinear functions in n variables by a modification
119+
* of the powell hybrid method. this is done by using the
120+
* more general nonlinear equation solver hybrj. the user
121+
* must provide a subroutine which calculates the functions
122+
* and the jacobian.
123+
*/
124+
MINPACK_EXTERN void
125+
minpack_hybrj1(
126+
minpack_fcn_hybrj /* fcn */,
127+
int /* n */,
128+
double* /* x */,
129+
double* /* fvec */,
130+
double* /* fjac */,
131+
int /* ldfjac */,
132+
double /* tol */,
133+
int* /* info */,
134+
double* /* wa */,
135+
int /* lwa */,
136+
void* /* udata */);
137+
138+
typedef
139+
void (*minpack_fcn_lmder)(
140+
int /* m */,
141+
int /* n */,
142+
const double* /* x */,
143+
double* /* fvec */,
144+
double* /* fjac */,
145+
int /* ldfjac */,
146+
int* /* iflag */,
147+
void* /* udata */);
148+
149+
/*
150+
* the purpose of lmder is to minimize the sum of the squares of
151+
* m nonlinear functions in n variables by a modification of
152+
* the levenberg-marquardt algorithm. the user must provide a
153+
* subroutine which calculates the functions and the jacobian.
154+
*/
155+
MINPACK_EXTERN void
156+
minpack_lmder(
157+
minpack_fcn_lmder /* fcn */,
158+
int /* m */,
159+
int /* n */,
160+
double* /* x */,
161+
double* /* fvec */,
162+
double* /* fjac */,
163+
int /* ldfjac */,
164+
double /* ftol */,
165+
double /* xtol */,
166+
double /* gtol */,
167+
int /* maxfev */,
168+
double* /* diag */,
169+
int /* mode */,
170+
double /* factor */,
171+
int /* nprint */,
172+
int* /* info */,
173+
int* /* nfev */,
174+
int* /* njev */,
175+
int* /* ipvt */,
176+
double* /* qtf */,
177+
double* /* wa1 */,
178+
double* /* wa2 */,
179+
double* /* wa3 */,
180+
double* /* wa4 */,
181+
void* /* udata */);
182+
183+
/*
184+
* the purpose of lmder1 is to minimize the sum of the squares of
185+
* m nonlinear functions in n variables by a modification of the
186+
* levenberg-marquardt algorithm. this is done by using the more
187+
* general least-squares solver lmder. the user must provide a
188+
* subroutine which calculates the functions and the jacobian.
189+
*/
190+
void minpack_lmder1 (
191+
minpack_fcn_lmder /* fcn */,
192+
int /* m */,
193+
int /* n */,
194+
double /* *x */,
195+
double /* *fvec */,
196+
double /* *fjac */,
197+
int /* ldfjac */,
198+
double /* tol */,
199+
int /* *info */,
200+
int /* *ipvt */,
201+
double /* *wa */,
202+
int /* lwa */,
203+
void* /* udata */);
204+
205+
typedef
206+
void (*minpack_func2)(
207+
int /* m */,
208+
int /* n */,
209+
const double* /* x */,
210+
double* /* fvec */,
211+
int* /* iflag */,
212+
void* /* udata */);
213+
214+
/*
215+
* the purpose of lmdif is to minimize the sum of the squares of
216+
* m nonlinear functions in n variables by a modification of
217+
* the levenberg-marquardt algorithm. the user must provide a
218+
* subroutine which calculates the functions. the jacobian is
219+
* then calculated by a forward-difference approximation.
220+
*/
221+
MINPACK_EXTERN void
222+
minpack_lmdif(
223+
minpack_func2 /* fcn */,
224+
int /* m */,
225+
int /* n */,
226+
double* /* x */,
227+
double* /* fvec */,
228+
double /* ftol */,
229+
double /* xtol */,
230+
double /* gtol */,
231+
int /* maxfev */,
232+
double /* epsfcn */,
233+
double* /* diag */,
234+
int /* mode */,
235+
double /* factor */,
236+
int /* nprint */,
237+
int* /* info */,
238+
int* /* nfev */,
239+
double* /* fjac */,
240+
int /* ldfjac */,
241+
int* /* ipvt */,
242+
double* /* qtf */,
243+
double* /* wa1 */,
244+
double* /* wa2 */,
245+
double* /* wa3 */,
246+
double* /* wa4 */,
247+
void* /* udata */);
248+
249+
/*
250+
* the purpose of lmdif1 is to minimize the sum of the squares of
251+
* m nonlinear functions in n variables by a modification of the
252+
* levenberg-marquardt algorithm. this is done by using the more
253+
* general least-squares solver lmdif. the user must provide a
254+
* subroutine which calculates the functions. the jacobian is
255+
* then calculated by a forward-difference approximation.
256+
*/
257+
void minpack_lmdif1 (
258+
minpack_func2 /* fcn */,
259+
int /* m */,
260+
int /* n */,
261+
double* /* x */,
262+
double* /* fvec */,
263+
double /* tol */,
264+
int* /* info */,
265+
int* /* iwa */,
266+
double* /* wa */,
267+
int /* lwa */,
268+
void* /* udata */);
269+
270+
/*
271+
* this subroutine checks the gradients of m nonlinear functions
272+
* in n variables, evaluated at a point x, for consistency with
273+
* the functions themselves.
274+
*
275+
* the subroutine does not perform reliably if cancellation or
276+
* rounding errors cause a severe loss of significance in the
277+
* evaluation of a function. therefore, none of the components
278+
* of x should be unusually small (in particular, zero) or any
279+
* other value which may cause loss of significance.
280+
*/
281+
MINPACK_EXTERN void
282+
minpack_chkder(
283+
int /* m */,
284+
int /* n */,
285+
const double* /* x */,
286+
const double* /* fvec */,
287+
const double* /* fjac */,
288+
int /* ldfjac */,
289+
double* /* xp */,
290+
const double* /* fvecp */,
291+
int /* mode */,
292+
double* /* err */);

0 commit comments

Comments
 (0)