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 <sstream>
#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

int polytopeID
 

Function Documentation

◆ bbpolytope_Assign()

BOOLEAN bbpolytope_Assign ( leftv  l,
leftv  r 
)

Definition at line 38 of file bbpolytope.cc.

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

◆ bbpolytope_Copy()

void* bbpolytope_Copy ( blackbox *  ,
void *  d 
)

Definition at line 111 of file bbpolytope.cc.

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

◆ bbpolytope_destroy()

void bbpolytope_destroy ( blackbox *  ,
void *  d 
)

Definition at line 102 of file bbpolytope.cc.

103 {
104  if (d!=NULL)
105  {
106  gfan::ZCone* zc = (gfan::ZCone*) d;
107  delete zc;
108  }
109 }
#define NULL
Definition: omList.c:10

◆ bbpolytope_Init()

void* bbpolytope_Init ( blackbox *  )

Definition at line 33 of file bbpolytope.cc.

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

◆ bbpolytope_setup()

void bbpolytope_setup ( SModulFunctions p)

Definition at line 550 of file bbpolytope.cc.

551 {
552  blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
553  // all undefined entries will be set to default in setBlackboxStuff
554  // the default Print is quite usefule,
555  // all other are simply error messages
556  b->blackbox_destroy=bbpolytope_destroy;
557  b->blackbox_String=bbpolytope_String;
558  //b->blackbox_Print=blackbox_default_Print;
559  b->blackbox_Init=bbpolytope_Init;
560  b->blackbox_Copy=bbpolytope_Copy;
561  b->blackbox_Assign=bbpolytope_Assign;
562  p->iiAddCproc("gfan.lib","polytopeViaPoints",FALSE,polytopeViaVertices);
563  p->iiAddCproc("gfan.lib","polytopeViaInequalities",FALSE,polytopeViaNormals);
564  p->iiAddCproc("gfan.lib","vertices",FALSE,vertices);
565  p->iiAddCproc("gfan.lib","newtonPolytope",FALSE,newtonPolytope);
566  p->iiAddCproc("gfan.lib","scalePolytope",FALSE,scalePolytope);
567  p->iiAddCproc("gfan.lib","dualPolytope",FALSE,dualPolytope);
568  p->iiAddCproc("gfan.lib","mixedVolume",FALSE,mixedVolume);
569  /********************************************************/
570  /* the following functions are implemented in bbcone.cc */
571  // iiAddCproc("gfan.lib","getAmbientDimension",FALSE,getAmbientDimension);
572  // iiAddCproc("gfan.lib","getCodimension",FALSE,getAmbientDimension);
573  // iiAddCproc("gfan.lib","getDimension",FALSE,getDimension);
574  /********************************************************/
575  /* the following functions are identical to those in bbcone.cc */
576  // iiAddCproc("gfan.lib","facets",FALSE,facets);
577  // iiAddCproc("gfan.lib","setLinearForms",FALSE,setLinearForms);
578  // iiAddCproc("gfan.lib","getLinearForms",FALSE,getLinearForms);
579  // iiAddCproc("gfan.lib","setMultiplicity",FALSE,setMultiplicity);
580  // iiAddCproc("gfan.lib","getMultiplicity",FALSE,getMultiplicity);
581  // iiAddCproc("gfan.lib","hasFace",FALSE,hasFace);
582  /***************************************************************/
583  // iiAddCproc("gfan.lib","getEquations",FALSE,getEquations);
584  // iiAddCproc("gfan.lib","getInequalities",FALSE,getInequalities);
585  polytopeID=setBlackboxStuff(b,"polytope");
586  //Print("created type %d (polytope)\n",polytopeID);
587 }
BOOLEAN mixedVolume(leftv res, leftv args)
Definition: bbpolytope.cc:490
BOOLEAN dualPolytope(leftv res, leftv args)
Definition: bbpolytope.cc:473
BOOLEAN bbpolytope_Assign(leftv l, leftv r)
Definition: bbpolytope.cc:38
BOOLEAN scalePolytope(leftv res, leftv args)
Definition: bbpolytope.cc:446
#define FALSE
Definition: auxiliary.h:94
void * bbpolytope_Init(blackbox *)
Definition: bbpolytope.cc:33
return P p
Definition: myNF.cc:203
int polytopeID
Definition: bbpolytope.cc:17
void bbpolytope_destroy(blackbox *, void *d)
Definition: bbpolytope.cc:102
BOOLEAN vertices(leftv res, leftv args)
Definition: bbpolytope.cc:370
BOOLEAN polytopeViaNormals(leftv res, leftv args)
Definition: bbpolytope.cc:331
BOOLEAN polytopeViaVertices(leftv res, leftv args)
Definition: bbpolytope.cc:185
gfan::ZCone newtonPolytope(poly p, ring r)
Definition: bbpolytope.cc:413
char * bbpolytope_String(blackbox *, void *d)
Definition: bbpolytope.cc:92
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition: blackbox.cc:126
const poly b
Definition: syzextra.cc:213
void * bbpolytope_Copy(blackbox *, void *d)
Definition: bbpolytope.cc:111
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ bbpolytope_String()

