My Project
Loading...
Searching...
No Matches
Functions | Variables
bbpolytope.cc File Reference
#include "kernel/mod2.h"
#include "Singular/ipid.h"
#include "Singular/ipshell.h"
#include "Singular/blackbox.h"
#include "misc/intvec.h"
#include "coeffs/bigintmat.h"
#include "callgfanlib_conversion.h"
#include "gfanlib/gfanlib.h"
#include "gfanlib/gfanlib_q.h"

Go to the source code of this file.

Functions

std::string bbpolytopeToString (gfan::ZCone const &c)
 
void * bbpolytope_Init (blackbox *)
 
BOOLEAN bbpolytope_Assign (leftv l, leftv r)
 
char * bbpolytope_String (blackbox *, void *d)
 
void bbpolytope_destroy (blackbox *, void *d)
 
void * bbpolytope_Copy (blackbox *, void *d)
 
static BOOLEAN ppCONERAYS1 (leftv res, leftv v)
 
static BOOLEAN ppCONERAYS3 (leftv res, leftv u, leftv v)
 
BOOLEAN polytopeViaVertices (leftv res, leftv args)
 
static BOOLEAN ppCONENORMALS1 (leftv res, leftv v)
 
static BOOLEAN ppCONENORMALS2 (leftv res, leftv u, leftv v)
 
static BOOLEAN ppCONENORMALS3 (leftv res, leftv u, leftv v, leftv w)
 
BOOLEAN polytopeViaNormals (leftv res, leftv args)
 
BOOLEAN vertices (leftv res, leftv args)
 
int getAmbientDimension (gfan::ZCone *zc)
 
int getCodimension (gfan::ZCone *zc)
 
int getDimension (gfan::ZCone *zc)
 
gfan::ZVector intStar2ZVectorWithLeadingOne (const int d, const int *i)
 
gfan::ZCone newtonPolytope (poly p, ring r)
 
BOOLEAN newtonPolytope (leftv res, leftv args)
 
BOOLEAN scalePolytope (leftv res, leftv args)
 
BOOLEAN dualPolytope (leftv res, leftv args)
 
BOOLEAN mixedVolume (leftv res, leftv args)
 
void bbpolytope_setup (SModulFunctions *p)
 

Variables

VAR int polytopeID
 

Function Documentation

◆ bbpolytope_Assign()

BOOLEAN bbpolytope_Assign ( leftv  l,
leftv  r 
)

Definition at line 37 of file bbpolytope.cc.

38{
39 gfan::ZCone* newZc;
40 if (r==NULL)
41 {
42 if (l->Data()!=NULL)
43 {
44 gfan::ZCone* zd = (gfan::ZCone*)l->Data();
45 delete zd;
46 }
47 newZc = new gfan::ZCone();
48 }
49 else if (r->Typ()==l->Typ())
50 {
51 if (l->Data()!=NULL)
52 {
53 gfan::ZCone* zd = (gfan::ZCone*)l->Data();
54 delete zd;
55 }
56 gfan::ZCone* zc = (gfan::ZCone*)r->Data();
57 newZc = new gfan::ZCone(*zc);
58 }
59 // else if (r->Typ()==INT_CMD) TODO:r->Typ()==BIGINTMAT_CMD
60 // {
61 // int ambientDim = (int)(long)r->Data();
62 // if (ambientDim < 0)
63 // {
64 // Werror("expected an int >= 0, but got %d", ambientDim);
65 // return TRUE;
66 // }
67 // if (l->Data()!=NULL)
68 // {
69 // gfan::ZCone* zd = (gfan::ZCone*)l->Data();
70 // delete zd;
71 // }
72 // newZc = new gfan::ZCone(ambientDim);
73 // }
74 else
75 {
76 Werror("assign Type(%d) = Type(%d) not implemented",l->Typ(),r->Typ());
77 return TRUE;
78 }
79
80 if (l->rtyp==IDHDL)
81 {
82 IDDATA((idhdl)l->data) = (char*) newZc;
83 }
84 else
85 {
86 l->data=(void *)newZc;
87 }
88 return FALSE;
89}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int l
Definition: cfEzgcd.cc:100
Definition: idrec.h:35
int Typ()
Definition: subexpr.cc:1019
void * Data()
Definition: subexpr.cc:1162
#define IDDATA(a)
Definition: ipid.h:126
#define NULL
Definition: omList.c:12
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define IDHDL
Definition: tok.h:31

