-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtolmin-wrap.c
43 lines (37 loc) · 1.11 KB
/
tolmin-wrap.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* tolmin-wrap.c --
*
* Wrapper for calling the C version of Mike Powell's TOLMIN from FORTRAN code.
*
* ----------------------------------------------------------------------------
*
* Copyright (c) 1989, Mike J. D. Powell (FORTRAN version released under the
* GNU Lesser General Public License).
*
* Copyright (c) 2017, Éric Thiébaut (C version).
*
*/
#include <math.h>
#include <stdio.h>
#include "tolmin.h"
extern void fgcalc_(const INTEGER *n, const REAL *x, REAL *f, REAL *g);
static REAL
wfg(void* ctx, const REAL x[], REAL g[])
{
INTEGER n = *(INTEGER*)ctx;
REAL f;
fgcalc_(&n, x, &f, g);
return f;
}
extern void
getmin_(const INTEGER* n, const INTEGER* m, const INTEGER* meq,
const REAL a[], const INTEGER* ia, const REAL b[],
const REAL xl[], const REAL xu[], REAL x[], const REAL* acc,
INTEGER iact[], INTEGER* nact, REAL par[],
const INTEGER* iprint, INTEGER* info, REAL w[])
{
INTEGER number = *n;
int status = tolmin(wfg, &number, *n, *m, *meq, a, *ia, b, xl, xu,
x, *acc, iact, nact, par, *iprint, *info, w);
*info = status;
}