char* bbpolytope_String ( blackbox *  ,
void *  d 
)

Definition at line 92 of file bbpolytope.cc.

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

◆ bbpolytopeToString()

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

Definition at line 19 of file bbpolytope.cc.

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

◆ dualPolytope()

BOOLEAN dualPolytope ( leftv  res,
leftv  args 
)

Definition at line 473 of file bbpolytope.cc.

474 {
475  leftv u = args;
476  if ((u != NULL) && (u->Typ() == polytopeID))
477  {
478  gfan::initializeCddlibIfRequired();
479  gfan::ZCone* zp = (gfan::ZCone*) u->Data();
480  gfan::ZCone* zq = new gfan::ZCone(zp->dualCone());
481  res->rtyp = polytopeID;
482  res->data = (void*) zq;
483  gfan::deinitializeCddlibIfRequired();
484  return FALSE;
485  }
486  WerrorS("dualPolytope: unexpected parameters");
487  return TRUE;
488 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:995
poly res
Definition: myNF.cc:322
int polytopeID
Definition: bbpolytope.cc:17
#define NULL
Definition: omList.c:10
void * Data()
Definition: subexpr.cc:1137

◆ getAmbientDimension()

int getAmbientDimension ( gfan::ZCone *  zc)

Definition at line 387 of file bbpolytope.cc.

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

◆ getCodimension()

int getCodimension ( gfan::ZCone *  zc)

Definition at line 392 of file bbpolytope.cc.

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

◆ getDimension()

int getDimension ( gfan::ZCone *  zc)

Definition at line 397 of file bbpolytope.cc.

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

◆ intStar2ZVectorWithLeadingOne()

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

Definition at line 402 of file bbpolytope.cc.

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

◆ mixedVolume()

BOOLEAN mixedVolume ( leftv  res,
leftv  args 
)

Definition at line 490 of file bbpolytope.cc.

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

◆ newtonPolytope() [1/2]

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

Definition at line 413 of file bbpolytope.cc.

414 {
415  int N = rVar(r);
416  gfan::ZMatrix zm(0,N+1);
417  int *leadexpv = (int*)omAlloc((N+1)*sizeof(int));
418  while (p!=NULL)
419  {
420  p_GetExpV(p,leadexpv,r);
421  gfan::ZVector zv = intStar2ZVectorWithLeadingOne(N, leadexpv);
422  zm.appendRow(zv);
423  pIter(p);
424  }
425  omFreeSize(leadexpv,(N+1)*sizeof(int));
426  gfan::ZCone Delta = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
427  return Delta;
428 }
return P p
Definition: myNF.cc:203
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1443
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
#define omAlloc(size)
Definition: omAllocDecl.h:210
gfan::ZVector intStar2ZVectorWithLeadingOne(const int d, const int *i)
Definition: bbpolytope.cc:402
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
#define NULL
Definition: omList.c:10

◆ newtonPolytope() [2/2]

BOOLEAN newtonPolytope ( leftv  res,
leftv  args 
)

Definition at line 430 of file bbpolytope.cc.

431 {
432  leftv u = args;
433  if ((u != NULL) && (u->Typ() == POLY_CMD))
434  {
435  gfan::initializeCddlibIfRequired();
436  poly p = (poly)u->Data();
437  res->rtyp = polytopeID;
438  res->data = (void*) new gfan::ZCone(newtonPolytope(p,currRing));
439  gfan::deinitializeCddlibIfRequired();
440  return FALSE;
441  }
442  WerrorS("newtonPolytope: unexpected parameters");
443  return TRUE;
444 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:995
poly res
Definition: myNF.cc:322
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
int polytopeID
Definition: bbpolytope.cc:17
#define NULL
Definition: omList.c:10
void * Data()
Definition: subexpr.cc:1137
gfan::ZCone newtonPolytope(poly p, ring r)
Definition: bbpolytope.cc:413
polyrec * poly
Definition: hilb.h:10

◆ polytopeViaNormals()

BOOLEAN polytopeViaNormals ( leftv  res,
leftv  args 
)

Definition at line 331 of file bbpolytope.cc.

332 {
333  leftv u = args;
334  if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD)))
335  {
336  if (u->next == NULL)
337  {
338  gfan::initializeCddlibIfRequired();
339  BOOLEAN bo = ppCONENORMALS1(res, u);
340  gfan::deinitializeCddlibIfRequired();
341  return bo;
342  }
343  }
344  leftv v = u->next;
345  if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTMAT_CMD)))
346  {
347  if (v->next == NULL)
348  {
349  gfan::initializeCddlibIfRequired();
350  BOOLEAN bo = ppCONENORMALS2(res, u, v);
351  gfan::deinitializeCddlibIfRequired();
352  return bo;
353  }
354  }
355  leftv w = v->next;
356  if ((w != NULL) && (w->Typ() == INT_CMD))
357  {
358  if (w->next == NULL)
359  {
360  gfan::initializeCddlibIfRequired();
361  BOOLEAN bo = ppCONENORMALS3(res, u, v, w);
362  gfan::deinitializeCddlibIfRequired();
363  return bo;
364  }
365  }
366  WerrorS("polytopeViaInequalities: unexpected parameters");
367  return TRUE;
368 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
Definition: tok.h:95
static BOOLEAN ppCONENORMALS3(leftv res, leftv u, leftv v, leftv w)
Definition: bbpolytope.cc:279
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:995
poly res
Definition: myNF.cc:322
static BOOLEAN ppCONENORMALS2(leftv res, leftv u, leftv v)
Definition: bbpolytope.cc:235
Variable next() const
Definition: factory.h:135
leftv next
Definition: subexpr.h:86
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55
static BOOLEAN ppCONENORMALS1(leftv res, leftv v)
Definition: bbpolytope.cc:213
int BOOLEAN
Definition: auxiliary.h:85