◆ bbpolytope_Copy()

void * bbpolytope_Copy ( blackbox *  ,
void *  d 
)

Definition at line 110 of file bbpolytope.cc.

111{
112 gfan::ZCone* zc = (gfan::ZCone*)d;
113 gfan::ZCone* newZc = new gfan::ZCone(*zc);
114 return newZc;
115}

◆ bbpolytope_destroy()

void bbpolytope_destroy ( blackbox *  ,
void *  d 
)

Definition at line 101 of file bbpolytope.cc.

102{
103 if (d!=NULL)
104 {
105 gfan::ZCone* zc = (gfan::ZCone*) d;
106 delete zc;
107 }
108}

◆ bbpolytope_Init()

void * bbpolytope_Init ( blackbox *  )

Definition at line 32 of file bbpolytope.cc.

33{
34 return (void*)(new gfan::ZCone());
35}

◆ bbpolytope_setup()

void bbpolytope_setup ( SModulFunctions p)

Definition at line 549 of file bbpolytope.cc.

550{
551 blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
552 // all undefined entries will be set to default in setBlackboxStuff
553 // the default Print is quite usefule,
554 // all other are simply error messages
555 b->blackbox_destroy=bbpolytope_destroy;
556 b->blackbox_String=bbpolytope_String;
557 //b->blackbox_Print=blackbox_default_Print;
558 b->blackbox_Init=bbpolytope_Init;
559 b->blackbox_Copy=bbpolytope_Copy;
560 b->blackbox_Assign=bbpolytope_Assign;
561 p->iiAddCproc("gfan.lib","polytopeViaPoints",FALSE,polytopeViaVertices);
562 p->iiAddCproc("gfan.lib","polytopeViaInequalities",FALSE,polytopeViaNormals);
563 p->iiAddCproc("gfan.lib","vertices",FALSE,vertices);
564 p->iiAddCproc("gfan.lib","newtonPolytope",FALSE,newtonPolytope);
565 p->iiAddCproc("gfan.lib","scalePolytope",FALSE,scalePolytope);
566 p->iiAddCproc("gfan.lib","dualPolytope",FALSE,dualPolytope);
567 p->iiAddCproc("gfan.lib","mixedVolume",FALSE,mixedVolume);
568 /********************************************************/
569 /* the following functions are implemented in bbcone.cc */
570 // iiAddCproc("gfan.lib","getAmbientDimension",FALSE,getAmbientDimension);
571 // iiAddCproc("gfan.lib","getCodimension",FALSE,getAmbientDimension);
572 // iiAddCproc("gfan.lib","getDimension",FALSE,getDimension);
573 /********************************************************/
574 /* the following functions are identical to those in bbcone.cc */
575 // iiAddCproc("gfan.lib","facets",FALSE,facets);
576 // iiAddCproc("gfan.lib","setLinearForms",FALSE,setLinearForms);
577 // iiAddCproc("gfan.lib","getLinearForms",FALSE,getLinearForms);
578 // iiAddCproc("gfan.lib","setMultiplicity",FALSE,setMultiplicity);
579 // iiAddCproc("gfan.lib","getMultiplicity",FALSE,getMultiplicity);
580 // iiAddCproc("gfan.lib","hasFace",FALSE,hasFace);
581 /***************************************************************/
582 // iiAddCproc("gfan.lib","getEquations",FALSE,getEquations);
583 // iiAddCproc("gfan.lib","getInequalities",FALSE,getInequalities);
584 polytopeID=setBlackboxStuff(b,"polytope");
585 //Print("created type %d (polytope)\n",polytopeID);
586}
BOOLEAN polytopeViaVertices(leftv res, leftv args)
Definition: bbpolytope.cc:184
void bbpolytope_destroy(blackbox *, void *d)
Definition: bbpolytope.cc:101
char * bbpolytope_String(blackbox *, void *d)
Definition: bbpolytope.cc:91
BOOLEAN polytopeViaNormals(leftv res, leftv args)
Definition: bbpolytope.cc:330
BOOLEAN dualPolytope(leftv res, leftv args)
Definition: bbpolytope.cc:472
BOOLEAN scalePolytope(leftv res, leftv args)
Definition: bbpolytope.cc:445
VAR int polytopeID
Definition: bbpolytope.cc:16
void * bbpolytope_Init(blackbox *)
Definition: bbpolytope.cc:32
BOOLEAN bbpolytope_Assign(leftv l, leftv r)
Definition: bbpolytope.cc:37
BOOLEAN mixedVolume(leftv res, leftv args)
Definition: bbpolytope.cc:489
gfan::ZCone newtonPolytope(poly p, ring r)
Definition: bbpolytope.cc:412
BOOLEAN vertices(leftv res, leftv args)
Definition: bbpolytope.cc:369
void * bbpolytope_Copy(blackbox *, void *d)
Definition: bbpolytope.cc:110
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition: blackbox.cc:142
int p
Definition: cfModGcd.cc:4078
CanonicalForm b
Definition: cfModGcd.cc:4103
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ bbpolytope_String()

