1 | #include <kernel/mod2.h> |
---|
2 | |
---|
3 | #if HAVE_GFANLIB |
---|
4 | |
---|
5 | #include <misc/intvec.h> |
---|
6 | #include <misc/sirandom.h> |
---|
7 | |
---|
8 | #include <coeffs/bigintmat.h> |
---|
9 | #include <coeffs/longrat.h> |
---|
10 | |
---|
11 | #include <Singular/ipid.h> |
---|
12 | #include <Singular/ipshell.h> |
---|
13 | #include <Singular/blackbox.h> |
---|
14 | |
---|
15 | #include <Singular/links/ssiLink.h> |
---|
16 | |
---|
17 | #include <callgfanlib_conversion.h> |
---|
18 | #include <sstream> |
---|
19 | |
---|
20 | #include <gfanlib/gfanlib.h> |
---|
21 | #include <gfanlib/gfanlib_q.h> |
---|
22 | |
---|
23 | #include <bbfan.h> |
---|
24 | #include <bbpolytope.h> |
---|
25 | |
---|
26 | int coneID; |
---|
27 | |
---|
28 | std::string toString(const gfan::ZCone* const c) |
---|
29 | { |
---|
30 | std::stringstream s; |
---|
31 | s<<"AMBIENT_DIM"<<std::endl; |
---|
32 | s<<c->ambientDimension()<<std::endl; |
---|
33 | |
---|
34 | gfan::ZMatrix i=c->getInequalities(); |
---|
35 | char* ineqs = toString(i); |
---|
36 | if (c->areFacetsKnown()) |
---|
37 | s<<"FACETS"<<std::endl; |
---|
38 | else |
---|
39 | s<<"INEQUALITIES"<<std::endl; |
---|
40 | if (ineqs!=NULL) |
---|
41 | { |
---|
42 | s<<ineqs<<std::endl; |
---|
43 | omFree(ineqs); |
---|
44 | } |
---|
45 | |
---|
46 | gfan::ZMatrix e=c->getEquations(); |
---|
47 | char* eqs = toString(e); |
---|
48 | if (c->areImpliedEquationsKnown()) |
---|
49 | s<<"LINEAR_SPAN"<<std::endl; |
---|
50 | else |
---|
51 | s<<"EQUATIONS"<<std::endl; |
---|
52 | if (eqs!=NULL) |
---|
53 | { |
---|
54 | s<<eqs<<std::endl; |
---|
55 | omFree(eqs); |
---|
56 | } |
---|
57 | |
---|
58 | if (c->areExtremeRaysKnown()) |
---|
59 | { |
---|
60 | gfan::ZMatrix r=c->extremeRays(); |
---|
61 | char* rs = toString(r); |
---|
62 | s<<"RAYS"<<std::endl; |
---|
63 | if (rs!=NULL) |
---|
64 | { |
---|
65 | s<<rs<<std::endl; |
---|
66 | omFree(rs); |
---|
67 | } |
---|
68 | gfan::ZMatrix l=c->generatorsOfLinealitySpace(); |
---|
69 | char* ls = toString(l); |
---|
70 | s<<"LINEALITY_SPACE"<<std::endl; |
---|
71 | if (ls!=NULL) |
---|
72 | { |
---|
73 | s<<ls<<std::endl; |
---|
74 | omFree(ls); |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | return s.str(); |
---|
79 | } |
---|
80 | |
---|
81 | void* bbcone_Init(blackbox* /*b*/) |
---|
82 | { |
---|
83 | return (void*)(new gfan::ZCone()); |
---|
84 | } |
---|
85 | |
---|
86 | BOOLEAN bbcone_Assign(leftv l, leftv r) |
---|
87 | { |
---|
88 | gfan::ZCone* newZc; |
---|
89 | if (r==NULL) |
---|
90 | { |
---|
91 | if (l->Data()!=NULL) |
---|
92 | { |
---|
93 | gfan::ZCone* zd = (gfan::ZCone*)l->Data(); |
---|
94 | delete zd; |
---|
95 | } |
---|
96 | newZc = new gfan::ZCone(); |
---|
97 | } |
---|
98 | else if (r->Typ()==l->Typ()) |
---|
99 | { |
---|
100 | if (l->Data()!=NULL) |
---|
101 | { |
---|
102 | gfan::ZCone* zd = (gfan::ZCone*)l->Data(); |
---|
103 | delete zd; |
---|
104 | } |
---|
105 | newZc = (gfan::ZCone*)r->CopyD(); |
---|
106 | } |
---|
107 | else if (r->Typ()==INT_CMD) |
---|
108 | { |
---|
109 | int ambientDim = (int)(long)r->Data(); |
---|
110 | if (ambientDim < 0) |
---|
111 | { |
---|
112 | Werror("expected an int >= 0, but got %d", ambientDim); |
---|
113 | return TRUE; |
---|
114 | } |
---|
115 | if (l->Data()!=NULL) |
---|
116 | { |
---|
117 | gfan::ZCone* zd = (gfan::ZCone*)l->Data(); |
---|
118 | delete zd; |
---|
119 | } |
---|
120 | newZc = new gfan::ZCone(ambientDim); |
---|
121 | } |
---|
122 | else |
---|
123 | { |
---|
124 | Werror("assign Type(%d) = Type(%d) not implemented",l->Typ(),r->Typ()); |
---|
125 | return TRUE; |
---|
126 | } |
---|
127 | |
---|
128 | if (l->rtyp==IDHDL) |
---|
129 | { |
---|
130 | IDDATA((idhdl)l->data)=(char*) newZc; |
---|
131 | } |
---|
132 | else |
---|
133 | { |
---|
134 | l->data=(void *)newZc; |
---|
135 | } |
---|
136 | return FALSE; |
---|
137 | } |
---|
138 | |
---|
139 | char* bbcone_String(blackbox* /*b*/, void *d) |
---|
140 | { |
---|
141 | if (d==NULL) return omStrDup("invalid object"); |
---|
142 | else |
---|
143 | { |
---|
144 | std::string s=toString((gfan::ZCone*) d); |
---|
145 | return omStrDup(s.c_str()); |
---|
146 | } |
---|
147 | } |
---|
148 | |
---|
149 | void bbcone_destroy(blackbox* /*b*/, void *d) |
---|
150 | { |
---|
151 | if (d!=NULL) |
---|
152 | { |
---|
153 | gfan::ZCone* zc = (gfan::ZCone*) d; |
---|
154 | delete zc; |
---|
155 | } |
---|
156 | } |
---|
157 | |
---|
158 | void* bbcone_Copy(blackbox* /*b*/, void *d) |
---|
159 | { |
---|
160 | gfan::ZCone* zc = (gfan::ZCone*)d; |
---|
161 | gfan::ZCone* newZc = new gfan::ZCone(*zc); |
---|
162 | return newZc; |
---|
163 | } |
---|
164 | |
---|
165 | static BOOLEAN bbcone_Op2(int op, leftv res, leftv i1, leftv i2) |
---|
166 | { |
---|
167 | gfan::ZCone* zp = (gfan::ZCone*) i1->Data(); |
---|
168 | switch(op) |
---|
169 | { |
---|
170 | case '&': |
---|
171 | { |
---|
172 | if (i2->Typ()==coneID) |
---|
173 | { |
---|
174 | gfan::ZCone* zq = (gfan::ZCone*) i2->Data(); |
---|
175 | int d1 = zp->ambientDimension(); |
---|
176 | int d2 = zq->ambientDimension(); |
---|
177 | if (d1 != d2) |
---|
178 | { |
---|
179 | WerrorS("mismatching ambient dimensions"); |
---|
180 | return TRUE; |
---|
181 | } |
---|
182 | gfan::ZCone* zs = new gfan::ZCone(); |
---|
183 | *zs = gfan::intersection(*zp, *zq); |
---|
184 | zs->canonicalize(); |
---|
185 | res->rtyp = coneID; |
---|
186 | res->data = (void*) zs; |
---|
187 | return FALSE; |
---|
188 | } |
---|
189 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
190 | } |
---|
191 | case '|': |
---|
192 | { |
---|
193 | if(i2->Typ()==coneID) |
---|
194 | { |
---|
195 | gfan::ZCone* zq = (gfan::ZCone*) i2->Data(); |
---|
196 | int d1 = zp->ambientDimension(); |
---|
197 | int d2 = zq->ambientDimension(); |
---|
198 | if (d1 != d2) |
---|
199 | { |
---|
200 | WerrorS("mismatching ambient dimensions"); |
---|
201 | return TRUE; |
---|
202 | } |
---|
203 | gfan::ZMatrix rays = zp->extremeRays(); |
---|
204 | rays.append(zq->extremeRays()); |
---|
205 | gfan::ZMatrix lineality = zp->generatorsOfLinealitySpace(); |
---|
206 | lineality.append(zq->generatorsOfLinealitySpace()); |
---|
207 | gfan::ZCone* zs = new gfan::ZCone(); |
---|
208 | *zs = gfan::ZCone::givenByRays(rays,lineality); |
---|
209 | zs->canonicalize(); |
---|
210 | res->rtyp = coneID; |
---|
211 | res->data = (void*) zs; |
---|
212 | return FALSE; |
---|
213 | } |
---|
214 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
215 | } |
---|
216 | case EQUAL_EQUAL: |
---|
217 | { |
---|
218 | if(i2->Typ()==coneID) |
---|
219 | { |
---|
220 | gfan::ZCone* zq = (gfan::ZCone*) i2->Data(); |
---|
221 | zp->canonicalize(); |
---|
222 | zq->canonicalize(); |
---|
223 | bool b = !((*zp)!=(*zq)); |
---|
224 | res->rtyp = INT_CMD; |
---|
225 | res->data = (void*) b; |
---|
226 | return FALSE; |
---|
227 | } |
---|
228 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
229 | } |
---|
230 | default: |
---|
231 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
232 | } |
---|
233 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
234 | } |
---|
235 | |
---|
236 | |
---|
237 | /* singular wrapper for gfanlib functions */ |
---|
238 | static BOOLEAN jjCONENORMALS1(leftv res, leftv v) |
---|
239 | { |
---|
240 | /* method for generating a cone object from inequalities; |
---|
241 | valid parametrizations: (intmat) */ |
---|
242 | bigintmat* ineq = NULL; |
---|
243 | if (v->Typ() == INTMAT_CMD) |
---|
244 | { |
---|
245 | intvec* ineq0 = (intvec*) v->Data(); |
---|
246 | ineq = iv2bim(ineq0,coeffs_BIGINT); |
---|
247 | } |
---|
248 | else |
---|
249 | ineq = (bigintmat*) v->Data(); |
---|
250 | gfan::ZMatrix* zm = bigintmatToZMatrix(ineq); |
---|
251 | gfan::ZCone* zc = new gfan::ZCone(*zm, gfan::ZMatrix(0, zm->getWidth())); |
---|
252 | delete zm; |
---|
253 | if (v->Typ() == INTMAT_CMD) |
---|
254 | delete ineq; |
---|
255 | res->rtyp = coneID; |
---|
256 | res->data = (void*) zc; |
---|
257 | return FALSE; |
---|
258 | } |
---|
259 | |
---|
260 | static BOOLEAN jjCONENORMALS2(leftv res, leftv u, leftv v) |
---|
261 | { |
---|
262 | /* method for generating a cone object from iequalities, |
---|
263 | and equations (...) |
---|
264 | valid parametrizations: (intmat, intmat) |
---|
265 | Errors will be invoked in the following cases: |
---|
266 | - u and v have different numbers of columns */ |
---|
267 | bigintmat* ineq = NULL; bigintmat* eq = NULL; |
---|
268 | if (u->Typ() == INTMAT_CMD) |
---|
269 | { |
---|
270 | intvec* ineq0 = (intvec*) u->Data(); |
---|
271 | ineq = iv2bim(ineq0,coeffs_BIGINT); |
---|
272 | } |
---|
273 | else |
---|
274 | ineq = (bigintmat*) u->Data(); |
---|
275 | if (v->Typ() == INTMAT_CMD) |
---|
276 | { |
---|
277 | intvec* eq0 = (intvec*) v->Data(); |
---|
278 | eq = iv2bim(eq0,coeffs_BIGINT); |
---|
279 | } |
---|
280 | else |
---|
281 | eq = (bigintmat*) v->Data(); |
---|
282 | |
---|
283 | if (ineq->cols() != eq->cols()) |
---|
284 | { |
---|
285 | Werror("expected same number of columns but got %d vs. %d", |
---|
286 | ineq->cols(), eq->cols()); |
---|
287 | return TRUE; |
---|
288 | } |
---|
289 | gfan::ZMatrix* zm1 = bigintmatToZMatrix(ineq); |
---|
290 | gfan::ZMatrix* zm2 = bigintmatToZMatrix(eq); |
---|
291 | gfan::ZCone* zc = new gfan::ZCone(*zm1, *zm2); |
---|
292 | delete zm1; |
---|
293 | delete zm2; |
---|
294 | if (u->Typ() == INTMAT_CMD) |
---|
295 | delete ineq; |
---|
296 | if (v->Typ() == INTMAT_CMD) |
---|
297 | delete eq; |
---|
298 | res->rtyp = coneID; |
---|
299 | res->data = (void*) zc; |
---|
300 | return FALSE; |
---|
301 | } |
---|
302 | |
---|
303 | static BOOLEAN jjCONENORMALS3(leftv res, leftv u, leftv v, leftv w) |
---|
304 | { |
---|
305 | /* method for generating a cone object from inequalities, equations, |
---|
306 | and an integer k; |
---|
307 | valid parametrizations: (intmat, intmat, int); |
---|
308 | Errors will be invoked in the following cases: |
---|
309 | - u and v have different numbers of columns, |
---|
310 | - k not in [0..3]; |
---|
311 | if the 2^0-bit of k is set, then ... */ |
---|
312 | bigintmat* ineq = NULL; bigintmat* eq = NULL; |
---|
313 | if (u->Typ() == INTMAT_CMD) |
---|
314 | { |
---|
315 | intvec* ineq0 = (intvec*) u->Data(); |
---|
316 | ineq = iv2bim(ineq0,coeffs_BIGINT); |
---|
317 | } |
---|
318 | else |
---|
319 | ineq = (bigintmat*) u->Data(); |
---|
320 | if (v->Typ() == INTMAT_CMD) |
---|
321 | { |
---|
322 | intvec* eq0 = (intvec*) v->Data(); |
---|
323 | eq = iv2bim(eq0,coeffs_BIGINT); |
---|
324 | } |
---|
325 | else |
---|
326 | eq = (bigintmat*) v->Data(); |
---|
327 | if (ineq->cols() != eq->cols()) |
---|
328 | { |
---|
329 | Werror("expected same number of columns but got %d vs. %d", |
---|
330 | ineq->cols(), eq->cols()); |
---|
331 | return TRUE; |
---|
332 | } |
---|
333 | int k = (int)(long)w->Data(); |
---|
334 | if ((k < 0) || (k > 3)) |
---|
335 | { |
---|
336 | WerrorS("expected int argument in [0..3]"); |
---|
337 | return TRUE; |
---|
338 | } |
---|
339 | gfan::ZMatrix* zm1 = bigintmatToZMatrix(ineq); |
---|
340 | gfan::ZMatrix* zm2 = bigintmatToZMatrix(eq); |
---|
341 | gfan::ZCone* zc = new gfan::ZCone(*zm1, *zm2, k); |
---|
342 | delete zm1; |
---|
343 | delete zm2; |
---|
344 | if (u->Typ() == INTMAT_CMD) |
---|
345 | delete ineq; |
---|
346 | if (v->Typ() == INTMAT_CMD) |
---|
347 | delete eq; |
---|
348 | res->rtyp = coneID; |
---|
349 | res->data = (void*) zc; |
---|
350 | return FALSE; |
---|
351 | } |
---|
352 | |
---|
353 | BOOLEAN coneViaNormals(leftv res, leftv args) |
---|
354 | { |
---|
355 | gfan::initializeCddlibIfRequired(); |
---|
356 | leftv u = args; |
---|
357 | if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD))) |
---|
358 | { |
---|
359 | if (u->next == NULL) |
---|
360 | { |
---|
361 | BOOLEAN bo = jjCONENORMALS1(res, u); |
---|
362 | gfan::deinitializeCddlibIfRequired(); |
---|
363 | return bo; |
---|
364 | } |
---|
365 | } |
---|
366 | leftv v = u->next; |
---|
367 | if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTMAT_CMD))) |
---|
368 | { |
---|
369 | if (v->next == NULL) |
---|
370 | { |
---|
371 | BOOLEAN bo = jjCONENORMALS2(res, u, v); |
---|
372 | gfan::deinitializeCddlibIfRequired(); |
---|
373 | return bo; |
---|
374 | } |
---|
375 | } |
---|
376 | leftv w = v->next; |
---|
377 | if ((w != NULL) && (w->Typ() == INT_CMD)) |
---|
378 | { |
---|
379 | if (w->next == NULL) |
---|
380 | { |
---|
381 | BOOLEAN bo = jjCONENORMALS3(res, u, v, w); |
---|
382 | gfan::deinitializeCddlibIfRequired(); |
---|
383 | return bo; |
---|
384 | } |
---|
385 | } |
---|
386 | WerrorS("coneViaInequalities: unexpected parameters"); |
---|
387 | return TRUE; |
---|
388 | } |
---|
389 | |
---|
390 | static BOOLEAN jjCONERAYS1(leftv res, leftv v) |
---|
391 | { |
---|
392 | /* method for generating a cone object from half-lines |
---|
393 | (cone = convex hull of the half-lines; note: there may be |
---|
394 | entire lines in the cone); |
---|
395 | valid parametrizations: (intmat) */ |
---|
396 | bigintmat* rays = NULL; |
---|
397 | if (v->Typ() == INTMAT_CMD) |
---|
398 | { |
---|
399 | intvec* rays0 = (intvec*) v->Data(); |
---|
400 | rays = iv2bim(rays0,coeffs_BIGINT); |
---|
401 | } |
---|
402 | else |
---|
403 | rays = (bigintmat*) v->Data(); |
---|
404 | |
---|
405 | gfan::ZMatrix* zm = bigintmatToZMatrix(rays); |
---|
406 | gfan::ZCone* zc = new gfan::ZCone(); |
---|
407 | *zc = gfan::ZCone::givenByRays(*zm, gfan::ZMatrix(0, zm->getWidth())); |
---|
408 | res->rtyp = coneID; |
---|
409 | res->data = (void*) zc; |
---|
410 | |
---|
411 | delete zm; |
---|
412 | if (v->Typ() == INTMAT_CMD) |
---|
413 | delete rays; |
---|
414 | return FALSE; |
---|
415 | } |
---|
416 | |
---|
417 | static BOOLEAN jjCONERAYS2(leftv res, leftv u, leftv v) |
---|
418 | { |
---|
419 | /* method for generating a cone object from half-lines, |
---|
420 | and lines (any point in the cone being the sum of a point |
---|
421 | in the convex hull of the half-lines and a point in the span |
---|
422 | of the lines; the second argument may contain or entirely consist |
---|
423 | of zero rows); |
---|
424 | valid parametrizations: (intmat, intmat) |
---|
425 | Errors will be invoked in the following cases: |
---|
426 | - u and v have different numbers of columns */ |
---|
427 | bigintmat* rays = NULL; bigintmat* linSpace = NULL; |
---|
428 | if (u->Typ() == INTMAT_CMD) |
---|
429 | { |
---|
430 | intvec* rays0 = (intvec*) u->Data(); |
---|
431 | rays = iv2bim(rays0,coeffs_BIGINT); |
---|
432 | } |
---|
433 | else |
---|
434 | rays = (bigintmat*) u->Data(); |
---|
435 | if (v->Typ() == INTMAT_CMD) |
---|
436 | { |
---|
437 | intvec* linSpace0 = (intvec*) v->Data(); |
---|
438 | linSpace = iv2bim(linSpace0,coeffs_BIGINT); |
---|
439 | } |
---|
440 | else |
---|
441 | linSpace = (bigintmat*) v->Data(); |
---|
442 | |
---|
443 | if (rays->cols() != linSpace->cols()) |
---|
444 | { |
---|
445 | Werror("expected same number of columns but got %d vs. %d", |
---|
446 | rays->cols(), linSpace->cols()); |
---|
447 | return TRUE; |
---|
448 | } |
---|
449 | gfan::ZMatrix* zm1 = bigintmatToZMatrix(rays); |
---|
450 | gfan::ZMatrix* zm2 = bigintmatToZMatrix(linSpace); |
---|
451 | gfan::ZCone* zc = new gfan::ZCone(); |
---|
452 | *zc = gfan::ZCone::givenByRays(*zm1, *zm2); |
---|
453 | res->rtyp = coneID; |
---|
454 | res->data = (void*) zc; |
---|
455 | |
---|
456 | delete zm1; |
---|
457 | delete zm2; |
---|
458 | if (u->Typ() == INTMAT_CMD) |
---|
459 | delete rays; |
---|
460 | if (v->Typ() == INTMAT_CMD) |
---|
461 | delete linSpace; |
---|
462 | return FALSE; |
---|
463 | } |
---|
464 | |
---|
465 | static BOOLEAN jjCONERAYS3(leftv res, leftv u, leftv v, leftv w) |
---|
466 | { |
---|
467 | /* method for generating a cone object from half-lines, |
---|
468 | and lines (any point in the cone being the sum of a point |
---|
469 | in the convex hull of the half-lines and a point in the span |
---|
470 | of the lines), and an integer k; |
---|
471 | valid parametrizations: (intmat, intmat, int); |
---|
472 | Errors will be invoked in the following cases: |
---|
473 | - u and v have different numbers of columns, |
---|
474 | - k not in [0..3]; |
---|
475 | if the 2^0-bit of k is set, then the lineality space is known |
---|
476 | to be the span of the provided lines; |
---|
477 | if the 2^1-bit of k is set, then the extreme rays are known: |
---|
478 | each half-line spans a (different) extreme ray */ |
---|
479 | bigintmat* rays = NULL; bigintmat* linSpace = NULL; |
---|
480 | if (u->Typ() == INTMAT_CMD) |
---|
481 | { |
---|
482 | intvec* rays0 = (intvec*) u->Data(); |
---|
483 | rays = iv2bim(rays0,coeffs_BIGINT); |
---|
484 | } |
---|
485 | else |
---|
486 | rays = (bigintmat*) u->Data(); |
---|
487 | if (v->Typ() == INTMAT_CMD) |
---|
488 | { |
---|
489 | intvec* linSpace0 = (intvec*) v->Data(); |
---|
490 | linSpace = iv2bim(linSpace0,coeffs_BIGINT); |
---|
491 | } |
---|
492 | else |
---|
493 | linSpace = (bigintmat*) v->Data(); |
---|
494 | |
---|
495 | if (rays->cols() != linSpace->cols()) |
---|
496 | { |
---|
497 | Werror("expected same number of columns but got %d vs. %d", |
---|
498 | rays->cols(), linSpace->cols()); |
---|
499 | return TRUE; |
---|
500 | } |
---|
501 | int k = (int)(long)w->Data(); |
---|
502 | if ((k < 0) || (k > 3)) |
---|
503 | { |
---|
504 | WerrorS("expected int argument in [0..3]"); |
---|
505 | return TRUE; |
---|
506 | } |
---|
507 | gfan::ZMatrix* zm1 = bigintmatToZMatrix(rays); |
---|
508 | gfan::ZMatrix* zm2 = bigintmatToZMatrix(linSpace); |
---|
509 | gfan::ZCone* zc = new gfan::ZCone(); |
---|
510 | *zc = gfan::ZCone::givenByRays(*zm1, *zm2); |
---|
511 | //k should be passed on to zc; not available yet |
---|
512 | res->rtyp = coneID; |
---|
513 | res->data = (void*) zc; |
---|
514 | |
---|
515 | delete zm1; |
---|
516 | delete zm2; |
---|
517 | if (u->Typ() == INTMAT_CMD) |
---|
518 | delete rays; |
---|
519 | if (v->Typ() == INTMAT_CMD) |
---|
520 | delete linSpace; |
---|
521 | return FALSE; |
---|
522 | } |
---|
523 | |
---|
524 | BOOLEAN coneViaRays(leftv res, leftv args) |
---|
525 | { |
---|
526 | gfan::initializeCddlibIfRequired(); |
---|
527 | leftv u = args; |
---|
528 | if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD))) |
---|
529 | { |
---|
530 | if (u->next == NULL) |
---|
531 | { |
---|
532 | BOOLEAN bo = jjCONERAYS1(res, u); |
---|
533 | gfan::deinitializeCddlibIfRequired(); |
---|
534 | return bo; |
---|
535 | } |
---|
536 | leftv v = u->next; |
---|
537 | if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTMAT_CMD))) |
---|
538 | { |
---|
539 | if (v->next == NULL) |
---|
540 | { |
---|
541 | BOOLEAN bo = jjCONERAYS2(res, u, v); |
---|
542 | gfan::deinitializeCddlibIfRequired(); |
---|
543 | return bo; |
---|
544 | } |
---|
545 | leftv w = v->next; |
---|
546 | if ((w != NULL) && (w->Typ() == INT_CMD)) |
---|
547 | { |
---|
548 | if (w->next == NULL) |
---|
549 | { |
---|
550 | BOOLEAN bo = jjCONERAYS3(res, u, v, w); |
---|
551 | gfan::deinitializeCddlibIfRequired(); |
---|
552 | return bo; |
---|
553 | } |
---|
554 | } |
---|
555 | } |
---|
556 | } |
---|
557 | WerrorS("coneViaPoints: unexpected parameters"); |
---|
558 | return TRUE; |
---|
559 | } |
---|
560 | |
---|
561 | BOOLEAN inequalities(leftv res, leftv args) |
---|
562 | { |
---|
563 | leftv u = args; |
---|
564 | if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID)) |
---|
565 | { |
---|
566 | gfan::initializeCddlibIfRequired(); |
---|
567 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
568 | gfan::ZMatrix zmat = zc->getInequalities(); |
---|
569 | res->rtyp = BIGINTMAT_CMD; |
---|
570 | res->data = (void*) zMatrixToBigintmat(zmat); |
---|
571 | gfan::deinitializeCddlibIfRequired(); |
---|
572 | return FALSE; |
---|
573 | } |
---|
574 | WerrorS("inequalities: unexpected parameters"); |
---|
575 | return TRUE; |
---|
576 | } |
---|
577 | |
---|
578 | BOOLEAN equations(leftv res, leftv args) |
---|
579 | { |
---|
580 | leftv u = args; |
---|
581 | if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID)) |
---|
582 | { |
---|
583 | gfan::initializeCddlibIfRequired(); |
---|
584 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
585 | gfan::ZMatrix zmat = zc->getEquations(); |
---|
586 | res->rtyp = BIGINTMAT_CMD; |
---|
587 | res->data = (void*) zMatrixToBigintmat(zmat); |
---|
588 | gfan::deinitializeCddlibIfRequired(); |
---|
589 | return FALSE; |
---|
590 | } |
---|
591 | WerrorS("equations: unexpected parameters"); |
---|
592 | return TRUE; |
---|
593 | } |
---|
594 | |
---|
595 | BOOLEAN facets(leftv res, leftv args) |
---|
596 | { |
---|
597 | leftv u = args; |
---|
598 | if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID)) |
---|
599 | { |
---|
600 | gfan::initializeCddlibIfRequired(); |
---|
601 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
602 | gfan::ZMatrix zm = zc->getFacets(); |
---|
603 | res->rtyp = BIGINTMAT_CMD; |
---|
604 | res->data = (void*) zMatrixToBigintmat(zm); |
---|
605 | gfan::deinitializeCddlibIfRequired(); |
---|
606 | return FALSE; |
---|
607 | } |
---|
608 | WerrorS("facets: unexpected parameters"); |
---|
609 | return TRUE; |
---|
610 | } |
---|
611 | |
---|
612 | BOOLEAN impliedEquations(leftv res, leftv args) |
---|
613 | { |
---|
614 | leftv u = args; |
---|
615 | if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID)) |
---|
616 | { |
---|
617 | gfan::initializeCddlibIfRequired(); |
---|
618 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
619 | gfan::ZMatrix zmat = zc->getImpliedEquations(); |
---|
620 | res->rtyp = BIGINTMAT_CMD; |
---|
621 | res->data = (void*) zMatrixToBigintmat(zmat); |
---|
622 | gfan::deinitializeCddlibIfRequired(); |
---|
623 | return FALSE; |
---|
624 | } |
---|
625 | WerrorS("span: unexpected parameters"); |
---|
626 | return TRUE; |
---|
627 | } |
---|
628 | |
---|
629 | BOOLEAN generatorsOfSpan(leftv res, leftv args) |
---|
630 | { |
---|
631 | leftv u = args; |
---|
632 | if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID)) |
---|
633 | { |
---|
634 | gfan::initializeCddlibIfRequired(); |
---|
635 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
636 | gfan::ZMatrix zmat = zc->generatorsOfSpan(); |
---|
637 | res->rtyp = BIGINTMAT_CMD; |
---|
638 | res->data = (void*) zMatrixToBigintmat(zmat); |
---|
639 | gfan::deinitializeCddlibIfRequired(); |
---|
640 | return FALSE; |
---|
641 | } |
---|
642 | WerrorS("generatorsOfSpan: unexpected parameters"); |
---|
643 | return TRUE; |
---|
644 | } |
---|
645 | |
---|
646 | BOOLEAN generatorsOfLinealitySpace(leftv res, leftv args) |
---|
647 | { |
---|
648 | leftv u = args; |
---|
649 | if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID)) |
---|
650 | { |
---|
651 | gfan::initializeCddlibIfRequired(); |
---|
652 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
653 | gfan::ZMatrix zmat = zc->generatorsOfLinealitySpace(); |
---|
654 | res->rtyp = BIGINTMAT_CMD; |
---|
655 | res->data = (void*) zMatrixToBigintmat(zmat); |
---|
656 | gfan::deinitializeCddlibIfRequired(); |
---|
657 | return FALSE; |
---|
658 | } |
---|
659 | WerrorS("generatorsOfLinealitySpace: unexpected parameters"); |
---|
660 | return TRUE; |
---|
661 | } |
---|
662 | |
---|
663 | BOOLEAN rays(leftv res, leftv args) |
---|
664 | { |
---|
665 | leftv u = args; |
---|
666 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
667 | { |
---|
668 | gfan::initializeCddlibIfRequired(); |
---|
669 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
670 | gfan::ZMatrix zm = zc->extremeRays(); |
---|
671 | res->rtyp = BIGINTMAT_CMD; |
---|
672 | res->data = (void*)zMatrixToBigintmat(zm); |
---|
673 | gfan::deinitializeCddlibIfRequired(); |
---|
674 | return FALSE; |
---|
675 | } |
---|
676 | if ((u != NULL) && (u->Typ() == fanID)) |
---|
677 | { |
---|
678 | gfan::initializeCddlibIfRequired(); |
---|
679 | gfan::ZFan* zf = (gfan::ZFan*)u->Data(); |
---|
680 | gfan::ZMatrix zmat = rays(zf); |
---|
681 | res->rtyp = BIGINTMAT_CMD; |
---|
682 | res->data = (void*) zMatrixToBigintmat(zmat); |
---|
683 | gfan::deinitializeCddlibIfRequired(); |
---|
684 | return FALSE; |
---|
685 | } |
---|
686 | WerrorS("rays: unexpected parameters"); |
---|
687 | return TRUE; |
---|
688 | } |
---|
689 | |
---|
690 | BOOLEAN quotientLatticeBasis(leftv res, leftv args) |
---|
691 | { |
---|
692 | leftv u = args; |
---|
693 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
694 | { |
---|
695 | gfan::initializeCddlibIfRequired(); |
---|
696 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
697 | gfan::ZMatrix zmat = zc->quotientLatticeBasis(); |
---|
698 | res->rtyp = BIGINTMAT_CMD; |
---|
699 | res->data = (void*) zMatrixToBigintmat(zmat); |
---|
700 | gfan::deinitializeCddlibIfRequired(); |
---|
701 | return FALSE; |
---|
702 | } |
---|
703 | WerrorS("quotientLatticeBasis: unexpected parameters"); |
---|
704 | return TRUE; |
---|
705 | } |
---|
706 | |
---|
707 | BOOLEAN getLinearForms(leftv res, leftv args) |
---|
708 | { |
---|
709 | leftv u = args; |
---|
710 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
711 | { |
---|
712 | gfan::initializeCddlibIfRequired(); |
---|
713 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
714 | gfan::ZMatrix zmat = zc->getLinearForms(); |
---|
715 | res->rtyp = BIGINTMAT_CMD; |
---|
716 | res->data = (void*) zMatrixToBigintmat(zmat); |
---|
717 | gfan::deinitializeCddlibIfRequired(); |
---|
718 | return FALSE; |
---|
719 | } |
---|
720 | WerrorS("getLinearForms: unexpected parameters"); |
---|
721 | return TRUE; |
---|
722 | } |
---|
723 | |
---|
724 | BOOLEAN ambientDimension(leftv res, leftv args) |
---|
725 | { |
---|
726 | leftv u=args; |
---|
727 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
728 | { |
---|
729 | gfan::initializeCddlibIfRequired(); |
---|
730 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
731 | res->rtyp = INT_CMD; |
---|
732 | res->data = (void*) (long) zc->ambientDimension(); |
---|
733 | gfan::deinitializeCddlibIfRequired(); |
---|
734 | return FALSE; |
---|
735 | } |
---|
736 | if ((u != NULL) && (u->Typ() == fanID)) |
---|
737 | { |
---|
738 | gfan::initializeCddlibIfRequired(); |
---|
739 | gfan::ZFan* zf = (gfan::ZFan*)u->Data(); |
---|
740 | res->rtyp = INT_CMD; |
---|
741 | res->data = (void*) (long) getAmbientDimension(zf); |
---|
742 | gfan::deinitializeCddlibIfRequired(); |
---|
743 | return FALSE; |
---|
744 | } |
---|
745 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
746 | { |
---|
747 | gfan::initializeCddlibIfRequired(); |
---|
748 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
749 | res->rtyp = INT_CMD; |
---|
750 | res->data = (void*) (long) getAmbientDimension(zc); |
---|
751 | gfan::deinitializeCddlibIfRequired(); |
---|
752 | return FALSE; |
---|
753 | } |
---|
754 | WerrorS("ambientDimension: unexpected parameters"); |
---|
755 | return TRUE; |
---|
756 | } |
---|
757 | |
---|
758 | BOOLEAN dimension(leftv res, leftv args) |
---|
759 | { |
---|
760 | leftv u=args; |
---|
761 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
762 | { |
---|
763 | gfan::initializeCddlibIfRequired(); |
---|
764 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
765 | res->rtyp = INT_CMD; |
---|
766 | res->data = (void*) (long) zc->dimension(); |
---|
767 | gfan::deinitializeCddlibIfRequired(); |
---|
768 | return FALSE; |
---|
769 | } |
---|
770 | if ((u != NULL) && (u->Typ() == fanID)) |
---|
771 | { |
---|
772 | gfan::initializeCddlibIfRequired(); |
---|
773 | gfan::ZFan* zf = (gfan::ZFan*)u->Data(); |
---|
774 | res->rtyp = INT_CMD; |
---|
775 | res->data = (void*) (long) getDimension(zf); |
---|
776 | gfan::deinitializeCddlibIfRequired(); |
---|
777 | return FALSE; |
---|
778 | } |
---|
779 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
780 | { |
---|
781 | gfan::initializeCddlibIfRequired(); |
---|
782 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
783 | res->rtyp = INT_CMD; |
---|
784 | res->data = (void*) (long) getDimension(zc); |
---|
785 | gfan::deinitializeCddlibIfRequired(); |
---|
786 | return FALSE; |
---|
787 | } |
---|
788 | WerrorS("dimension: unexpected parameters"); |
---|
789 | return TRUE; |
---|
790 | } |
---|
791 | |
---|
792 | BOOLEAN codimension(leftv res, leftv args) |
---|
793 | { |
---|
794 | leftv u=args; |
---|
795 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
796 | { |
---|
797 | gfan::initializeCddlibIfRequired(); |
---|
798 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
799 | res->rtyp = INT_CMD; |
---|
800 | res->data = (void*) (long) zc->codimension(); |
---|
801 | gfan::deinitializeCddlibIfRequired(); |
---|
802 | return FALSE; |
---|
803 | } |
---|
804 | if ((u != NULL) && (u->Typ() == fanID)) |
---|
805 | { |
---|
806 | gfan::initializeCddlibIfRequired(); |
---|
807 | gfan::ZFan* zf = (gfan::ZFan*)u->Data(); |
---|
808 | res->rtyp = INT_CMD; |
---|
809 | res->data = (void*) (long) getCodimension(zf); |
---|
810 | gfan::deinitializeCddlibIfRequired(); |
---|
811 | return FALSE; |
---|
812 | } |
---|
813 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
814 | { |
---|
815 | gfan::initializeCddlibIfRequired(); |
---|
816 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
817 | res->rtyp = INT_CMD; |
---|
818 | res->data = (void*) (long) getCodimension(zc); |
---|
819 | gfan::deinitializeCddlibIfRequired(); |
---|
820 | return FALSE; |
---|
821 | } |
---|
822 | WerrorS("getCodimension: unexpected parameters"); |
---|
823 | return TRUE; |
---|
824 | } |
---|
825 | |
---|
826 | BOOLEAN linealityDimension(leftv res, leftv args) |
---|
827 | { |
---|
828 | leftv u=args; |
---|
829 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
830 | { |
---|
831 | gfan::initializeCddlibIfRequired(); |
---|
832 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
833 | res->rtyp = INT_CMD; |
---|
834 | res->data = (void*) (long) zc->dimensionOfLinealitySpace(); |
---|
835 | gfan::deinitializeCddlibIfRequired(); |
---|
836 | return FALSE; |
---|
837 | } |
---|
838 | if ((u != NULL) && (u->Typ() == fanID)) |
---|
839 | { |
---|
840 | gfan::initializeCddlibIfRequired(); |
---|
841 | gfan::ZFan* zf = (gfan::ZFan*)u->Data(); |
---|
842 | res->rtyp = INT_CMD; |
---|
843 | res->data = (void*) (long) getLinealityDimension(zf); |
---|
844 | gfan::deinitializeCddlibIfRequired(); |
---|
845 | return FALSE; |
---|
846 | } |
---|
847 | WerrorS("linealityDimension: unexpected parameters"); |
---|
848 | return TRUE; |
---|
849 | } |
---|
850 | |
---|
851 | BOOLEAN getMultiplicity(leftv res, leftv args) |
---|
852 | { |
---|
853 | leftv u = args; |
---|
854 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
855 | { |
---|
856 | gfan::initializeCddlibIfRequired(); |
---|
857 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
858 | number i = integerToNumber(zc->getMultiplicity()); |
---|
859 | res->rtyp = BIGINT_CMD; |
---|
860 | res->data = (void*) i; |
---|
861 | gfan::deinitializeCddlibIfRequired(); |
---|
862 | return FALSE; |
---|
863 | } |
---|
864 | WerrorS("getMultiplicity: unexpected parameters"); |
---|
865 | return TRUE; |
---|
866 | } |
---|
867 | |
---|
868 | BOOLEAN isOrigin(leftv res, leftv args) |
---|
869 | { |
---|
870 | leftv u = args; |
---|
871 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
872 | { |
---|
873 | gfan::initializeCddlibIfRequired(); |
---|
874 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
875 | int i = zc->isOrigin(); |
---|
876 | res->rtyp = INT_CMD; |
---|
877 | res->data = (void*) (long) i; |
---|
878 | gfan::deinitializeCddlibIfRequired(); |
---|
879 | return FALSE; |
---|
880 | } |
---|
881 | WerrorS("isOrigin: unexpected parameters"); |
---|
882 | return TRUE; |
---|
883 | } |
---|
884 | |
---|
885 | BOOLEAN isFullSpace(leftv res, leftv args) |
---|
886 | { |
---|
887 | leftv u = args; |
---|
888 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
889 | { |
---|
890 | gfan::initializeCddlibIfRequired(); |
---|
891 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
892 | int i = zc->isFullSpace(); |
---|
893 | res->rtyp = INT_CMD; |
---|
894 | res->data = (void*) (long) i; |
---|
895 | gfan::deinitializeCddlibIfRequired(); |
---|
896 | return FALSE; |
---|
897 | } |
---|
898 | WerrorS("isFullSpace: unexpected parameters"); |
---|
899 | return TRUE; |
---|
900 | } |
---|
901 | |
---|
902 | BOOLEAN isSimplicial(leftv res, leftv args) |
---|
903 | { |
---|
904 | leftv u=args; |
---|
905 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
906 | { |
---|
907 | gfan::initializeCddlibIfRequired(); |
---|
908 | gfan::ZCone* zc = (gfan::ZCone*) u->Data(); |
---|
909 | int b = zc->isSimplicial(); |
---|
910 | res->rtyp = INT_CMD; |
---|
911 | res->data = (void*) (long) b; |
---|
912 | gfan::deinitializeCddlibIfRequired(); |
---|
913 | return FALSE; |
---|
914 | } |
---|
915 | if ((u != NULL) && (u->Typ() == fanID)) |
---|
916 | { |
---|
917 | gfan::initializeCddlibIfRequired(); |
---|
918 | gfan::ZFan* zf = (gfan::ZFan*) u->Data(); |
---|
919 | bool b = isSimplicial(zf); |
---|
920 | res->rtyp = INT_CMD; |
---|
921 | res->data = (void*) (long) b; |
---|
922 | gfan::deinitializeCddlibIfRequired(); |
---|
923 | return FALSE; |
---|
924 | } |
---|
925 | WerrorS("isSimplicial: unexpected parameters"); |
---|
926 | return TRUE; |
---|
927 | } |
---|
928 | |
---|
929 | BOOLEAN containsPositiveVector(leftv res, leftv args) |
---|
930 | { |
---|
931 | leftv u = args; |
---|
932 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
933 | { |
---|
934 | gfan::initializeCddlibIfRequired(); |
---|
935 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
936 | int i = zc->containsPositiveVector(); |
---|
937 | res->rtyp = INT_CMD; |
---|
938 | res->data = (void*) (long) i; |
---|
939 | gfan::deinitializeCddlibIfRequired(); |
---|
940 | return FALSE; |
---|
941 | } |
---|
942 | WerrorS("containsPositiveVector: unexpected parameters"); |
---|
943 | return TRUE; |
---|
944 | } |
---|
945 | |
---|
946 | BOOLEAN linealitySpace(leftv res, leftv args) |
---|
947 | { |
---|
948 | leftv u = args; |
---|
949 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
950 | { |
---|
951 | gfan::initializeCddlibIfRequired(); |
---|
952 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
953 | gfan::ZCone* zd = new gfan::ZCone(zc->linealitySpace()); |
---|
954 | res->rtyp = coneID; |
---|
955 | res->data = (void*) zd; |
---|
956 | gfan::deinitializeCddlibIfRequired(); |
---|
957 | return FALSE; |
---|
958 | } |
---|
959 | WerrorS("linealitySpace: unexpected parameters"); |
---|
960 | return TRUE; |
---|
961 | } |
---|
962 | |
---|
963 | BOOLEAN dualCone(leftv res, leftv args) |
---|
964 | { |
---|
965 | leftv u = args; |
---|
966 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
967 | { |
---|
968 | gfan::initializeCddlibIfRequired(); |
---|
969 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
970 | gfan::ZCone* zd = new gfan::ZCone(zc->dualCone()); |
---|
971 | res->rtyp = coneID; |
---|
972 | res->data = (void*) zd; |
---|
973 | gfan::deinitializeCddlibIfRequired(); |
---|
974 | return FALSE; |
---|
975 | } |
---|
976 | WerrorS("dual: unexpected parameters"); |
---|
977 | return TRUE; |
---|
978 | } |
---|
979 | |
---|
980 | BOOLEAN negatedCone(leftv res, leftv args) |
---|
981 | { |
---|
982 | leftv u = args; |
---|
983 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
984 | { |
---|
985 | gfan::initializeCddlibIfRequired(); |
---|
986 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
987 | gfan::ZCone* zd = new gfan::ZCone(zc->negated()); |
---|
988 | res->rtyp = coneID; |
---|
989 | res->data = (void*) zd; |
---|
990 | gfan::deinitializeCddlibIfRequired(); |
---|
991 | return FALSE; |
---|
992 | } |
---|
993 | WerrorS("negatedCone: unexpected parameters"); |
---|
994 | return TRUE; |
---|
995 | } |
---|
996 | |
---|
997 | BOOLEAN semigroupGenerator(leftv res, leftv args) |
---|
998 | { |
---|
999 | leftv u = args; |
---|
1000 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1001 | { |
---|
1002 | gfan::initializeCddlibIfRequired(); |
---|
1003 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1004 | int d = zc->dimension(); |
---|
1005 | int dLS = zc->dimensionOfLinealitySpace(); |
---|
1006 | if (d == dLS + 1) |
---|
1007 | { |
---|
1008 | gfan::ZVector zv = zc->semiGroupGeneratorOfRay(); |
---|
1009 | res->rtyp = BIGINTMAT_CMD; |
---|
1010 | res->data = (void*) zVectorToBigintmat(zv); |
---|
1011 | gfan::deinitializeCddlibIfRequired(); |
---|
1012 | return FALSE; |
---|
1013 | } |
---|
1014 | gfan::deinitializeCddlibIfRequired(); |
---|
1015 | Werror("expected dim of cone one larger than dim of lin space\n" |
---|
1016 | "but got dimensions %d and %d", d, dLS); |
---|
1017 | } |
---|
1018 | WerrorS("semigroupGenerator: unexpected parameters"); |
---|
1019 | return TRUE; |
---|
1020 | } |
---|
1021 | |
---|
1022 | BOOLEAN relativeInteriorPoint(leftv res, leftv args) |
---|
1023 | { |
---|
1024 | leftv u = args; |
---|
1025 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1026 | { |
---|
1027 | gfan::initializeCddlibIfRequired(); |
---|
1028 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1029 | gfan::ZVector zv = zc->getRelativeInteriorPoint(); |
---|
1030 | res->rtyp = BIGINTMAT_CMD; |
---|
1031 | res->data = (void*) zVectorToBigintmat(zv); |
---|
1032 | gfan::deinitializeCddlibIfRequired(); |
---|
1033 | return FALSE; |
---|
1034 | } |
---|
1035 | WerrorS("relativeInteriorPoint: unexpected parameters"); |
---|
1036 | return TRUE; |
---|
1037 | } |
---|
1038 | |
---|
1039 | BOOLEAN uniquePoint(leftv res, leftv args) |
---|
1040 | { |
---|
1041 | leftv u = args; |
---|
1042 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1043 | { |
---|
1044 | gfan::initializeCddlibIfRequired(); |
---|
1045 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1046 | gfan::ZVector zv = zc->getUniquePoint(); |
---|
1047 | res->rtyp = BIGINTMAT_CMD; |
---|
1048 | res->data = (void*) zVectorToBigintmat(zv); |
---|
1049 | gfan::deinitializeCddlibIfRequired(); |
---|
1050 | return FALSE; |
---|
1051 | } |
---|
1052 | WerrorS("uniquePoint: unexpected parameters"); |
---|
1053 | return TRUE; |
---|
1054 | } |
---|
1055 | |
---|
1056 | gfan::ZVector randomPoint(const gfan::ZCone* zc) |
---|
1057 | { |
---|
1058 | gfan::ZVector rp = gfan::ZVector(zc->ambientDimension()); |
---|
1059 | |
---|
1060 | gfan::ZMatrix rays = zc->extremeRays(); |
---|
1061 | for (int i=0; i<rays.getHeight(); i++) |
---|
1062 | { |
---|
1063 | int n = siRand(); |
---|
1064 | rp = rp + n * rays[i].toVector(); |
---|
1065 | } |
---|
1066 | |
---|
1067 | gfan::ZMatrix lins = zc->generatorsOfLinealitySpace(); |
---|
1068 | for (int i=0; i<lins.getHeight(); i++) |
---|
1069 | { |
---|
1070 | int n = siRand(); |
---|
1071 | rp = rp + n * lins[i].toVector(); |
---|
1072 | } |
---|
1073 | |
---|
1074 | return rp; |
---|
1075 | } |
---|
1076 | |
---|
1077 | BOOLEAN randomPoint(leftv res, leftv args) |
---|
1078 | { |
---|
1079 | leftv u = args; |
---|
1080 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1081 | { |
---|
1082 | gfan::initializeCddlibIfRequired(); |
---|
1083 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1084 | gfan::ZVector zv = randomPoint(zc); |
---|
1085 | res->rtyp = BIGINTMAT_CMD; |
---|
1086 | res->data = (void*) zVectorToBigintmat(zv); |
---|
1087 | gfan::deinitializeCddlibIfRequired(); |
---|
1088 | return FALSE; |
---|
1089 | } |
---|
1090 | WerrorS("randomPoint: unexpected parameters"); |
---|
1091 | return TRUE; |
---|
1092 | } |
---|
1093 | |
---|
1094 | BOOLEAN setMultiplicity(leftv res, leftv args) |
---|
1095 | { |
---|
1096 | leftv u = args; |
---|
1097 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1098 | { |
---|
1099 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1100 | leftv v = u->next; |
---|
1101 | if ((v != NULL) && (v->Typ() == INT_CMD)) |
---|
1102 | { |
---|
1103 | gfan::initializeCddlibIfRequired(); |
---|
1104 | int val = (int)(long)v->Data(); |
---|
1105 | zc->setMultiplicity(gfan::Integer(val)); |
---|
1106 | res->rtyp = NONE; |
---|
1107 | res->data = NULL; |
---|
1108 | gfan::deinitializeCddlibIfRequired(); |
---|
1109 | return FALSE; |
---|
1110 | } |
---|
1111 | } |
---|
1112 | WerrorS("setMultiplicity: unexpected parameters"); |
---|
1113 | return TRUE; |
---|
1114 | } |
---|
1115 | |
---|
1116 | BOOLEAN setLinearForms(leftv res, leftv args) |
---|
1117 | { |
---|
1118 | leftv u = args; |
---|
1119 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1120 | { |
---|
1121 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1122 | leftv v = u->next; |
---|
1123 | if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD))) |
---|
1124 | { |
---|
1125 | gfan::initializeCddlibIfRequired(); |
---|
1126 | bigintmat* mat=NULL; |
---|
1127 | if (v->Typ() == INTVEC_CMD) |
---|
1128 | { |
---|
1129 | intvec* mat0 = (intvec*) v->Data(); |
---|
1130 | mat = iv2bim(mat0,coeffs_BIGINT)->transpose(); |
---|
1131 | } |
---|
1132 | else |
---|
1133 | mat = (bigintmat*) v->Data(); |
---|
1134 | gfan::ZMatrix* zm = bigintmatToZMatrix(mat); |
---|
1135 | zc->setLinearForms(*zm); |
---|
1136 | res->rtyp = NONE; |
---|
1137 | res->data = NULL; |
---|
1138 | |
---|
1139 | delete zm; |
---|
1140 | if (v->Typ() == INTVEC_CMD) |
---|
1141 | delete mat; |
---|
1142 | gfan::deinitializeCddlibIfRequired(); |
---|
1143 | return FALSE; |
---|
1144 | } |
---|
1145 | } |
---|
1146 | WerrorS("setLinearForms: unexpected parameters"); |
---|
1147 | return TRUE; |
---|
1148 | } |
---|
1149 | |
---|
1150 | gfan::ZMatrix liftUp(const gfan::ZMatrix &zm) |
---|
1151 | { |
---|
1152 | int r=zm.getHeight(); |
---|
1153 | int c=zm.getWidth(); |
---|
1154 | gfan::ZMatrix zn(r+1,c+1); |
---|
1155 | zn[1][1]=1; |
---|
1156 | for (int i=0; i<r; i++) |
---|
1157 | for (int j=0; j<c; j++) |
---|
1158 | zn[i+1][j+1]=zm[i][j]; |
---|
1159 | return zn; |
---|
1160 | } |
---|
1161 | |
---|
1162 | gfan::ZCone liftUp(const gfan::ZCone &zc) |
---|
1163 | { |
---|
1164 | gfan::ZMatrix ineq=zc.getInequalities(); |
---|
1165 | gfan::ZMatrix eq=zc.getEquations(); |
---|
1166 | gfan::ZCone zd(liftUp(ineq),liftUp(eq)); |
---|
1167 | return zd; |
---|
1168 | } |
---|
1169 | |
---|
1170 | BOOLEAN coneToPolytope(leftv res, leftv args) |
---|
1171 | { |
---|
1172 | leftv u = args; |
---|
1173 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1174 | { |
---|
1175 | gfan::initializeCddlibIfRequired(); |
---|
1176 | gfan::ZCone* zc = (gfan::ZCone*) u->Data(); |
---|
1177 | gfan::ZMatrix ineq=zc->getInequalities(); |
---|
1178 | gfan::ZMatrix eq=zc->getEquations(); |
---|
1179 | gfan::ZCone* zd = new gfan::ZCone(liftUp(ineq),liftUp(eq)); |
---|
1180 | res->rtyp = polytopeID; |
---|
1181 | res->data = (void*) zd; |
---|
1182 | gfan::deinitializeCddlibIfRequired(); |
---|
1183 | return FALSE; |
---|
1184 | } |
---|
1185 | WerrorS("makePolytope: unexpected parameters"); |
---|
1186 | return TRUE; |
---|
1187 | } |
---|
1188 | |
---|
1189 | BOOLEAN intersectCones(leftv res, leftv args) |
---|
1190 | { |
---|
1191 | leftv u = args; |
---|
1192 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1193 | { |
---|
1194 | leftv v = u->next; |
---|
1195 | if ((v != NULL) && (v->Typ() == coneID)) |
---|
1196 | { |
---|
1197 | gfan::initializeCddlibIfRequired(); |
---|
1198 | gfan::ZCone* zc1 = (gfan::ZCone*)u->Data(); |
---|
1199 | gfan::ZCone* zc2 = (gfan::ZCone*)v->Data(); |
---|
1200 | int d1 = zc1->ambientDimension(); |
---|
1201 | int d2 = zc2->ambientDimension(); |
---|
1202 | if (d1 != d2) |
---|
1203 | { |
---|
1204 | Werror("expected ambient dims of both cones to coincide\n" |
---|
1205 | "but got %d and %d", d1, d2); |
---|
1206 | gfan::deinitializeCddlibIfRequired(); |
---|
1207 | return TRUE; |
---|
1208 | } |
---|
1209 | gfan::ZCone zc3 = gfan::intersection(*zc1, *zc2); |
---|
1210 | zc3.canonicalize(); |
---|
1211 | res->rtyp = coneID; |
---|
1212 | res->data = (void *)new gfan::ZCone(zc3); |
---|
1213 | gfan::deinitializeCddlibIfRequired(); |
---|
1214 | return FALSE; |
---|
1215 | } |
---|
1216 | if ((v != NULL) && (v->Typ() == polytopeID)) |
---|
1217 | { |
---|
1218 | gfan::initializeCddlibIfRequired(); |
---|
1219 | gfan::ZCone* zc11 = (gfan::ZCone*)u->Data(); |
---|
1220 | gfan::ZCone zc1 = liftUp(*zc11); |
---|
1221 | gfan::ZCone* zc2 = (gfan::ZCone*)v->Data(); |
---|
1222 | int d1 = zc1.ambientDimension(); |
---|
1223 | int d2 = zc2->ambientDimension(); |
---|
1224 | if (d1 != d2) |
---|
1225 | { |
---|
1226 | Werror("expected ambient dims of both cones to coincide\n" |
---|
1227 | "but got %d and %d", d1, d2); |
---|
1228 | gfan::deinitializeCddlibIfRequired(); |
---|
1229 | return TRUE; |
---|
1230 | } |
---|
1231 | gfan::ZCone zc3 = gfan::intersection(zc1, *zc2); |
---|
1232 | zc3.canonicalize(); |
---|
1233 | res->rtyp = polytopeID; |
---|
1234 | res->data = (void *)new gfan::ZCone(zc3); |
---|
1235 | gfan::deinitializeCddlibIfRequired(); |
---|
1236 | return FALSE; |
---|
1237 | } |
---|
1238 | } |
---|
1239 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1240 | { |
---|
1241 | leftv v = u->next; |
---|
1242 | if ((v != NULL) && (v->Typ() == coneID)) |
---|
1243 | { |
---|
1244 | gfan::initializeCddlibIfRequired(); |
---|
1245 | gfan::ZCone* zc1 = (gfan::ZCone*)u->Data(); |
---|
1246 | gfan::ZCone* zc22 = (gfan::ZCone*)v->Data(); |
---|
1247 | gfan::ZCone zc2 = liftUp(*zc22); |
---|
1248 | int d1 = zc1->ambientDimension(); |
---|
1249 | int d2 = zc2.ambientDimension(); |
---|
1250 | if (d1 != d2) |
---|
1251 | { |
---|
1252 | Werror("expected ambient dims of both cones to coincide\n" |
---|
1253 | "but got %d and %d", d1, d2); |
---|
1254 | gfan::deinitializeCddlibIfRequired(); |
---|
1255 | return TRUE; |
---|
1256 | } |
---|
1257 | gfan::ZCone zc3 = gfan::intersection(*zc1, zc2); |
---|
1258 | zc3.canonicalize(); |
---|
1259 | res->rtyp = polytopeID; |
---|
1260 | res->data = (void *)new gfan::ZCone(zc3); |
---|
1261 | gfan::deinitializeCddlibIfRequired(); |
---|
1262 | return FALSE; |
---|
1263 | } |
---|
1264 | if ((v != NULL) && (v->Typ() == polytopeID)) |
---|
1265 | { |
---|
1266 | gfan::initializeCddlibIfRequired(); |
---|
1267 | gfan::ZCone* zc1 = (gfan::ZCone*)u->Data(); |
---|
1268 | gfan::ZCone* zc2 = (gfan::ZCone*)v->Data(); |
---|
1269 | int d1 = zc1->ambientDimension(); |
---|
1270 | int d2 = zc2->ambientDimension(); |
---|
1271 | if (d1 != d2) |
---|
1272 | { |
---|
1273 | Werror("expected ambient dims of both cones to coincide\n" |
---|
1274 | "but got %d and %d", d1, d2); |
---|
1275 | gfan::deinitializeCddlibIfRequired(); |
---|
1276 | return TRUE; |
---|
1277 | } |
---|
1278 | gfan::ZCone zc3 = gfan::intersection(*zc1, *zc2); |
---|
1279 | zc3.canonicalize(); |
---|
1280 | res->rtyp = polytopeID; |
---|
1281 | res->data = (void *)new gfan::ZCone(zc3); |
---|
1282 | gfan::deinitializeCddlibIfRequired(); |
---|
1283 | return FALSE; |
---|
1284 | } |
---|
1285 | } |
---|
1286 | WerrorS("convexIntersection: unexpected parameters"); |
---|
1287 | return TRUE; |
---|
1288 | } |
---|
1289 | |
---|
1290 | BOOLEAN convexHull(leftv res, leftv args) |
---|
1291 | { |
---|
1292 | leftv u = args; |
---|
1293 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1294 | { |
---|
1295 | leftv v = u->next; |
---|
1296 | if ((v != NULL) && (v->Typ() == coneID)) |
---|
1297 | { |
---|
1298 | gfan::initializeCddlibIfRequired(); |
---|
1299 | gfan::ZCone* zc1 = (gfan::ZCone*)u->Data(); |
---|
1300 | gfan::ZCone* zc2 = (gfan::ZCone*)v->Data(); |
---|
1301 | int d1 = zc1->ambientDimension(); |
---|
1302 | int d2 = zc2->ambientDimension(); |
---|
1303 | if (d1 != d2) |
---|
1304 | { |
---|
1305 | Werror("expected ambient dims of both cones to coincide\n" |
---|
1306 | "but got %d and %d", d1, d2); |
---|
1307 | gfan::deinitializeCddlibIfRequired(); |
---|
1308 | return TRUE; |
---|
1309 | } |
---|
1310 | gfan::ZMatrix zm1 = zc1->extremeRays(); |
---|
1311 | gfan::ZMatrix zm2 = zc2->extremeRays(); |
---|
1312 | gfan::ZMatrix zn1 = zc1->generatorsOfLinealitySpace(); |
---|
1313 | gfan::ZMatrix zn2 = zc2->generatorsOfLinealitySpace(); |
---|
1314 | gfan::ZMatrix zm = combineOnTop(zm1,zm2); |
---|
1315 | gfan::ZMatrix zn = combineOnTop(zn1,zn2); |
---|
1316 | gfan::ZCone* zc = new gfan::ZCone(); |
---|
1317 | *zc = gfan::ZCone::givenByRays(zm, zn); |
---|
1318 | res->rtyp = coneID; |
---|
1319 | res->data = (void*) zc; |
---|
1320 | gfan::deinitializeCddlibIfRequired(); |
---|
1321 | return FALSE; |
---|
1322 | } |
---|
1323 | if ((v != NULL) && (v->Typ() == polytopeID)) |
---|
1324 | { |
---|
1325 | gfan::initializeCddlibIfRequired(); |
---|
1326 | gfan::ZCone* zc11 = (gfan::ZCone*)u->Data(); |
---|
1327 | gfan::ZCone zc1 = liftUp(*zc11); |
---|
1328 | gfan::ZCone* zc2 = (gfan::ZCone*)v->Data(); |
---|
1329 | int d1 = zc1.ambientDimension()-1; |
---|
1330 | int d2 = zc2->ambientDimension()-1; |
---|
1331 | if (d1 != d2) |
---|
1332 | { |
---|
1333 | Werror("expected ambient dims of both cones to coincide\n" |
---|
1334 | "but got %d and %d", d1, d2); |
---|
1335 | gfan::deinitializeCddlibIfRequired(); |
---|
1336 | return TRUE; |
---|
1337 | } |
---|
1338 | gfan::ZMatrix zm1 = zc1.extremeRays(); |
---|
1339 | gfan::ZMatrix zm2 = zc2->extremeRays(); |
---|
1340 | gfan::ZMatrix zn = zc1.generatorsOfLinealitySpace(); |
---|
1341 | gfan::ZMatrix zm = combineOnTop(zm1,zm2); |
---|
1342 | gfan::ZCone* zc = new gfan::ZCone(); |
---|
1343 | *zc = gfan::ZCone::givenByRays(zm, zn); |
---|
1344 | res->rtyp = polytopeID; |
---|
1345 | res->data = (void*) zc; |
---|
1346 | gfan::deinitializeCddlibIfRequired(); |
---|
1347 | return FALSE; |
---|
1348 | } |
---|
1349 | } |
---|
1350 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1351 | { |
---|
1352 | leftv v = u->next; |
---|
1353 | if ((v != NULL) && (v->Typ() == coneID)) |
---|
1354 | { |
---|
1355 | gfan::initializeCddlibIfRequired(); |
---|
1356 | gfan::ZCone* zc1 = (gfan::ZCone*)u->Data(); |
---|
1357 | gfan::ZCone* zc22 = (gfan::ZCone*)v->Data(); |
---|
1358 | gfan::ZCone zc2 = liftUp(*zc22); |
---|
1359 | int d1 = zc1->ambientDimension()-1; |
---|
1360 | int d2 = zc2.ambientDimension()-1; |
---|
1361 | if (d1 != d2) |
---|
1362 | { |
---|
1363 | Werror("expected ambient dims of both cones to coincide\n" |
---|
1364 | "but got %d and %d", d1, d2); |
---|
1365 | gfan::deinitializeCddlibIfRequired(); |
---|
1366 | return TRUE; |
---|
1367 | } |
---|
1368 | gfan::ZMatrix zm1 = zc1->extremeRays(); |
---|
1369 | gfan::ZMatrix zm2 = zc2.extremeRays(); |
---|
1370 | gfan::ZMatrix zn = zc2.generatorsOfLinealitySpace(); |
---|
1371 | gfan::ZMatrix zm = combineOnTop(zm1,zm2); |
---|
1372 | gfan::ZCone* zc = new gfan::ZCone(); |
---|
1373 | *zc = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth())); |
---|
1374 | res->rtyp = polytopeID; |
---|
1375 | res->data = (void*) zc; |
---|
1376 | gfan::deinitializeCddlibIfRequired(); |
---|
1377 | return FALSE; |
---|
1378 | } |
---|
1379 | if ((v != NULL) && (v->Typ() == polytopeID)) |
---|
1380 | { |
---|
1381 | gfan::initializeCddlibIfRequired(); |
---|
1382 | gfan::ZCone* zc1 = (gfan::ZCone*)u->Data(); |
---|
1383 | gfan::ZCone* zc2 = (gfan::ZCone*)v->Data(); |
---|
1384 | int d1 = zc1->ambientDimension()-1; |
---|
1385 | int d2 = zc2->ambientDimension()-1; |
---|
1386 | if (d1 != d2) |
---|
1387 | { |
---|
1388 | Werror("expected ambient dims of both cones to coincide\n" |
---|
1389 | "but got %d and %d", d1, d2); |
---|
1390 | gfan::deinitializeCddlibIfRequired(); |
---|
1391 | return TRUE; |
---|
1392 | } |
---|
1393 | gfan::ZMatrix zm1 = zc1->extremeRays(); |
---|
1394 | gfan::ZMatrix zm2 = zc2->extremeRays(); |
---|
1395 | gfan::ZMatrix zm = combineOnTop(zm1,zm2); |
---|
1396 | gfan::ZCone* zc = new gfan::ZCone(); |
---|
1397 | *zc = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth())); |
---|
1398 | res->rtyp = polytopeID; |
---|
1399 | res->data = (void*) zc; |
---|
1400 | gfan::deinitializeCddlibIfRequired(); |
---|
1401 | return FALSE; |
---|
1402 | } |
---|
1403 | } |
---|
1404 | WerrorS("convexHull: unexpected parameters"); |
---|
1405 | return TRUE; |
---|
1406 | } |
---|
1407 | |
---|
1408 | BOOLEAN coneLink(leftv res, leftv args) |
---|
1409 | { |
---|
1410 | leftv u = args; |
---|
1411 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1412 | { |
---|
1413 | leftv v = u->next; |
---|
1414 | if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD))) |
---|
1415 | { |
---|
1416 | gfan::initializeCddlibIfRequired(); |
---|
1417 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1418 | bigintmat* iv = NULL; |
---|
1419 | if (v->Typ() == INTVEC_CMD) |
---|
1420 | { |
---|
1421 | intvec* iv0 = (intvec*) v->Data(); |
---|
1422 | iv = iv2bim(iv0,coeffs_BIGINT)->transpose(); |
---|
1423 | } |
---|
1424 | else |
---|
1425 | iv = (bigintmat*)v->Data(); |
---|
1426 | gfan::ZVector* zv = bigintmatToZVector(iv); |
---|
1427 | int d1 = zc->ambientDimension(); |
---|
1428 | int d2 = zv->size(); |
---|
1429 | if (d1 != d2) |
---|
1430 | { |
---|
1431 | Werror("expected ambient dim of cone and size of vector\n" |
---|
1432 | " to be equal but got %d and %d", d1, d2); |
---|
1433 | gfan::deinitializeCddlibIfRequired(); |
---|
1434 | return TRUE; |
---|
1435 | } |
---|
1436 | if(!zc->contains(*zv)) |
---|
1437 | { |
---|
1438 | WerrorS("the provided intvec does not lie in the cone"); |
---|
1439 | gfan::deinitializeCddlibIfRequired(); |
---|
1440 | return TRUE; |
---|
1441 | } |
---|
1442 | gfan::ZCone* zd = new gfan::ZCone(zc->link(*zv)); |
---|
1443 | res->rtyp = coneID; |
---|
1444 | res->data = (void *) zd; |
---|
1445 | |
---|
1446 | delete zv; |
---|
1447 | if (v->Typ() == INTMAT_CMD) |
---|
1448 | delete iv; |
---|
1449 | gfan::deinitializeCddlibIfRequired(); |
---|
1450 | return FALSE; |
---|
1451 | } |
---|
1452 | } |
---|
1453 | WerrorS("coneLink: unexpected parameters"); |
---|
1454 | return TRUE; |
---|
1455 | } |
---|
1456 | |
---|
1457 | BOOLEAN containsInSupport(leftv res, leftv args) |
---|
1458 | { |
---|
1459 | leftv u=args; |
---|
1460 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1461 | { |
---|
1462 | leftv v=u->next; |
---|
1463 | if ((v != NULL) && (v->Typ() == coneID)) |
---|
1464 | { |
---|
1465 | gfan::initializeCddlibIfRequired(); |
---|
1466 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1467 | gfan::ZCone* zd = (gfan::ZCone*)v->Data(); |
---|
1468 | int d1 = zc->ambientDimension(); |
---|
1469 | int d2 = zd->ambientDimension(); |
---|
1470 | if (d1 != d2) |
---|
1471 | { |
---|
1472 | Werror("expected cones with same ambient dimensions\n but got" |
---|
1473 | " dimensions %d and %d", d1, d2); |
---|
1474 | gfan::deinitializeCddlibIfRequired(); |
---|
1475 | return TRUE; |
---|
1476 | } |
---|
1477 | bool b = (zc->contains(*zd) ? 1 : 0); |
---|
1478 | res->rtyp = INT_CMD; |
---|
1479 | res->data = (void*) (long) b; |
---|
1480 | gfan::deinitializeCddlibIfRequired(); |
---|
1481 | return FALSE; |
---|
1482 | } |
---|
1483 | if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD))) |
---|
1484 | { |
---|
1485 | gfan::initializeCddlibIfRequired(); |
---|
1486 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1487 | bigintmat* iv = NULL; |
---|
1488 | if (v->Typ() == INTVEC_CMD) |
---|
1489 | { |
---|
1490 | intvec* iv0 = (intvec*) v->Data(); |
---|
1491 | iv = iv2bim(iv0,coeffs_BIGINT)->transpose(); |
---|
1492 | } |
---|
1493 | else |
---|
1494 | iv = (bigintmat*)v->Data(); |
---|
1495 | |
---|
1496 | gfan::ZVector* zv = bigintmatToZVector(iv); |
---|
1497 | int d1 = zc->ambientDimension(); |
---|
1498 | int d2 = zv->size(); |
---|
1499 | if (d1 != d2) |
---|
1500 | { |
---|
1501 | Werror("expected cones with same ambient dimensions\n but got" |
---|
1502 | " dimensions %d and %d", d1, d2); |
---|
1503 | gfan::deinitializeCddlibIfRequired(); |
---|
1504 | return TRUE; |
---|
1505 | } |
---|
1506 | int b = zc->contains(*zv); |
---|
1507 | res->rtyp = INT_CMD; |
---|
1508 | res->data = (void*) (long) b; |
---|
1509 | |
---|
1510 | delete zv; |
---|
1511 | if (v->Typ() == INTMAT_CMD) |
---|
1512 | delete iv; |
---|
1513 | gfan::deinitializeCddlibIfRequired(); |
---|
1514 | return FALSE; |
---|
1515 | } |
---|
1516 | } |
---|
1517 | WerrorS("containsInSupport: unexpected parameters"); |
---|
1518 | return TRUE; |
---|
1519 | } |
---|
1520 | |
---|
1521 | BOOLEAN containsRelatively(leftv res, leftv args) |
---|
1522 | { |
---|
1523 | leftv u = args; |
---|
1524 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1525 | { |
---|
1526 | leftv v = u->next; |
---|
1527 | if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD))) |
---|
1528 | { |
---|
1529 | gfan::initializeCddlibIfRequired(); |
---|
1530 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1531 | bigintmat* iv = NULL; |
---|
1532 | if (v->Typ() == INTVEC_CMD) |
---|
1533 | { |
---|
1534 | intvec* iv0 = (intvec*) v->Data(); |
---|
1535 | iv = iv2bim(iv0,coeffs_BIGINT)->transpose(); |
---|
1536 | } |
---|
1537 | else |
---|
1538 | iv = (bigintmat*)v->Data(); |
---|
1539 | gfan::ZVector* zv = bigintmatToZVector(iv); |
---|
1540 | int d1 = zc->ambientDimension(); |
---|
1541 | int d2 = zv->size(); |
---|
1542 | if (d1 == d2) |
---|
1543 | { |
---|
1544 | bool b = (zc->containsRelatively(*zv) ? 1 : 0); |
---|
1545 | res->rtyp = INT_CMD; |
---|
1546 | res->data = (void *) b; |
---|
1547 | delete zv; |
---|
1548 | if (v->Typ() == INTMAT_CMD) |
---|
1549 | delete iv; |
---|
1550 | gfan::deinitializeCddlibIfRequired(); |
---|
1551 | return FALSE; |
---|
1552 | } |
---|
1553 | delete zv; |
---|
1554 | if (v->Typ() == INTMAT_CMD) |
---|
1555 | delete iv; |
---|
1556 | gfan::deinitializeCddlibIfRequired(); |
---|
1557 | Werror("expected ambient dim of cone and size of vector\n" |
---|
1558 | "to be equal but got %d and %d", d1, d2); |
---|
1559 | } |
---|
1560 | } |
---|
1561 | WerrorS("containsRelatively: unexpected parameters"); |
---|
1562 | return TRUE; |
---|
1563 | } |
---|
1564 | |
---|
1565 | BOOLEAN hasFace(leftv res, leftv args) |
---|
1566 | { |
---|
1567 | leftv u=args; |
---|
1568 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1569 | { |
---|
1570 | leftv v=u->next; |
---|
1571 | if ((v != NULL) && (v->Typ() == coneID)) |
---|
1572 | { |
---|
1573 | gfan::initializeCddlibIfRequired(); |
---|
1574 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1575 | gfan::ZCone* zd = (gfan::ZCone*)v->Data(); |
---|
1576 | bool b = zc->hasFace(*zd); |
---|
1577 | res->rtyp = INT_CMD; |
---|
1578 | res->data = (void*) (long) b; |
---|
1579 | gfan::deinitializeCddlibIfRequired(); |
---|
1580 | return FALSE; |
---|
1581 | } |
---|
1582 | } |
---|
1583 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1584 | { |
---|
1585 | leftv v=u->next; |
---|
1586 | if ((v != NULL) && (v->Typ() == polytopeID)) |
---|
1587 | { |
---|
1588 | gfan::initializeCddlibIfRequired(); |
---|
1589 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1590 | gfan::ZCone* zd = (gfan::ZCone*)v->Data(); |
---|
1591 | bool b = zc->hasFace(*zd); |
---|
1592 | res->rtyp = INT_CMD; |
---|
1593 | res->data = (void*) (long) b; |
---|
1594 | gfan::deinitializeCddlibIfRequired(); |
---|
1595 | return FALSE; |
---|
1596 | } |
---|
1597 | } |
---|
1598 | WerrorS("containsAsFace: unexpected parameters"); |
---|
1599 | return TRUE; |
---|
1600 | } |
---|
1601 | |
---|
1602 | BOOLEAN canonicalizeCone(leftv res, leftv args) |
---|
1603 | { |
---|
1604 | leftv u=args; |
---|
1605 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1606 | { |
---|
1607 | gfan::initializeCddlibIfRequired(); |
---|
1608 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1609 | gfan::ZCone* zd = new gfan::ZCone(*zc); |
---|
1610 | zd->canonicalize(); |
---|
1611 | res->rtyp = coneID; |
---|
1612 | res->data = (void*) zd; |
---|
1613 | gfan::deinitializeCddlibIfRequired(); |
---|
1614 | return FALSE; |
---|
1615 | } |
---|
1616 | WerrorS("canonicalizeCone: unexpected parameters"); |
---|
1617 | return TRUE; |
---|
1618 | } |
---|
1619 | |
---|
1620 | BOOLEAN containsCone(leftv res, leftv args) |
---|
1621 | { |
---|
1622 | leftv u=args; |
---|
1623 | if ((u != NULL) && (u->Typ() == LIST_CMD)) |
---|
1624 | { |
---|
1625 | leftv v=u->next; |
---|
1626 | if ((v != NULL) && (v->Typ() == coneID)) |
---|
1627 | { |
---|
1628 | gfan::initializeCddlibIfRequired(); |
---|
1629 | lists l = (lists) u->Data(); |
---|
1630 | gfan::ZCone* zc = (gfan::ZCone*) v->Data(); |
---|
1631 | zc->canonicalize(); |
---|
1632 | int b = 0; |
---|
1633 | for (int i=0; i<=lSize(l); i++) |
---|
1634 | { |
---|
1635 | if (l->m[i].Typ() != coneID) |
---|
1636 | { |
---|
1637 | WerrorS("containsCone: entries of wrong type in list"); |
---|
1638 | gfan::deinitializeCddlibIfRequired(); |
---|
1639 | return TRUE; |
---|
1640 | } |
---|
1641 | gfan::ZCone* ll = (gfan::ZCone*) l->m[i].Data(); |
---|
1642 | ll->canonicalize(); |
---|
1643 | if (!((*ll) != (*zc))) |
---|
1644 | { |
---|
1645 | b = 1; |
---|
1646 | break; |
---|
1647 | } |
---|
1648 | } |
---|
1649 | res->rtyp = INT_CMD; |
---|
1650 | res->data = (char*) (long) b; |
---|
1651 | gfan::deinitializeCddlibIfRequired(); |
---|
1652 | return FALSE; |
---|
1653 | } |
---|
1654 | } |
---|
1655 | WerrorS("containsCone: unexpected parameters"); |
---|
1656 | return TRUE; |
---|
1657 | } |
---|
1658 | |
---|
1659 | BOOLEAN faceContaining(leftv res, leftv args) |
---|
1660 | { |
---|
1661 | leftv u = args; |
---|
1662 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1663 | { |
---|
1664 | leftv v = u->next; |
---|
1665 | if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD))) |
---|
1666 | { |
---|
1667 | gfan::initializeCddlibIfRequired(); |
---|
1668 | gfan::ZCone* zc = (gfan::ZCone*) u->Data(); |
---|
1669 | |
---|
1670 | bigintmat* point1; |
---|
1671 | if (v->Typ() == INTVEC_CMD) |
---|
1672 | { |
---|
1673 | intvec* point0 = (intvec*) v->Data(); |
---|
1674 | point1 = iv2bim(point0,coeffs_BIGINT)->transpose(); |
---|
1675 | } |
---|
1676 | else |
---|
1677 | point1 = (bigintmat*) v->Data(); |
---|
1678 | gfan::ZVector* point = bigintmatToZVector(*point1); |
---|
1679 | |
---|
1680 | if (!zc->contains(*point)) |
---|
1681 | { |
---|
1682 | WerrorS("faceContaining: point not in cone"); |
---|
1683 | return TRUE; |
---|
1684 | } |
---|
1685 | res->rtyp = coneID; |
---|
1686 | res->data = (void*) new gfan::ZCone(zc->faceContaining(*point)); |
---|
1687 | |
---|
1688 | delete point; |
---|
1689 | if (v->Typ() == INTVEC_CMD) |
---|
1690 | delete point1; |
---|
1691 | gfan::deinitializeCddlibIfRequired(); |
---|
1692 | return FALSE; |
---|
1693 | } |
---|
1694 | } |
---|
1695 | WerrorS("faceContaining: unexpected parameters"); |
---|
1696 | return TRUE; |
---|
1697 | } |
---|
1698 | |
---|
1699 | |
---|
1700 | /*** |
---|
1701 | * Computes a relative interior point for each facet of zc |
---|
1702 | **/ |
---|
1703 | gfan::ZMatrix interiorPointsOfFacets(const gfan::ZCone &zc, const std::set<gfan::ZVector> &exceptThese) |
---|
1704 | { |
---|
1705 | gfan::ZMatrix inequalities = zc.getFacets(); |
---|
1706 | gfan::ZMatrix equations = zc.getImpliedEquations(); |
---|
1707 | int r = inequalities.getHeight(); |
---|
1708 | int c = inequalities.getWidth(); |
---|
1709 | |
---|
1710 | /* our cone has r facets, if r==0 return empty matrices */ |
---|
1711 | gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c); |
---|
1712 | if (r==0) return relativeInteriorPoints; |
---|
1713 | |
---|
1714 | /* next we iterate over each of the r facets, |
---|
1715 | * build the respective cone and add it to the list |
---|
1716 | * this is the i=0 case */ |
---|
1717 | gfan::ZMatrix newInequalities = inequalities.submatrix(1,0,r,c); |
---|
1718 | gfan::ZMatrix newEquations = equations; |
---|
1719 | newEquations.appendRow(inequalities[0]); |
---|
1720 | gfan::ZCone facet = gfan::ZCone(newInequalities,newEquations); |
---|
1721 | facet.canonicalize(); |
---|
1722 | gfan::ZVector interiorPoint = facet.getRelativeInteriorPoint(); |
---|
1723 | if (exceptThese.count(interiorPoint)==0) |
---|
1724 | relativeInteriorPoints.appendRow(interiorPoint); |
---|
1725 | |
---|
1726 | /* these are the cases i=1,...,r-2 */ |
---|
1727 | for (int i=1; i<r-1; i++) |
---|
1728 | { |
---|
1729 | newInequalities = inequalities.submatrix(0,0,i,c); |
---|
1730 | newInequalities.append(inequalities.submatrix(i+1,0,r,c)); |
---|
1731 | newEquations = equations; |
---|
1732 | newEquations.appendRow(inequalities[i]); |
---|
1733 | facet = gfan::ZCone(newInequalities,newEquations); |
---|
1734 | facet.canonicalize(); |
---|
1735 | interiorPoint = facet.getRelativeInteriorPoint(); |
---|
1736 | if (exceptThese.count(interiorPoint)==0) |
---|
1737 | relativeInteriorPoints.appendRow(interiorPoint); |
---|
1738 | } |
---|
1739 | |
---|
1740 | /* this is the i=r-1 case */ |
---|
1741 | newInequalities = inequalities.submatrix(0,0,r-1,c); |
---|
1742 | newEquations = equations; |
---|
1743 | newEquations.appendRow(inequalities[r-1]); |
---|
1744 | facet = gfan::ZCone(newInequalities,newEquations); |
---|
1745 | facet.canonicalize(); |
---|
1746 | interiorPoint = facet.getRelativeInteriorPoint(); |
---|
1747 | if (exceptThese.count(interiorPoint)==0) |
---|
1748 | relativeInteriorPoints.appendRow(interiorPoint); |
---|
1749 | |
---|
1750 | return relativeInteriorPoints; |
---|
1751 | } |
---|
1752 | |
---|
1753 | |
---|
1754 | /*** |
---|
1755 | * Computes a relative interior point and an outer normal vector for each facet of zc |
---|
1756 | **/ |
---|
1757 | std::pair<gfan::ZMatrix,gfan::ZMatrix> interiorPointsAndNormalsOfFacets(const gfan::ZCone zc, const std::set<gfan::ZVector> &exceptThesePoints, const bool onlyLowerHalfSpace) |
---|
1758 | { |
---|
1759 | gfan::ZMatrix inequalities = zc.getFacets(); |
---|
1760 | gfan::ZMatrix equations = zc.getImpliedEquations(); |
---|
1761 | int r = inequalities.getHeight(); |
---|
1762 | int c = inequalities.getWidth(); |
---|
1763 | |
---|
1764 | /* our cone has r facets, if r==0 return empty matrices */ |
---|
1765 | gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c); |
---|
1766 | gfan::ZMatrix outerFacetNormals = gfan::ZMatrix(0,c); |
---|
1767 | if (r==0) |
---|
1768 | return std::make_pair(relativeInteriorPoints,outerFacetNormals); |
---|
1769 | |
---|
1770 | /* next we iterate over each of the r facets, |
---|
1771 | * build the respective cone and add it to the list |
---|
1772 | * this is the i=0 case */ |
---|
1773 | gfan::ZMatrix newInequalities = inequalities.submatrix(1,0,r,c); |
---|
1774 | gfan::ZMatrix newEquations = equations; |
---|
1775 | newEquations.appendRow(inequalities[0]); |
---|
1776 | gfan::ZCone facet = gfan::ZCone(newInequalities,newEquations); |
---|
1777 | gfan::ZVector interiorPoint = facet.getRelativeInteriorPoint(); |
---|
1778 | if (onlyLowerHalfSpace==false || interiorPoint[0].sign()<0) |
---|
1779 | { |
---|
1780 | if (exceptThesePoints.count(interiorPoint)==0) |
---|
1781 | { |
---|
1782 | relativeInteriorPoints.appendRow(interiorPoint); |
---|
1783 | outerFacetNormals.appendRow(-inequalities[0].toVector()); |
---|
1784 | } |
---|
1785 | } |
---|
1786 | |
---|
1787 | /* these are the cases i=1,...,r-2 */ |
---|
1788 | for (int i=1; i<r-1; i++) |
---|
1789 | { |
---|
1790 | newInequalities = inequalities.submatrix(0,0,i,c); |
---|
1791 | newInequalities.append(inequalities.submatrix(i+1,0,r,c)); |
---|
1792 | newEquations = equations; |
---|
1793 | newEquations.appendRow(inequalities[i]); |
---|
1794 | facet = gfan::ZCone(newInequalities,newEquations); |
---|
1795 | interiorPoint = facet.getRelativeInteriorPoint(); |
---|
1796 | if (onlyLowerHalfSpace==false || interiorPoint[0].sign()<0) |
---|
1797 | { |
---|
1798 | if (exceptThesePoints.count(interiorPoint)==0) |
---|
1799 | { |
---|
1800 | relativeInteriorPoints.appendRow(interiorPoint); |
---|
1801 | outerFacetNormals.appendRow(-inequalities[i].toVector()); |
---|
1802 | } |
---|
1803 | } |
---|
1804 | } |
---|
1805 | |
---|
1806 | /* this is the i=r-1 case */ |
---|
1807 | newInequalities = inequalities.submatrix(0,0,r-1,c); |
---|
1808 | newEquations = equations; |
---|
1809 | newEquations.appendRow(inequalities[r-1]); |
---|
1810 | facet = gfan::ZCone(newInequalities,newEquations); |
---|
1811 | interiorPoint = facet.getRelativeInteriorPoint(); |
---|
1812 | if (onlyLowerHalfSpace==false || interiorPoint[0].sign()<0) |
---|
1813 | { |
---|
1814 | if (exceptThesePoints.count(interiorPoint)==0) |
---|
1815 | { |
---|
1816 | relativeInteriorPoints.appendRow(interiorPoint); |
---|
1817 | outerFacetNormals.appendRow(-inequalities[r-1].toVector()); |
---|
1818 | } |
---|
1819 | } |
---|
1820 | |
---|
1821 | return std::make_pair(relativeInteriorPoints,outerFacetNormals); |
---|
1822 | } |
---|
1823 | |
---|
1824 | |
---|
1825 | static void gfanIntegerWriteFd(gfan::Integer n, ssiInfo* dd) |
---|
1826 | { |
---|
1827 | mpz_t tmp; |
---|
1828 | mpz_init(tmp); |
---|
1829 | n.setGmp(tmp); |
---|
1830 | mpz_out_str (dd->f_write,SSI_BASE, tmp); |
---|
1831 | mpz_clear(tmp); |
---|
1832 | fputc(' ',dd->f_write); |
---|
1833 | } |
---|
1834 | |
---|
1835 | static void gfanZMatrixWriteFd(gfan::ZMatrix M, ssiInfo* dd) |
---|
1836 | { |
---|
1837 | fprintf(dd->f_write,"%d %d ",M.getHeight(),M.getWidth()); |
---|
1838 | |
---|
1839 | for (int i=0; i<M.getHeight(); i++) |
---|
1840 | { |
---|
1841 | for (int j=0; j<M.getWidth(); j++) |
---|
1842 | { |
---|
1843 | gfanIntegerWriteFd(M[i][j],dd); |
---|
1844 | } |
---|
1845 | } |
---|
1846 | } |
---|
1847 | |
---|
1848 | BOOLEAN bbcone_serialize(blackbox *b, void *d, si_link f) |
---|
1849 | { |
---|
1850 | ssiInfo *dd = (ssiInfo *)f->data; |
---|
1851 | |
---|
1852 | sleftv l; |
---|
1853 | memset(&l,0,sizeof(l)); |
---|
1854 | l.rtyp=STRING_CMD; |
---|
1855 | l.data=(void*)"cone"; |
---|
1856 | f->m->Write(f, &l); |
---|
1857 | |
---|
1858 | gfan::ZCone *Z = (gfan::ZCone*) d; |
---|
1859 | fprintf(dd->f_write,"%d ",Z->areImpliedEquationsKnown()+Z->areFacetsKnown()*2); |
---|
1860 | |
---|
1861 | gfan::ZMatrix i=Z->getInequalities(); |
---|
1862 | gfanZMatrixWriteFd(i,dd); |
---|
1863 | |
---|
1864 | gfan::ZMatrix e=Z->getEquations(); |
---|
1865 | gfanZMatrixWriteFd(e,dd); |
---|
1866 | |
---|
1867 | // assert(i.getWidth() == e.getWidth()); |
---|
1868 | return FALSE; |
---|
1869 | } |
---|
1870 | |
---|
1871 | static gfan::Integer gfanIntegerReadFd(ssiInfo* dd) |
---|
1872 | { |
---|
1873 | mpz_t tmp; |
---|
1874 | mpz_init(tmp); |
---|
1875 | s_readmpz_base(dd->f_read,tmp,SSI_BASE); |
---|
1876 | gfan::Integer n(tmp); |
---|
1877 | mpz_clear(tmp); |
---|
1878 | return n; |
---|
1879 | } |
---|
1880 | |
---|
1881 | static gfan::ZMatrix gfanZMatrixReadFd(ssiInfo* dd) |
---|
1882 | { |
---|
1883 | int r=s_readint(dd->f_read); |
---|
1884 | int c=s_readint(dd->f_read); |
---|
1885 | |
---|
1886 | gfan::ZMatrix M(r,c); |
---|
1887 | for (int i=0; i<r; i++) |
---|
1888 | { |
---|
1889 | for (int j=0; j<c; j++) |
---|
1890 | { |
---|
1891 | M[i][j] = gfanIntegerReadFd(dd); |
---|
1892 | } |
---|
1893 | } |
---|
1894 | return M; |
---|
1895 | } |
---|
1896 | |
---|
1897 | BOOLEAN bbcone_deserialize(blackbox **b, void **d, si_link f) |
---|
1898 | { |
---|
1899 | ssiInfo *dd = (ssiInfo *)f->data; |
---|
1900 | int preassumptions = s_readint(dd->f_read); |
---|
1901 | |
---|
1902 | gfan::ZMatrix i = gfanZMatrixReadFd(dd); |
---|
1903 | gfan::ZMatrix e = gfanZMatrixReadFd(dd); |
---|
1904 | |
---|
1905 | // if (e.getHeight()==0) // why is e sometimes 0x0 and sometimex 0xn??? |
---|
1906 | // e = gfan::ZMatrix(0,i.getWidth()); |
---|
1907 | |
---|
1908 | gfan::ZCone* Z = new gfan::ZCone(i,e,preassumptions); |
---|
1909 | |
---|
1910 | *d=Z; |
---|
1911 | return FALSE; |
---|
1912 | } |
---|
1913 | |
---|
1914 | void bbcone_setup(SModulFunctions* p) |
---|
1915 | { |
---|
1916 | blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox)); |
---|
1917 | // all undefined entries will be set to default in setBlackboxStuff |
---|
1918 | // the default Print is quite usefull, |
---|
1919 | // all other are simply error messages |
---|
1920 | b->blackbox_destroy=bbcone_destroy; |
---|
1921 | b->blackbox_String=bbcone_String; |
---|
1922 | // b->blackbox_Print=blackbox_default_Print; |
---|
1923 | b->blackbox_Init=bbcone_Init; |
---|
1924 | b->blackbox_Copy=bbcone_Copy; |
---|
1925 | b->blackbox_Assign=bbcone_Assign; |
---|
1926 | b->blackbox_Op2=bbcone_Op2; |
---|
1927 | b->blackbox_serialize=bbcone_serialize; |
---|
1928 | b->blackbox_deserialize=bbcone_deserialize; |
---|
1929 | p->iiAddCproc("gfan.lib","coneViaInequalities",FALSE,coneViaNormals); |
---|
1930 | p->iiAddCproc("gfan.lib","coneViaPoints",FALSE,coneViaRays); |
---|
1931 | p->iiAddCproc("","listContainsCone",FALSE,containsCone); |
---|
1932 | // iiAddCproc("gfan.lib","makePolytope",FALSE,coneToPolytope); |
---|
1933 | p->iiAddCproc("gfan.lib","ambientDimension",FALSE,ambientDimension); |
---|
1934 | p->iiAddCproc("gfan.lib","canonicalizeCone",FALSE,canonicalizeCone); |
---|
1935 | p->iiAddCproc("gfan.lib","codimension",FALSE,codimension); |
---|
1936 | p->iiAddCproc("gfan.lib","coneLink",FALSE,coneLink); |
---|
1937 | p->iiAddCproc("gfan.lib","containsAsFace",FALSE,hasFace); |
---|
1938 | p->iiAddCproc("gfan.lib","containsInSupport",FALSE,containsInSupport); |
---|
1939 | p->iiAddCproc("gfan.lib","containsPositiveVector",FALSE,containsPositiveVector); |
---|
1940 | p->iiAddCproc("gfan.lib","containsRelatively",FALSE,containsRelatively); |
---|
1941 | p->iiAddCproc("gfan.lib","convexHull",FALSE,convexHull); |
---|
1942 | p->iiAddCproc("gfan.lib","convexIntersection",FALSE,intersectCones); |
---|
1943 | p->iiAddCproc("gfan.lib","dimension",FALSE,dimension); |
---|
1944 | p->iiAddCproc("gfan.lib","dualCone",FALSE,dualCone); |
---|
1945 | p->iiAddCproc("gfan.lib","equations",FALSE,equations); |
---|
1946 | p->iiAddCproc("gfan.lib","facets",FALSE,facets); |
---|
1947 | p->iiAddCproc("gfan.lib","generatorsOfLinealitySpace",FALSE,generatorsOfLinealitySpace); |
---|
1948 | p->iiAddCproc("gfan.lib","generatorsOfSpan",FALSE,generatorsOfSpan); |
---|
1949 | p->iiAddCproc("gfan.lib","getLinearForms",FALSE,getLinearForms); |
---|
1950 | p->iiAddCproc("gfan.lib","getMultiplicity",FALSE,getMultiplicity); |
---|
1951 | p->iiAddCproc("gfan.lib","inequalities",FALSE,inequalities); |
---|
1952 | p->iiAddCproc("gfan.lib","isFullSpace",FALSE,isFullSpace); |
---|
1953 | p->iiAddCproc("gfan.lib","isOrigin",FALSE,isOrigin); |
---|
1954 | p->iiAddCproc("gfan.lib","isSimplicial",FALSE,isSimplicial); |
---|
1955 | p->iiAddCproc("gfan.lib","linealityDimension",FALSE,linealityDimension); |
---|
1956 | p->iiAddCproc("gfan.lib","linealitySpace",FALSE,linealitySpace); |
---|
1957 | p->iiAddCproc("gfan.lib","negatedCone",FALSE,negatedCone); |
---|
1958 | p->iiAddCproc("gfan.lib","quotientLatticeBasis",FALSE,quotientLatticeBasis); |
---|
1959 | p->iiAddCproc("gfan.lib","randomPoint",FALSE,randomPoint); |
---|
1960 | p->iiAddCproc("gfan.lib","rays",FALSE,rays); |
---|
1961 | p->iiAddCproc("gfan.lib","relativeInteriorPoint",FALSE,relativeInteriorPoint); |
---|
1962 | p->iiAddCproc("gfan.lib","semigroupGenerator",FALSE,semigroupGenerator); |
---|
1963 | p->iiAddCproc("gfan.lib","setLinearForms",FALSE,setLinearForms); |
---|
1964 | p->iiAddCproc("gfan.lib","setMultiplicity",FALSE,setMultiplicity); |
---|
1965 | p->iiAddCproc("gfan.lib","span",FALSE,impliedEquations); |
---|
1966 | p->iiAddCproc("gfan.lib","uniquePoint",FALSE,uniquePoint); |
---|
1967 | p->iiAddCproc("gfan.lib","faceContaining",FALSE,faceContaining); |
---|
1968 | coneID=setBlackboxStuff(b,"cone"); |
---|
1969 | } |
---|
1970 | |
---|
1971 | #endif |
---|