◆ polytopeViaVertices()

BOOLEAN polytopeViaVertices ( leftv  res,
leftv  args 
)

Definition at line 185 of file bbpolytope.cc.

186 {
187  leftv u = args;
188  if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD)))
189  {
190  if (u->next == NULL)
191  {
192  gfan::initializeCddlibIfRequired();
193  BOOLEAN bo = ppCONERAYS1(res, u);
194  gfan::deinitializeCddlibIfRequired();
195  return bo;
196  }
197  leftv v = u->next;
198  if ((v != NULL) && (v->Typ() == INT_CMD))
199  {
200  if (v->next == NULL)
201  {
202  gfan::initializeCddlibIfRequired();
203  BOOLEAN bo = ppCONERAYS3(res, u, v);
204  gfan::deinitializeCddlibIfRequired();
205  return bo;
206  }
207  }
208  }
209  WerrorS("polytopeViaPoints: unexpected parameters");
210  return TRUE;
211 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
Definition: tok.h:95
static BOOLEAN ppCONERAYS1(leftv res, leftv v)
Definition: bbpolytope.cc:118
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:995
poly res
Definition: myNF.cc:322
Variable next() const
Definition: factory.h:135
leftv next
Definition: subexpr.h:86
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
int BOOLEAN
Definition: auxiliary.h:85
static BOOLEAN ppCONERAYS3(leftv res, leftv u, leftv v)
Definition: bbpolytope.cc:145

◆ ppCONENORMALS1()

static BOOLEAN ppCONENORMALS1 ( leftv  res,
leftv  v 
)
static

Definition at line 213 of file bbpolytope.cc.