char * bbpolytope_String ( blackbox *  ,
void *  d 
)

Definition at line 91 of file bbpolytope.cc.

92{ if (d==NULL) return omStrDup("invalid object");
93 else
94 {
95 gfan::ZCone* zc = (gfan::ZCone*)d;
96 std::string s=bbpolytopeToString(*zc);
97 return omStrDup(s.c_str());
98 }
99}
std::string bbpolytopeToString(gfan::ZCone const &c)
Definition: bbpolytope.cc:18
const CanonicalForm int s
Definition: facAbsFact.cc:51
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ bbpolytopeToString()

std::string bbpolytopeToString ( gfan::ZCone const c)

Definition at line 18 of file bbpolytope.cc.

19{
20 std::stringstream s;
21 gfan::ZMatrix i=c.getInequalities();
22 gfan::ZMatrix e=c.getEquations();
23 s<<"AMBIENT_DIM"<<std::endl;
24 s<<c.ambientDimension()-1<<std::endl;
25 s<<"INEQUALITIES"<<std::endl;
26 s<<toString(i)<<std::endl;
27 s<<"EQUATIONS"<<std::endl;
28 s<<toString(e)<<std::endl;
29 return s.str();
30}
std::string toString(const gfan::ZCone *const c)
Definition: bbcone.cc:27
int i
Definition: cfEzgcd.cc:132

◆ dualPolytope()

BOOLEAN dualPolytope ( leftv  res,
leftv  args 
)

Definition at line 472 of file bbpolytope.cc.

473{
474 leftv u = args;
475 if ((u != NULL) && (u->Typ() == polytopeID))
476 {
477 gfan::initializeCddlibIfRequired();
478 gfan::ZCone* zp = (gfan::ZCone*) u->Data();
479 gfan::ZCone* zq = new gfan::ZCone(zp->dualCone());
480 res->rtyp = polytopeID;
481 res->data = (void*) zq;
482 gfan::deinitializeCddlibIfRequired();
483 return FALSE;
484 }
485 WerrorS("dualPolytope: unexpected parameters");
486 return TRUE;
487}
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
CanonicalForm res
Definition: facAbsFact.cc:60
void WerrorS(const char *s)
Definition: feFopen.cc:24

◆ getAmbientDimension()

int getAmbientDimension ( gfan::ZCone *  zc)

Definition at line 386 of file bbpolytope.cc.

387{ // hence ambientDimension-1
388 return zc->ambientDimension()-1;
389}

◆ getCodimension()

int getCodimension ( gfan::ZCone *  zc)

Definition at line 391 of file bbpolytope.cc.

392{
393 return zc->codimension();
394}

◆ getDimension()

int getDimension ( gfan::ZCone *  zc)

Definition at line 396 of file bbpolytope.cc.

397{
398 return zc->dimension()-1;
399}

◆ intStar2ZVectorWithLeadingOne()

gfan::ZVector intStar2ZVectorWithLeadingOne ( const int  d,
const int *  i 
)

Definition at line 401 of file bbpolytope.cc.

402{
403 gfan::ZVector zv(d+1);
404 zv[0]=1;
405 for(int j=1; j<=d; j++)
406 {
407 zv[j]=i[j];
408 }
409 return zv;
410}
int j
Definition: facHensel.cc:110

◆ mixedVolume()

BOOLEAN mixedVolume ( leftv  res,
leftv  args 
)

Definition at line 489 of file bbpolytope.cc.

