-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcineq6_min_v_func.c
More file actions
353 lines (318 loc) · 11.4 KB
/
Copy pathcineq6_min_v_func.c
File metadata and controls
353 lines (318 loc) · 11.4 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/* This file was automatically generated by CasADi.
The CasADi copyright holders make no ownership claim of its contents. */
#ifdef __cplusplus
extern "C" {
#endif
/* How to prefix internal symbols */
#ifdef CASADI_CODEGEN_PREFIX
#define CASADI_NAMESPACE_CONCAT(NS, ID) _CASADI_NAMESPACE_CONCAT(NS, ID)
#define _CASADI_NAMESPACE_CONCAT(NS, ID) NS ## ID
#define CASADI_PREFIX(ID) CASADI_NAMESPACE_CONCAT(CODEGEN_PREFIX, ID)
#else
#define CASADI_PREFIX(ID) cineq6_min_v_func_ ## ID
#endif
#include <math.h>
#include <stdio.h>
#include <string.h>
#ifdef MATLAB_MEX_FILE
#include <mex.h>
#endif
#ifndef casadi_real
#define casadi_real double
#endif
#ifndef casadi_int
#define casadi_int long long int
#endif
/* Add prefix to internal symbols */
#define casadi_f0 CASADI_PREFIX(f0)
#define casadi_fill CASADI_PREFIX(fill)
#define casadi_from_mex CASADI_PREFIX(from_mex)
#define casadi_s0 CASADI_PREFIX(s0)
#define casadi_s1 CASADI_PREFIX(s1)
#define casadi_s2 CASADI_PREFIX(s2)
#define casadi_to_mex CASADI_PREFIX(to_mex)
/* Symbol visibility in DLLs */
#ifndef CASADI_SYMBOL_EXPORT
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#if defined(STATIC_LINKED)
#define CASADI_SYMBOL_EXPORT
#else
#define CASADI_SYMBOL_EXPORT __declspec(dllexport)
#endif
#elif defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
#define CASADI_SYMBOL_EXPORT __attribute__ ((visibility ("default")))
#else
#define CASADI_SYMBOL_EXPORT
#endif
#endif
void casadi_fill(casadi_real* x, casadi_int n, casadi_real alpha) {
casadi_int i;
if (x) {
for (i=0; i<n; ++i) *x++ = alpha;
}
}
#ifdef MATLAB_MEX_FILE
casadi_real* casadi_from_mex(const mxArray* p, casadi_real* y, const casadi_int* sp, casadi_real* w) {
casadi_int nrow, ncol, is_sparse, c, k, p_nrow, p_ncol;
const casadi_int *colind, *row;
mwIndex *Jc, *Ir;
const double* p_data;
if (!mxIsDouble(p) || mxGetNumberOfDimensions(p)!=2)
mexErrMsgIdAndTxt("Casadi:RuntimeError",
"\"from_mex\" failed: Not a two-dimensional matrix of double precision.");
nrow = *sp++;
ncol = *sp++;
colind = sp;
row = sp+ncol+1;
p_nrow = mxGetM(p);
p_ncol = mxGetN(p);
is_sparse = mxIsSparse(p);
Jc = 0;
Ir = 0;
if (is_sparse) {
Jc = mxGetJc(p);
Ir = mxGetIr(p);
}
p_data = (const double*)mxGetData(p);
if (p_nrow==1 && p_ncol==1) {
casadi_int nnz;
double v = is_sparse && Jc[1]==0 ? 0 : *p_data;
nnz = sp[ncol];
casadi_fill(y, nnz, v);
} else {
casadi_int tr = 0;
if (nrow!=p_nrow || ncol!=p_ncol) {
tr = nrow==p_ncol && ncol==p_nrow && (nrow==1 || ncol==1);
if (!tr) mexErrMsgIdAndTxt("Casadi:RuntimeError",
"\"from_mex\" failed: Dimension mismatch. "
"Expected %d-by-%d, got %d-by-%d instead.",
nrow, ncol, p_nrow, p_ncol);
}
if (is_sparse) {
if (tr) {
for (c=0; c<ncol; ++c)
for (k=colind[c]; k<colind[c+1]; ++k) w[row[k]+c*nrow]=0;
for (c=0; c<p_ncol; ++c)
for (k=Jc[c]; k<(casadi_int) Jc[c+1]; ++k) w[c+Ir[k]*p_ncol] = p_data[k];
for (c=0; c<ncol; ++c)
for (k=colind[c]; k<colind[c+1]; ++k) y[k] = w[row[k]+c*nrow];
} else {
for (c=0; c<ncol; ++c) {
for (k=colind[c]; k<colind[c+1]; ++k) w[row[k]]=0;
for (k=Jc[c]; k<(casadi_int) Jc[c+1]; ++k) w[Ir[k]]=p_data[k];
for (k=colind[c]; k<colind[c+1]; ++k) y[k]=w[row[k]];
}
}
} else {
for (c=0; c<ncol; ++c) {
for (k=colind[c]; k<colind[c+1]; ++k) {
y[k] = p_data[row[k]+c*nrow];
}
}
}
}
return y;
}
#endif
#define casadi_to_double(x) ((double) x)
#ifdef MATLAB_MEX_FILE
mxArray* casadi_to_mex(const casadi_int* sp, const casadi_real* x) {
casadi_int nrow, ncol, c, k;
#ifndef CASADI_MEX_NO_SPARSE
casadi_int nnz;
#endif
const casadi_int *colind, *row;
mxArray *p;
double *d;
#ifndef CASADI_MEX_NO_SPARSE
casadi_int i;
mwIndex *j;
#endif /* CASADI_MEX_NO_SPARSE */
nrow = *sp++;
ncol = *sp++;
colind = sp;
row = sp+ncol+1;
#ifndef CASADI_MEX_NO_SPARSE
nnz = sp[ncol];
if (nnz!=nrow*ncol) {
p = mxCreateSparse(nrow, ncol, nnz, mxREAL);
for (i=0, j=mxGetJc(p); i<=ncol; ++i) *j++ = *colind++;
for (i=0, j=mxGetIr(p); i<nnz; ++i) *j++ = *row++;
if (x) {
d = (double*)mxGetData(p);
for (i=0; i<nnz; ++i) *d++ = casadi_to_double(*x++);
}
return p;
}
#endif /* CASADI_MEX_NO_SPARSE */
p = mxCreateDoubleMatrix(nrow, ncol, mxREAL);
if (x) {
d = (double*)mxGetData(p);
for (c=0; c<ncol; ++c) {
for (k=colind[c]; k<colind[c+1]; ++k) {
d[row[k]+c*nrow] = casadi_to_double(*x++);
}
}
}
return p;
}
#endif
#ifndef CASADI_PRINTF
#ifdef MATLAB_MEX_FILE
#define CASADI_PRINTF mexPrintf
#else
#define CASADI_PRINTF printf
#endif
#endif
static const casadi_int casadi_s0[184] = {180, 1, 0, 180, 0, 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, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179};
static const casadi_int casadi_s1[5] = {1, 1, 0, 1, 0};
static const casadi_int casadi_s2[225] = {2, 220, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1};
/* cineq6_min_v_func:(i0[180],i1,i2,i3,i4,i5)->(o0[2x220,2nz]) */
static int casadi_f0(const casadi_real** arg, casadi_real** res, casadi_int* iw, casadi_real* w, int mem) {
casadi_real a0;
a0=-1.;
if (res[0]!=0) res[0][0]=a0;
if (res[0]!=0) res[0][1]=a0;
return 0;
}
CASADI_SYMBOL_EXPORT int cineq6_min_v_func(const casadi_real** arg, casadi_real** res, casadi_int* iw, casadi_real* w, int mem){
return casadi_f0(arg, res, iw, w, mem);
}
CASADI_SYMBOL_EXPORT int cineq6_min_v_func_alloc_mem(void) {
return 0;
}
CASADI_SYMBOL_EXPORT int cineq6_min_v_func_init_mem(int mem) {
return 0;
}
CASADI_SYMBOL_EXPORT void cineq6_min_v_func_free_mem(int mem) {
}
CASADI_SYMBOL_EXPORT int cineq6_min_v_func_checkout(void) {
return 0;
}
CASADI_SYMBOL_EXPORT void cineq6_min_v_func_release(int mem) {
}
CASADI_SYMBOL_EXPORT void cineq6_min_v_func_incref(void) {
}
CASADI_SYMBOL_EXPORT void cineq6_min_v_func_decref(void) {
}
CASADI_SYMBOL_EXPORT casadi_int cineq6_min_v_func_n_in(void) { return 6;}
CASADI_SYMBOL_EXPORT casadi_int cineq6_min_v_func_n_out(void) { return 1;}
CASADI_SYMBOL_EXPORT casadi_real cineq6_min_v_func_default_in(casadi_int i){
switch (i) {
default: return 0;
}
}
CASADI_SYMBOL_EXPORT const char* cineq6_min_v_func_name_in(casadi_int i){
switch (i) {
case 0: return "i0";
case 1: return "i1";
case 2: return "i2";
case 3: return "i3";
case 4: return "i4";
case 5: return "i5";
default: return 0;
}
}
CASADI_SYMBOL_EXPORT const char* cineq6_min_v_func_name_out(casadi_int i){
switch (i) {
case 0: return "o0";
default: return 0;
}
}
CASADI_SYMBOL_EXPORT const casadi_int* cineq6_min_v_func_sparsity_in(casadi_int i) {
switch (i) {
case 0: return casadi_s0;
case 1: return casadi_s1;
case 2: return casadi_s1;
case 3: return casadi_s1;
case 4: return casadi_s1;
case 5: return casadi_s1;
default: return 0;
}
}
CASADI_SYMBOL_EXPORT const casadi_int* cineq6_min_v_func_sparsity_out(casadi_int i) {
switch (i) {
case 0: return casadi_s2;
default: return 0;
}
}
CASADI_SYMBOL_EXPORT int cineq6_min_v_func_work(casadi_int *sz_arg, casadi_int* sz_res, casadi_int *sz_iw, casadi_int *sz_w) {
if (sz_arg) *sz_arg = 6;
if (sz_res) *sz_res = 1;
if (sz_iw) *sz_iw = 0;
if (sz_w) *sz_w = 0;
return 0;
}
#ifdef MATLAB_MEX_FILE
void mex_cineq6_min_v_func(int resc, mxArray *resv[], int argc, const mxArray *argv[]) {
casadi_int i;
casadi_real w[367];
casadi_int *iw = 0;
const casadi_real* arg[6] = {0};
casadi_real* res[1] = {0};
if (argc>6) mexErrMsgIdAndTxt("Casadi:RuntimeError","Evaluation of \"cineq6_min_v_func\" failed. Too many input arguments (%d, max 6)", argc);
if (resc>1) mexErrMsgIdAndTxt("Casadi:RuntimeError","Evaluation of \"cineq6_min_v_func\" failed. Too many output arguments (%d, max 1)", resc);
if (--argc>=0) arg[0] = casadi_from_mex(argv[0], w, casadi_s0, w+187);
if (--argc>=0) arg[1] = casadi_from_mex(argv[1], w+180, casadi_s1, w+187);
if (--argc>=0) arg[2] = casadi_from_mex(argv[2], w+181, casadi_s1, w+187);
if (--argc>=0) arg[3] = casadi_from_mex(argv[3], w+182, casadi_s1, w+187);
if (--argc>=0) arg[4] = casadi_from_mex(argv[4], w+183, casadi_s1, w+187);
if (--argc>=0) arg[5] = casadi_from_mex(argv[5], w+184, casadi_s1, w+187);
--resc;
res[0] = w+185;
i = cineq6_min_v_func(arg, res, iw, w+187, 0);
if (i) mexErrMsgIdAndTxt("Casadi:RuntimeError","Evaluation of \"cineq6_min_v_func\" failed.");
if (res[0]) resv[0] = casadi_to_mex(casadi_s2, res[0]);
}
#endif
casadi_int main_cineq6_min_v_func(casadi_int argc, char* argv[]) {
casadi_int j;
casadi_real* a;
const casadi_real* r;
casadi_int flag;
casadi_int *iw = 0;
casadi_real w[188];
const casadi_real* arg[6];
casadi_real* res[1];
arg[0] = w+0;
arg[1] = w+180;
arg[2] = w+181;
arg[3] = w+182;
arg[4] = w+183;
arg[5] = w+184;
res[0] = w+185;
a = w;
for (j=0; j<185; ++j) if (scanf("%lg", a++)<=0) return 2;
flag = cineq6_min_v_func(arg, res, iw, w+187, 0);
if (flag) return flag;
r = w+185;
for (j=0; j<2; ++j) CASADI_PRINTF("%g ", *r++);
CASADI_PRINTF("\n");
return 0;
}
#ifdef MATLAB_MEX_FILE
void mexFunction(int resc, mxArray *resv[], int argc, const mxArray *argv[]) {
char buf[18];
int buf_ok = argc > 0 && !mxGetString(*argv, buf, sizeof(buf));
if (!buf_ok) {
mex_cineq6_min_v_func(resc, resv, argc, argv);
return;
} else if (strcmp(buf, "cineq6_min_v_func")==0) {
mex_cineq6_min_v_func(resc, resv, argc-1, argv+1);
return;
}
mexErrMsgTxt("First input should be a command string. Possible values: 'cineq6_min_v_func'");
}
#endif
int main(int argc, char* argv[]) {
if (argc<2) {
/* name error */
} else if (strcmp(argv[1], "cineq6_min_v_func")==0) {
return main_cineq6_min_v_func(argc-2, argv+2);
}
fprintf(stderr, "First input should be a command string. Possible values: 'cineq6_min_v_func'\nNote: you may use function.generate_input to create a command string.\n");
return 1;
}
#ifdef __cplusplus
} /* extern "C" */
#endif