214 {
215  /* method for generating a cone object from inequalities;
216  valid parametrizations: (bigintmat) */
217  bigintmat* ineq = NULL;
218  if (v->Typ() == INTMAT_CMD)
219  {
220  intvec* ineq0 = (intvec*) v->Data();
221  ineq = iv2bim(ineq0,coeffs_BIGINT);
222  }
223  else
224  ineq = (bigintmat*) v->Data();
225  gfan::ZMatrix* zm = bigintmatToZMatrix(ineq);
226  gfan::ZCone* zc = new gfan::ZCone(*zm, gfan::ZMatrix(0, zm->getWidth()));
227  delete zm;
228  if (v->Typ() == INTMAT_CMD)
229  delete ineq;
230  res->rtyp = polytopeID;
231  res->data = (void*) zc;
232  return FALSE;
233 }
#define FALSE
Definition: auxiliary.h:94
Matrices of numbers.
Definition: bigintmat.h:51
bigintmat * iv2bim(intvec *b, const coeffs C)
Definition: bigintmat.cc:350
coeffs coeffs_BIGINT
Definition: ipid.cc:54
poly res
Definition: myNF.cc:322
int polytopeID
Definition: bbpolytope.cc:17
Definition: intvec.h:14
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10

◆ ppCONENORMALS2()

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

Definition at line 235 of file bbpolytope.cc.

236 {
237  /* method for generating a cone object from iequalities,
238  and equations (...)
239  valid parametrizations: (bigintmat, bigintmat)
240  Errors will be invoked in the following cases:
241  - u and v have different numbers of columns */
242  bigintmat* ineq = NULL; bigintmat* eq = NULL;
243  if (u->Typ() == INTMAT_CMD)
244  {
245  intvec* ineq0 = (intvec*) u->Data();
246  ineq = iv2bim(ineq0,coeffs_BIGINT);
247  }
248  else
249  ineq = (bigintmat*) u->Data();
250  if (v->Typ() == INTMAT_CMD)
251  {
252  intvec* eq0 = (intvec*) v->Data();
253  eq = iv2bim(eq0,coeffs_BIGINT);
254  }
255  else
256  eq = (bigintmat*) v->Data();
257 
258  if (ineq->cols() != eq->cols())
259  {
260  Werror("expected same number of columns but got %d vs. %d",
261  ineq->cols(), eq->cols());
262  return TRUE;
263  }
264  gfan::ZMatrix* zm1 = bigintmatToZMatrix(ineq);
265  gfan::ZMatrix* zm2 = bigintmatToZMatrix(eq);
266  gfan::ZCone* zc = new gfan::ZCone(*zm1, *zm2);
267  delete zm1;
268  delete zm2;
269  if (u->Typ() == INTMAT_CMD)
270  delete ineq;
271  if (v->Typ() == INTMAT_CMD)
272  delete eq;
273 
274  res->rtyp = polytopeID;
275  res->data = (void*) zc;
276  return FALSE;
277 }
#define FALSE
Definition: auxiliary.h:94
Matrices of numbers.
Definition: bigintmat.h:51
bigintmat * iv2bim(intvec *b, const coeffs C)
Definition: bigintmat.cc:350
#define TRUE
Definition: auxiliary.h:98
coeffs coeffs_BIGINT
Definition: ipid.cc:54
int Typ()
Definition: subexpr.cc:995
poly res
Definition: myNF.cc:322
int polytopeID
Definition: bbpolytope.cc:17
Definition: intvec.h:14
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
int cols() const
Definition: bigintmat.h:145
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
void * Data()
Definition: subexpr.cc:1137
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ ppCONENORMALS3()

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

Definition at line 279 of file bbpolytope.cc.