490{
491 leftv u = args;
492 if ((u != NULL) && (u->Typ() == LIST_CMD))
493 {
494 gfan::initializeCddlibIfRequired();
495 lists l = (lists) u->Data();
496 int k = lSize(l)+1;
497 std::vector<gfan::IntMatrix> P(k);
498 for (int i=0; i<k; i++)
499 {
500 if (l->m[i].Typ() == polytopeID)
501 {
502 gfan::ZCone* p = (gfan::ZCone*) l->m[i].Data();
503 gfan::ZMatrix pv = p->extremeRays();
504 int r = pv.getHeight();
505 int c = pv.getWidth();
506 gfan::IntMatrix pw(r,c-1);
507 for (int n=0; n<r; n++)
508 for (int m=1; m<c; m++)
509 pw[n][m-1] = pv[n][m].toInt();
510 P[i]=pw.transposed();
511 } else if (l->m[i].Typ() == POLY_CMD)
512 {
513 poly p = (poly) l->m[i].Data();
514 int N = rVar(currRing);
515 gfan::IntMatrix pw(0,N);
516 int *leadexpv = (int*)omAlloc((N+1)*sizeof(int));
517 while (p!=NULL)
518 {
519 p_GetExpV(p,leadexpv,currRing);
520 gfan::IntVector zv(N);
521 for (int i=0; i<N; i++)
522 zv[i] = leadexpv[i+1];
523 pw.appendRow(zv);
524 pIter(p);
525 }
526 P[i]=pw.transposed();
527 omFreeSize(leadexpv,(N+1)*sizeof(int));
528 }
529 else
530 {
531 WerrorS("mixedVolume: entries of unsupported type in list");
532 gfan::deinitializeCddlibIfRequired();
533 return TRUE;
534 }
535 }
536 gfan::Integer mv = gfan::mixedVolume(P);
537
538 res->rtyp = BIGINT_CMD;
539 res->data = (void*) integerToNumber(mv);
540 gfan::deinitializeCddlibIfRequired();
541 return FALSE;
542 }
543 WerrorS("mixedVolume: unexpected parameters");
544 return TRUE;
545}
number integerToNumber(const gfan::Integer &I)
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
int m
Definition: cfEzgcd.cc:128
int k
Definition: cfEzgcd.cc:99
Definition: lists.h:24
@ POLY_CMD
Definition: grammar.cc:289
int lSize(lists L)
Definition: lists.cc:25
#define pIter(p)
Definition: monomials.h:37
slists * lists
Definition: mpr_numeric.h:146
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1518
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
@ BIGINT_CMD
Definition: tok.h:38
@ LIST_CMD
Definition: tok.h:118

◆ newtonPolytope() [1/2]

BOOLEAN newtonPolytope ( leftv  res,
leftv  args 
)

Definition at line 429 of file bbpolytope.cc.

430{
431 leftv u = args;
432 if ((u != NULL) && (u->Typ() == POLY_CMD))
433 {
434 gfan::initializeCddlibIfRequired();
435 poly p = (poly)u->Data();
436 res->rtyp = polytopeID;
437 res->data = (void*) new gfan::ZCone(newtonPolytope(p,currRing));
438 gfan::deinitializeCddlibIfRequired();
439 return FALSE;
440 }
441 WerrorS("newtonPolytope: unexpected parameters");
442 return TRUE;
443}

◆ newtonPolytope() [2/2]

gfan::ZCone newtonPolytope ( poly  p,
ring  r 
)

Definition at line 412 of file bbpolytope.cc.

413{
414 int N = rVar(r);
415 gfan::ZMatrix zm(0,N+1);
416 int *leadexpv = (int*)omAlloc((N+1)*sizeof(int));
417 while (p!=NULL)
418 {
419 p_GetExpV(p,leadexpv,r);
420 gfan::ZVector zv = intStar2ZVectorWithLeadingOne(N, leadexpv);
421 zm.appendRow(zv);
422 pIter(p);
423 }
424 omFreeSize(leadexpv,(N+1)*sizeof(int));
425 gfan::ZCone Delta = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
426 return Delta;
427}
gfan::ZVector intStar2ZVectorWithLeadingOne(const int d, const int *i)
Definition: bbpolytope.cc:401

◆ polytopeViaNormals()

BOOLEAN polytopeViaNormals ( leftv  res,
leftv  args 
)

Definition at line 330 of file bbpolytope.cc.