280 {
281  /* method for generating a cone object from inequalities, equations,
282  and an integer k;
283  valid parametrizations: (bigintmat, bigintmat, int);
284  Errors will be invoked in the following cases:
285  - u and v have different numbers of columns,
286  - k not in [0..3];
287  if the 2^0-bit of k is set, then ... */
288  bigintmat* ineq = NULL; bigintmat* eq = NULL;
289  if (u->Typ() == INTMAT_CMD)
290  {
291  intvec* ineq0 = (intvec*) u->Data();
292  ineq = iv2bim(ineq0,coeffs_BIGINT);
293  }
294  else
295  ineq = (bigintmat*) u->Data();
296  if (v->Typ() == INTMAT_CMD)
297  {
298  intvec* eq0 = (intvec*) v->Data();
299  eq = iv2bim(eq0,coeffs_BIGINT);
300  }
301  else
302  eq = (bigintmat*) v->Data();
303 
304  if (ineq->cols() != eq->cols())
305  {
306  Werror("expected same number of columns but got %d vs. %d",
307  ineq->cols(), eq->cols());
308  return TRUE;
309  }
310  int k = (int)(long)w->Data();
311  if ((k < 0) || (k > 3))
312  {
313  WerrorS("expected int argument in [0..3]");
314  return TRUE;
315  }
316  gfan::ZMatrix* zm1 = bigintmatToZMatrix(ineq);
317  gfan::ZMatrix* zm2 = bigintmatToZMatrix(eq);
318  gfan::ZCone* zc = new gfan::ZCone(*zm1, *zm2, k);
319  delete zm1;
320  delete zm2;
321  if (u->Typ() == INTMAT_CMD)
322  delete ineq;
323  if (v->Typ() == INTMAT_CMD)
324  delete eq;
325 
326  res->rtyp = polytopeID;
327  res->data = (void*) zc;
328  return FALSE;
329 }
#define FALSE
Definition: auxiliary.h:94
Matrices of numbers.
Definition: bigintmat.h:51
bigintmat * iv2bim(intvec *b, const coeffs C)
Definition: bigintmat.cc:350
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
coeffs coeffs_BIGINT
Definition: ipid.cc:54
int Typ()
Definition: subexpr.cc:995
poly res
Definition: myNF.cc:322
int polytopeID
Definition: bbpolytope.cc:17
Definition: intvec.h:14
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
int cols() const
Definition: bigintmat.h:145
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55
void * Data()
Definition: subexpr.cc:1137
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ ppCONERAYS1()

static BOOLEAN ppCONERAYS1 ( leftv  res,
leftv  v 
)
static

Definition at line 118 of file bbpolytope.cc.

119 {
120  /* method for generating a cone object from half-lines
121  (cone = convex hull of the half-lines; note: there may be
122  entire lines in the cone);
123  valid parametrizations: (bigintmat) */
124  bigintmat* rays = NULL;
125  if (v->Typ() == INTMAT_CMD)
126  {
127  intvec* rays0 = (intvec*) v->Data();
128  rays = iv2bim(rays0,coeffs_BIGINT);
129  }
130  else
131  rays = (bigintmat*) v->Data();
132 
133  gfan::ZMatrix* zm = bigintmatToZMatrix(rays);
134  gfan::ZCone* zc = new gfan::ZCone();
135  *zc = gfan::ZCone::givenByRays(*zm, gfan::ZMatrix(0, zm->getWidth()));
136  res->rtyp = polytopeID;
137  res->data = (void*) zc;
138 
139  delete zm;
140  if (v->Typ() == INTMAT_CMD)
141  delete rays;
142  return FALSE;
143 }
#define FALSE
Definition: auxiliary.h:94
Matrices of numbers.
Definition: bigintmat.h:51
bigintmat * iv2bim(intvec *b, const coeffs C)
Definition: bigintmat.cc:350
coeffs coeffs_BIGINT
Definition: ipid.cc:54
poly res
Definition: myNF.cc:322
int polytopeID
Definition: bbpolytope.cc:17
Definition: intvec.h:14
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
BOOLEAN rays(leftv res, leftv args)
Definition: bbcone.cc:663
#define NULL
Definition: omList.c:10

◆ ppCONERAYS3()

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

Definition at line 145 of file bbpolytope.cc.