331{
332 leftv u = args;
333 if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD)))
334 {
335 if (u->next == NULL)
336 {
337 gfan::initializeCddlibIfRequired();
338 BOOLEAN bo = ppCONENORMALS1(res, u);
339 gfan::deinitializeCddlibIfRequired();
340 return bo;
341 }
342 }
343 leftv v = u->next;
344 if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTMAT_CMD)))
345 {
346 if (v->next == NULL)
347 {
348 gfan::initializeCddlibIfRequired();
349 BOOLEAN bo = ppCONENORMALS2(res, u, v);
350 gfan::deinitializeCddlibIfRequired();
351 return bo;
352 }
353 }
354 leftv w = v->next;
355 if ((w != NULL) && (w->Typ() == INT_CMD))
356 {
357 if (w->next == NULL)
358 {
359 gfan::initializeCddlibIfRequired();
360 BOOLEAN bo = ppCONENORMALS3(res, u, v, w);
361 gfan::deinitializeCddlibIfRequired();
362 return bo;
363 }
364 }
365 WerrorS("polytopeViaInequalities: unexpected parameters");
366 return TRUE;
367}
int BOOLEAN
Definition: auxiliary.h:87
static BOOLEAN ppCONENORMALS2(leftv res, leftv u, leftv v)
Definition: bbpolytope.cc:234
static BOOLEAN ppCONENORMALS1(leftv res, leftv v)
Definition: bbpolytope.cc:212
static BOOLEAN ppCONENORMALS3(leftv res, leftv u, leftv v, leftv w)
Definition: bbpolytope.cc:278
Variable next() const
Definition: variable.h:52
leftv next
Definition: subexpr.h:86
const CanonicalForm & w
Definition: facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
@ BIGINTMAT_CMD
Definition: grammar.cc:278
@ INTMAT_CMD
Definition: grammar.cc:279
@ INT_CMD
Definition: tok.h:96

◆ polytopeViaVertices()

BOOLEAN polytopeViaVertices ( leftv  res,
leftv  args 
)

Definition at line 184 of file bbpolytope.cc.

185{
186 leftv u = args;
187 if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD)))
188 {
189 if (u->next == NULL)
190 {
191 gfan::initializeCddlibIfRequired();
192 BOOLEAN bo = ppCONERAYS1(res, u);
193 gfan::deinitializeCddlibIfRequired();
194 return bo;
195 }
196 leftv v = u->next;
197 if ((v != NULL) && (v->Typ() == INT_CMD))
198 {
199 if (v->next == NULL)
200 {
201 gfan::initializeCddlibIfRequired();
202 BOOLEAN bo = ppCONERAYS3(res, u, v);
203 gfan::deinitializeCddlibIfRequired();
204 return bo;
205 }
206 }
207 }
208 WerrorS("polytopeViaPoints: unexpected parameters");
209 return TRUE;
210}
static BOOLEAN ppCONERAYS1(leftv res, leftv v)
Definition: bbpolytope.cc:117
static BOOLEAN ppCONERAYS3(leftv res, leftv u, leftv v)
Definition: bbpolytope.cc:144

◆ ppCONENORMALS1()

static BOOLEAN ppCONENORMALS1 ( leftv  res,
leftv  v 
)
static

Definition at line 212 of file bbpolytope.cc.

213{
214 /* method for generating a cone object from inequalities;
215 valid parametrizations: (bigintmat) */
216 bigintmat* ineq = NULL;
217 if (v->Typ() == INTMAT_CMD)
218 {
219 intvec* ineq0 = (intvec*) v->Data();
220 ineq = iv2bim(ineq0,coeffs_BIGINT);
221 }
222 else
223 ineq = (bigintmat*) v->Data();
224 gfan::ZMatrix* zm = bigintmatToZMatrix(ineq);
225 gfan::ZCone* zc = new gfan::ZCone(*zm, gfan::ZMatrix(0, zm->getWidth()));
226 delete zm;
227 if (v->Typ() == INTMAT_CMD)
228 delete ineq;
229 res->rtyp = polytopeID;
230 res->data = (void*) zc;
231 return FALSE;
232}
bigintmat * iv2bim(intvec *b, const coeffs C)
Definition: bigintmat.cc:349
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
Matrices of numbers.
Definition: bigintmat.h:51
Definition: intvec.h:23
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50

◆ ppCONENORMALS2()