146 {
147  /* method for generating a cone object from half-lines
148  (any point in the cone being the sum of a point
149  in the convex hull of the half-lines and a point in the span
150  of the lines), and an integer k;
151  valid parametrizations: (bigintmat, int);
152  Errors will be invoked in the following cases:
153  - k not 0 or 1;
154  if the k=1, then the extreme rays are known:
155  each half-line spans a (different) extreme ray */
156  bigintmat* rays = NULL;
157  if (u->Typ() == INTMAT_CMD)
158  {
159  intvec* rays0 = (intvec*) u->Data();
160  rays = iv2bim(rays0,coeffs_BIGINT);
161  }
162  else
163  rays = (bigintmat*) u->Data();
164  int k = (int)(long)v->Data();
165 
166  if ((k < 0) || (k > 1))
167  {
168  WerrorS("expected int argument in [0..1]");
169  return TRUE;
170  }
171  k=k*2;
172  gfan::ZMatrix* zm = bigintmatToZMatrix(rays);
173  gfan::ZCone* zc = new gfan::ZCone();
174  *zc = gfan::ZCone::givenByRays(*zm,gfan::ZMatrix(0, zm->getWidth()));
175  //k should be passed on to zc; not available yet
176  res->rtyp = polytopeID;
177  res->data = (void*) zc;
178 
179  delete zm;
180  if (v->Typ() == INTMAT_CMD)
181  delete rays;
182  return FALSE;
183 }
#define FALSE
Definition: auxiliary.h:94
Matrices of numbers.
Definition: bigintmat.h:51
bigintmat * iv2bim(intvec *b, const coeffs C)
Definition: bigintmat.cc:350
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
coeffs coeffs_BIGINT
Definition: ipid.cc:54
int Typ()
Definition: subexpr.cc:995
poly res
Definition: myNF.cc:322
int polytopeID
Definition: bbpolytope.cc:17
Definition: intvec.h:14
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
BOOLEAN rays(leftv res, leftv args)
Definition: bbcone.cc:663
#define NULL
Definition: omList.c:10
void * Data()
Definition: subexpr.cc:1137

◆ scalePolytope()

BOOLEAN scalePolytope ( leftv  res,
leftv  args 
)

Definition at line 446 of file bbpolytope.cc.

447 {
448  leftv u = args;
449  if ((u != NULL) && (u->Typ() == INT_CMD))
450  {
451  leftv v = u->next;
452  if ((v != NULL) && (v->Typ() == polytopeID))
453  {
454  gfan::initializeCddlibIfRequired();
455  int s = (int)(long) u->Data();
456  gfan::ZCone* zp = (gfan::ZCone*) v->Data();
457  gfan::ZMatrix zm = zp->extremeRays();
458  for (int i=0; i<zm.getHeight(); i++)
459  for (int j=1; j<zm.getWidth(); j++)
460  zm[i][j]*=s;
461  gfan::ZCone* zq = new gfan::ZCone();
462  *zq = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
463  res->rtyp = polytopeID;
464  res->data = (void*) zq;
465  gfan::deinitializeCddlibIfRequired();
466  return FALSE;
467  }
468  }
469  WerrorS("scalePolytope: unexpected parameters");
470  return TRUE;
471 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
Definition: tok.h:95
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:995
poly res
Definition: myNF.cc:322
int polytopeID
Definition: bbpolytope.cc:17
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
leftv next
Definition: subexpr.h:86
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
void * Data()
Definition: subexpr.cc:1137

◆ vertices()

BOOLEAN vertices ( leftv  res,
leftv  args 
)

Definition at line 370 of file bbpolytope.cc.

371 {
372  leftv u = args;
373  if ((u != NULL) && (u->Typ() == polytopeID))
374  {
375  gfan::initializeCddlibIfRequired();
376  gfan::ZCone* zc = (gfan::ZCone*)u->Data();
377  gfan::ZMatrix zmat = zc->extremeRays();
378  res->rtyp = BIGINTMAT_CMD;
379  res->data = (void*)zMatrixToBigintmat(zmat);
380  gfan::deinitializeCddlibIfRequired();
381  return FALSE;
382  }
383  WerrorS("vertices: unexpected parameters");
384  return TRUE;
385 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define FALSE
Definition: auxiliary.h:94
bigintmat * zMatrixToBigintmat(const gfan::ZMatrix &zm)
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:995
poly res
Definition: myNF.cc:322
int polytopeID
Definition: bbpolytope.cc:17
#define NULL
Definition: omList.c:10
void * Data()
Definition: subexpr.cc:1137

Variable Documentation

◆ polytopeID

int polytopeID

Definition at line 17 of file bbpolytope.cc.