static BOOLEAN ppCONENORMALS2 ( leftv  res,
leftv  u,
leftv  v 
)
static

Definition at line 234 of file bbpolytope.cc.

235{
236 /* method for generating a cone object from iequalities,
237 and equations (...)
238 valid parametrizations: (bigintmat, bigintmat)
239 Errors will be invoked in the following cases:
240 - u and v have different numbers of columns */
241 bigintmat* ineq = NULL; bigintmat* eq = NULL;
242 if (u->Typ() == INTMAT_CMD)
243 {
244 intvec* ineq0 = (intvec*) u->Data();
245 ineq = iv2bim(ineq0,coeffs_BIGINT);
246 }
247 else
248 ineq = (bigintmat*) u->Data();
249 if (v->Typ() == INTMAT_CMD)
250 {
251 intvec* eq0 = (intvec*) v->Data();
252 eq = iv2bim(eq0,coeffs_BIGINT);
253 }
254 else
255 eq = (bigintmat*) v->Data();
256
257 if (ineq->cols() != eq->cols())
258 {
259 Werror("expected same number of columns but got %d vs. %d",
260 ineq->cols(), eq->cols());
261 return TRUE;
262 }
263 gfan::ZMatrix* zm1 = bigintmatToZMatrix(ineq);
264 gfan::ZMatrix* zm2 = bigintmatToZMatrix(eq);
265 gfan::ZCone* zc = new gfan::ZCone(*zm1, *zm2);
266 delete zm1;
267 delete zm2;
268 if (u->Typ() == INTMAT_CMD)
269 delete ineq;
270 if (v->Typ() == INTMAT_CMD)
271 delete eq;
272
273 res->rtyp = polytopeID;
274 res->data = (void*) zc;
275 return FALSE;
276}
int cols() const
Definition: bigintmat.h:144

◆ ppCONENORMALS3()

static BOOLEAN ppCONENORMALS3 ( leftv  res,
leftv  u,
leftv  v,
leftv  w 
)
static

Definition at line 278 of file bbpolytope.cc.

279{
280 /* method for generating a cone object from inequalities, equations,
281 and an integer k;
282 valid parametrizations: (bigintmat, bigintmat, int);
283 Errors will be invoked in the following cases:
284 - u and v have different numbers of columns,
285 - k not in [0..3];
286 if the 2^0-bit of k is set, then ... */
287 bigintmat* ineq = NULL; bigintmat* eq = NULL;
288 if (u->Typ() == INTMAT_CMD)
289 {
290 intvec* ineq0 = (intvec*) u->Data();
291 ineq = iv2bim(ineq0,coeffs_BIGINT);
292 }
293 else
294 ineq = (bigintmat*) u->Data();
295 if (v->Typ() == INTMAT_CMD)
296 {
297 intvec* eq0 = (intvec*) v->Data();
298 eq = iv2bim(eq0,coeffs_BIGINT);
299 }
300 else
301 eq = (bigintmat*) v->Data();
302
303 if (ineq->cols() != eq->cols())
304 {
305 Werror("expected same number of columns but got %d vs. %d",
306 ineq->cols(), eq->cols());
307 return TRUE;
308 }
309 int k = (int)(long)w->Data();
310 if ((k < 0) || (k > 3))
311 {
312 WerrorS("expected int argument in [0..3]");
313 return TRUE;
314 }
315 gfan::ZMatrix* zm1 = bigintmatToZMatrix(ineq);
316 gfan::ZMatrix* zm2 = bigintmatToZMatrix(eq);
317 gfan::ZCone* zc = new gfan::ZCone(*zm1, *zm2, k);
318 delete zm1;
319 delete zm2;
320 if (u->Typ() == INTMAT_CMD)
321 delete ineq;
322 if (v->Typ() == INTMAT_CMD)
323 delete eq;
324
325 res->rtyp = polytopeID;
326 res->data = (void*) zc;
327 return FALSE;
328}

◆ ppCONERAYS1()

static BOOLEAN ppCONERAYS1 ( leftv  res,
leftv  v 
)
static

Definition at line 117 of file bbpolytope.cc.

118{
119 /* method for generating a cone object from half-lines
120 (cone = convex hull of the half-lines; note: there may be
121 entire lines in the cone);
122 valid parametrizations: (bigintmat) */
124 if (v->Typ() == INTMAT_CMD)
125 {
126 intvec* rays0 = (intvec*) v->Data();
127 rays = iv2bim(rays0,coeffs_BIGINT);
128 }
129 else
130 rays = (bigintmat*) v->Data();
131
132 gfan::ZMatrix* zm = bigintmatToZMatrix(rays);
133 gfan::ZCone* zc = new gfan::ZCone();
134 *zc = gfan::ZCone::givenByRays(*zm, gfan::ZMatrix(0, zm->getWidth()));
135 res->rtyp = polytopeID;
136 res->data = (void*) zc;
137
138 delete zm;
139 if (v->Typ() == INTMAT_CMD)
140 delete rays;
141 return FALSE;
142}
BOOLEAN rays(leftv res, leftv args)
Definition: bbcone.cc:662

◆ ppCONERAYS3()

static BOOLEAN ppCONERAYS3 ( leftv  res,
leftv  u,
leftv  v 
)
static

Definition at line 144 of file bbpolytope.cc.

145{
146 /* method for generating a cone object from half-lines
147 (any point in the cone being the sum of a point
148 in the convex hull of the half-lines and a point in the span
149 of the lines), and an integer k;
150 valid parametrizations: (bigintmat, int);
151 Errors will be invoked in the following cases:
152 - k not 0 or 1;
153 if the k=1, then the extreme rays are known:
154 each half-line spans a (different) extreme ray */
156 if (u->Typ() == INTMAT_CMD)
157 {
158 intvec* rays0 = (intvec*) u->Data();
159 rays = iv2bim(rays0,coeffs_BIGINT);
160 }
161 else
162 rays = (bigintmat*) u->Data();
163 int k = (int)(long)v->Data();
164
165 if ((k < 0) || (k > 1))
166 {
167 WerrorS("expected int argument in [0..1]");
168 return TRUE;
169 }
170 k=k*2;
171 gfan::ZMatrix* zm = bigintmatToZMatrix(rays);
172 gfan::ZCone* zc = new gfan::ZCone();
173 *zc = gfan::ZCone::givenByRays(*zm,gfan::ZMatrix(0, zm->getWidth()));
174 //k should be passed on to zc; not available yet
175 res->rtyp = polytopeID;
176 res->data = (void*) zc;
177
178 delete zm;
179 if (v->Typ() == INTMAT_CMD)
180 delete rays;
181 return FALSE;
182}

◆ scalePolytope()

BOOLEAN scalePolytope ( leftv  res,
leftv  args 
)

Definition at line 445 of file bbpolytope.cc.

446{
447 leftv u = args;
448 if ((u != NULL) && (u->Typ() == INT_CMD))
449 {
450 leftv v = u->next;
451 if ((v != NULL) && (v->Typ() == polytopeID))
452 {
453 gfan::initializeCddlibIfRequired();
454 int s = (int)(long) u->Data();
455 gfan::ZCone* zp = (gfan::ZCone*) v->Data();
456 gfan::ZMatrix zm = zp->extremeRays();
457 for (int i=0; i<zm.getHeight(); i++)
458 for (int j=1; j<zm.getWidth(); j++)
459 zm[i][j]*=s;
460 gfan::ZCone* zq = new gfan::ZCone();
461 *zq = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
462 res->rtyp = polytopeID;
463 res->data = (void*) zq;
464 gfan::deinitializeCddlibIfRequired();
465 return FALSE;
466 }
467 }
468 WerrorS("scalePolytope: unexpected parameters");
469 return TRUE;
470}

◆ vertices()

BOOLEAN vertices ( leftv  res,
leftv  args 
)

Definition at line 369 of file bbpolytope.cc.

370{
371 leftv u = args;
372 if ((u != NULL) && (u->Typ() == polytopeID))
373 {
374 gfan::initializeCddlibIfRequired();
375 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
376 gfan::ZMatrix zmat = zc->extremeRays();
377 res->rtyp = BIGINTMAT_CMD;
378 res->data = (void*)zMatrixToBigintmat(zmat);
379 gfan::deinitializeCddlibIfRequired();
380 return FALSE;
381 }
382 WerrorS("vertices: unexpected parameters");
383 return TRUE;
384}
bigintmat * zMatrixToBigintmat(const gfan::ZMatrix &zm)

Variable Documentation

◆ polytopeID

VAR int polytopeID

Definition at line 16 of file bbpolytope.cc.