Functions
polymake_conversion.cc File Reference
#include <kernel/mod2.h>
#include <gmpxx.h>
#include <polymake/Main.h>
#include <polymake/Matrix.h>
#include <polymake/Rational.h>
#include <polymake/Integer.h>
#include <polymake/Set.h>
#include <polymake/common/lattice_tools.h>
#include <polymake/IncidenceMatrix.h>
#include <gfanlib/gfanlib.h>
#include <gfanlib/gfanlib_q.h>
#include <misc/intvec.h>
#include <coeffs/numbers.h>
#include <coeffs/bigintmat.h>
#include <Singular/lists.h>
#include <Singular/ipid.h>

Go to the source code of this file.

Functions

polymake::Integer GfInteger2PmInteger (const gfan::Integer &gi)
 
polymake::Rational GfRational2PmRational (const gfan::Rational &gr)
 
polymake::Vector< polymake::Integer > Intvec2PmVectorInteger (const intvec *iv)
 
polymake::Matrix< polymake::Integer > GfZMatrix2PmMatrixInteger (const gfan::ZMatrix *zm)
 
polymake::Matrix< polymake::Rational > GfQMatrix2PmMatrixRational (const gfan::QMatrix *qm)
 
gfan::Integer PmInteger2GfInteger (const polymake::Integer &pi)
 
gfan::Rational PmRational2GfRational (const polymake::Rational &pr)
 
gfan::ZMatrix PmMatrixInteger2GfZMatrix (const polymake::Matrix< polymake::Integer > *mi)
 
gfan::QMatrix PmMatrixRational2GfQMatrix (const polymake::Matrix< polymake::Rational > *mr)
 
int PmInteger2Int (const polymake::Integer &pi, bool &ok)
 
number PmInteger2Number (const polymake::Integer &pi)
 
intvecPmVectorInteger2Intvec (const polymake::Vector< polymake::Integer > *vi, bool &ok)
 
intvecPmMatrixInteger2Intvec (polymake::Matrix< polymake::Integer > *mi, bool &ok)
 
bigintmatPmMatrixInteger2Bigintmat (polymake::Matrix< polymake::Integer > *mi)
 
lists PmIncidenceMatrix2ListOfIntvecs (polymake::IncidenceMatrix< polymake::NonSymmetric > *icmat)
 
lists PmAdjacencyMatrix2ListOfEdges (polymake::IncidenceMatrix< polymake::NonSymmetric > *icmat)
 
intvecPmSetInteger2Intvec (polymake::Set< polymake::Integer > *si, bool &b)
 
polymake::Matrix< polymake::Integer > Intvec2PmMatrixInteger (const intvec *im)
 
gfan::ZCone * PmCone2ZCone (polymake::perl::Object *pc)
 
gfan::ZCone * PmPolytope2ZPolytope (polymake::perl::Object *pp)
 
gfan::ZFan * PmFan2ZFan (polymake::perl::Object *pf)
 
polymake::perl::Object * ZCone2PmCone (gfan::ZCone *zc)
 
polymake::perl::Object * ZPolytope2PmPolytope (gfan::ZCone *zc)
 
polymake::Matrix< polymake::Integer > raysOf (gfan::ZFan *zf)
 
int numberOfRaysOf (gfan::ZFan *zf)
 
int numberOfMaximalConesOf (gfan::ZFan *zf)
 
polymake::Array< polymake::Set< int > > conesOf (gfan::ZFan *zf)
 
polymake::perl::Object * ZFan2PmFan (gfan::ZFan *zf)
 

Function Documentation

◆ conesOf()

polymake::Array<polymake::Set<int> > conesOf ( gfan::ZFan *  zf)

Definition at line 486 of file polymake_conversion.cc.

487 {
488  int r = numberOfMaximalConesOf(zf);
489 
490  polymake::Matrix<polymake::Integer> pm=raysOf(zf);
491  polymake::Array<polymake::Set<int> > L(r);
492 
493  int ii = 0;
494  for (int d=1; d<=zf->getAmbientDimension(); d++)
495  {
496  for (int i=0; i<zf->numberOfConesOfDimension(d,0,1); i++)
497  {
498  gfan::IntVector v = zf->getConeIndices(d,i,0,1);
499  polymake::Set<int> s;
500  for (int j=0; j<(int)v.size(); j++)
501  {
502  s = s+v[j];
503  }
504  L[ii] = s;
505  ii = ii + 1;
506  }
507  }
508  return L;
509 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int numberOfMaximalConesOf(gfan::ZFan *zf)
polymake::Matrix< polymake::Integer > raysOf(gfan::ZFan *zf)
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37

◆ GfInteger2PmInteger()

polymake::Integer GfInteger2PmInteger ( const gfan::Integer &  gi)

Definition at line 30 of file polymake_conversion.cc.

31 {
32  mpz_t cache; mpz_init(cache);
33  gi.setGmp(cache);
34  polymake::Integer pi(cache);
35  return pi;
36 }
#define pi
Definition: libparse.cc:1143

◆ GfQMatrix2PmMatrixRational()

polymake::Matrix<polymake::Rational> GfQMatrix2PmMatrixRational ( const gfan::QMatrix *  qm)

Definition at line 67 of file polymake_conversion.cc.

68 {
69  int rows=qm->getHeight();
70  int cols=qm->getWidth();
71  polymake::Matrix<polymake::Rational> mr(rows,cols);
72  for(int r=1; r<=rows; r++)
73  for(int c=1; c<=cols; c++)
74  mr(r-1,c-1) = GfRational2PmRational((*qm)[r-1][c-1]);
75  return mr;
76 }
const ring r
Definition: syzextra.cc:208
polymake::Rational GfRational2PmRational(const gfan::Rational &gr)

◆ GfRational2PmRational()

polymake::Rational GfRational2PmRational ( const gfan::Rational &  gr)

Definition at line 38 of file polymake_conversion.cc.

39 {
40  mpq_t cache; mpq_init(cache);
41  gr.setGmp(cache);
42  polymake::Rational pr(cache);
43  return pr;
44 }

◆ GfZMatrix2PmMatrixInteger()

polymake::Matrix<polymake::Integer> GfZMatrix2PmMatrixInteger ( const gfan::ZMatrix *  zm)

Definition at line 56 of file polymake_conversion.cc.

57 {
58  int rows=zm->getHeight();
59  int cols=zm->getWidth();
60  polymake::Matrix<polymake::Integer> mi(rows,cols);
61  for(int r=1; r<=rows; r++)
62  for(int c=1; c<=cols; c++)
63  mi(r-1,c-1) = GfInteger2PmInteger((*zm)[r-1][c-1]);
64  return mi;
65 }
polymake::Integer GfInteger2PmInteger(const gfan::Integer &gi)
const ring r
Definition: syzextra.cc:208

◆ Intvec2PmMatrixInteger()

polymake::Matrix<polymake::Integer> Intvec2PmMatrixInteger ( const intvec im)

Definition at line 257 of file polymake_conversion.cc.

258 {
259  int rows=im->rows();
260  int cols=im->cols();
261  polymake::Matrix<polymake::Integer> mi(rows,cols);
262  for(int r=0; r<rows; r++)
263  for(int c=0; c<cols; c++)
264  mi(r,c) = polymake::Integer(IMATELEM(*im, r+1, c+1));
265  return mi;
266 }
int rows() const
Definition: intvec.h:88
const ring r
Definition: syzextra.cc:208
int cols() const
Definition: intvec.h:87
#define IMATELEM(M, I, J)
Definition: intvec.h:77

◆ Intvec2PmVectorInteger()

polymake::Vector<polymake::Integer> Intvec2PmVectorInteger ( const intvec iv)

Definition at line 46 of file polymake_conversion.cc.

47 {
48  polymake::Vector<polymake::Integer> vi(iv->length());
49  for(int i=1; i<=iv->length(); i++)
50  {
51  vi[i-1]=(*iv)[i-1];
52  }
53  return vi;
54 }
int i
Definition: cfEzgcd.cc:123
int length() const
Definition: intvec.h:86

◆ numberOfMaximalConesOf()

int numberOfMaximalConesOf ( gfan::ZFan *  zf)

Definition at line 473 of file polymake_conversion.cc.

474 {
475  int d = zf->getAmbientDimension();
476  int n = 0;
477 
478  for (int i=0; i<=d; i++)
479  {
480  n = n + zf->numberOfConesOfDimension(i,0,1);
481  }
482 
483  return n;
484 }
int i
Definition: cfEzgcd.cc:123

◆ numberOfRaysOf()

int numberOfRaysOf ( gfan::ZFan *  zf)

Definition at line 467 of file polymake_conversion.cc.

468 {
469  int n = zf->numberOfConesOfDimension(1,0,0);
470  return n;
471 }

◆ PmAdjacencyMatrix2ListOfEdges()

lists PmAdjacencyMatrix2ListOfEdges ( polymake::IncidenceMatrix< polymake::NonSymmetric > *  icmat)

Definition at line 211 of file polymake_conversion.cc.

212 {
213  int rows = icmat->rows();
214  int cols = icmat->cols();
215 
216  // counting number of edges
217  int i=0; int r, c;
218  for (r=0; r<rows; r++)
219  {
220  for (c=0; c<cols; c++)
221  {
222  if ((*icmat).row(r).exists(c) && r<c)
223  i++;
224  }
225  }
226 
228  L->Init(i);
229 
230  i=0;
231  for (r=0; r<rows; r++)
232  {
233  for (c=0; c<cols; c++)
234  {
235  if ((*icmat).row(r).exists(c) && r<c)
236  {
237  intvec* iv = new intvec(2);
238  (*iv)[0]=r; (*iv)[1]=c;
239  L->m[i].rtyp = INTVEC_CMD;
240  L->m[i].data = (void*) iv;
241  i++;
242  }
243  }
244  }
245 
246  return L;
247 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
sleftv * m
Definition: lists.h:45
Definition: lists.h:22
void * data
Definition: subexpr.h:88
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:14
int i
Definition: cfEzgcd.cc:123
INLINE_THIS void Init(int l=0)
slists * lists
Definition: mpr_numeric.h:146
int rtyp
Definition: subexpr.h:91
omBin slists_bin
Definition: lists.cc:23

◆ PmCone2ZCone()

gfan::ZCone* PmCone2ZCone ( polymake::perl::Object *  pc)

Definition at line 271 of file polymake_conversion.cc.

272 {
273  if (pc->isa("Cone"))
274  {
275  polymake::Integer ambientdim1 = pc->give("CONE_AMBIENT_DIM");
276  bool ok=true; int ambientdim2 = PmInteger2Int(ambientdim1, ok);
277  if (!ok)
278  {
279  WerrorS("PmCone2ZCone: overflow while converting polymake::Integer to int");
280  }
281  polymake::Matrix<polymake::Rational> ineqrational = pc->give("FACETS");
282  polymake::Matrix<polymake::Rational> eqrational = pc->give("LINEAR_SPAN");
283  // polymake::Matrix<polymake::Rational> exraysrational = pc->give("RAYS");
284  // polymake::Matrix<polymake::Rational> linrational = pc->give("LINEALITY_SPACE");
285 
286  gfan::ZMatrix zv, zw, zx, zy, zz;
287  // the following branching statements are to cover cases in which polymake returns empty matrices
288  // by convention, gfanlib ignores empty matrices, hence zero matrices of right dimensions have to be supplied
289  if (ineqrational.cols()!=0)
290  {
291  polymake::Matrix<polymake::Integer> ineqinteger = polymake::common::primitive(ineqrational);
292  zv = PmMatrixInteger2GfZMatrix(&ineqinteger);
293  }
294  else
295  zv = gfan::ZMatrix(0, ambientdim2);
296  if (eqrational.cols()!=0)
297  {
298  polymake::Matrix<polymake::Integer> eqinteger = polymake::common::primitive(eqrational);
299  zw = PmMatrixInteger2GfZMatrix(&eqinteger);
300  }
301  else
302  zw = gfan::ZMatrix(0, ambientdim2);
303  // if (exraysrational.cols()!=0)
304  // {
305  // polymake::Matrix<polymake::Integer> exraysinteger = polymake::common::primitive(exraysrational);
306  // zx = PmMatrixInteger2GfZMatrix(&exraysinteger);
307  // }
308  // else
309  // zx = gfan::ZMatrix(0, ambientdim2);
310  // if (linrational.cols()!=0)
311  // {
312  // polymake::Matrix<polymake::Integer> lininteger = polymake::common::primitive(linrational);
313  // zy = PmMatrixInteger2GfZMatrix(&lininteger);
314  // }
315  // else
316  // zy = gfan::ZMatrix(0, ambientdim2);
317 
318  // gfan::ZCone* zc = new gfan::ZCone(zv,zw,zx,zy,zz,3);
319  gfan::ZCone* zc = new gfan::ZCone(zv,zw,3);
320  return zc;
321  }
322  WerrorS("PmCone2ZCone: unexpected parameters");
323  return NULL;
324 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
gfan::ZMatrix PmMatrixInteger2GfZMatrix(const polymake::Matrix< polymake::Integer > *mi)
#define NULL
Definition: omList.c:10
int PmInteger2Int(const polymake::Integer &pi, bool &ok)

◆ PmFan2ZFan()

gfan::ZFan* PmFan2ZFan ( polymake::perl::Object *  pf)

Definition at line 384 of file polymake_conversion.cc.

385 {
386  if (pf->isa("PolyhedralFan"))
387  {
388  int d = (int) pf->give("FAN_AMBIENT_DIM");
389  gfan::ZFan* zf = new gfan::ZFan(d);
390 
391  int n = pf->give("N_MAXIMAL_CONES");
392  for (int i=0; i<n; i++)
393  {
394  polymake::perl::Object pmcone=pf->CallPolymakeMethod("cone",i);
395  gfan::ZCone* zc=PmCone2ZCone(&pmcone);
396  zf->insert(*zc);
397  }
398  return zf;
399  }
400  WerrorS("PmFan2ZFan: unexpected parameters");
401  return NULL;
402 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
gfan::ZCone * PmCone2ZCone(polymake::perl::Object *pc)
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10

◆ PmIncidenceMatrix2ListOfIntvecs()

lists PmIncidenceMatrix2ListOfIntvecs ( polymake::IncidenceMatrix< polymake::NonSymmetric > *  icmat)

Definition at line 188 of file polymake_conversion.cc.

189 {
190  int rows = icmat->rows();
191  int cols = icmat->cols();
193  L->Init(rows);
194 
195  for (int r = 0; r < rows; r++)
196  {
197  intvec* iv = new intvec(cols); int i=0;
198  for (int c = 0; c < cols; c++)
199  {
200  if ((*icmat).row(r).exists(c))
201  { (*iv)[i]=c; i++; }
202  }
203  iv->resize(i);
204  L->m[r].rtyp = INTVEC_CMD;
205  L->m[r].data = (void*) iv;
206  }
207 
208  return L;
209 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
sleftv * m
Definition: lists.h:45
void resize(int new_length)
Definition: intvec.cc:107
Definition: lists.h:22
void * data
Definition: subexpr.h:88
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:14
int i
Definition: cfEzgcd.cc:123
INLINE_THIS void Init(int l=0)
slists * lists
Definition: mpr_numeric.h:146
int rtyp
Definition: subexpr.h:91
omBin slists_bin
Definition: lists.cc:23

◆ PmInteger2GfInteger()

gfan::Integer PmInteger2GfInteger ( const polymake::Integer &  pi)

Definition at line 80 of file polymake_conversion.cc.

81 {
82  mpz_class cache(pi.get_rep());
83  gfan::Integer gi(cache.get_mpz_t());
84  return gi;
85 }
#define pi
Definition: libparse.cc:1143

◆ PmInteger2Int()

int PmInteger2Int ( const polymake::Integer &  pi,
bool &  ok 
)

Definition at line 118 of file polymake_conversion.cc.

119 {
120  int i=0;
121  try
122  {
123  i = pi.to_int();
124  }
125  catch (const std::exception& ex)
126  {
127  WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
128  ok = false;
129  }
130  return i;
131 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
int i
Definition: cfEzgcd.cc:123
#define pi
Definition: libparse.cc:1143

◆ PmInteger2Number()

number PmInteger2Number ( const polymake::Integer &  pi)

Definition at line 133 of file polymake_conversion.cc.

134 {
135  mpz_class cache(pi.get_rep());
136  long m = 268435456;
137  if(mpz_cmp_si(cache.get_mpz_t(),m))
138  {
139  int temp = (int) mpz_get_si(cache.get_mpz_t());
140  return n_Init(temp,coeffs_BIGINT);
141  }
142  else
143  return n_InitMPZ(cache.get_mpz_t(),coeffs_BIGINT);
144 }
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
coeffs coeffs_BIGINT
Definition: ipid.cc:54
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition: coeffs.h:546
int m
Definition: cfEzgcd.cc:119
#define pi
Definition: libparse.cc:1143

◆ PmMatrixInteger2Bigintmat()

bigintmat* PmMatrixInteger2Bigintmat ( polymake::Matrix< polymake::Integer > *  mi)

Definition at line 171 of file polymake_conversion.cc.

172 {
173  int rows = mi->rows();
174  int cols = mi->cols();
175  bigintmat* bim= new bigintmat(rows,cols,coeffs_BIGINT);
176  const polymake::Integer* pi = concat_rows(*mi).begin();
177  for (int r = 1; r <= rows; r++)
178  for (int c = 1; c <= cols; c++)
179  {
180  number temp = PmInteger2Number(*pi);
181  bim->set(r,c,temp);
182  n_Delete(&temp,coeffs_BIGINT);
183  pi++;
184  }
185  return bim;
186 }
number PmInteger2Number(const polymake::Integer &pi)
Matrices of numbers.
Definition: bigintmat.h:51
coeffs coeffs_BIGINT
Definition: ipid.cc:54
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition: bigintmat.cc:96
const ring r
Definition: syzextra.cc:208
#define pi
Definition: libparse.cc:1143
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

◆ PmMatrixInteger2GfZMatrix()

gfan::ZMatrix PmMatrixInteger2GfZMatrix ( const polymake::Matrix< polymake::Integer > *  mi)

Definition at line 94 of file polymake_conversion.cc.

95 {
96  int rows=mi->rows();
97  int cols=mi->cols();
98  gfan::ZMatrix zm(rows,cols);
99  for(int r=1; r<=rows; r++)
100  for(int c=1; c<=cols; c++)
101  zm[r-1][c-1] = PmInteger2GfInteger((*mi)(r-1,c-1));
102  return zm;
103 }
const ring r
Definition: syzextra.cc:208
gfan::Integer PmInteger2GfInteger(const polymake::Integer &pi)

◆ PmMatrixInteger2Intvec()

intvec* PmMatrixInteger2Intvec ( polymake::Matrix< polymake::Integer > *  mi,
bool &  ok 
)

Definition at line 156 of file polymake_conversion.cc.

157 {
158  int rows = mi->rows();
159  int cols = mi->cols();
160  intvec* iv = new intvec(rows,cols,0);
161  const polymake::Integer* pi = concat_rows(*mi).begin();
162  for (int r = 1; r <= rows; r++)
163  for (int c = 1; c <= cols; c++)
164  {
165  IMATELEM(*iv,r,c) = PmInteger2Int(*pi, ok);
166  pi++;
167  }
168  return iv;
169 }
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:14
#define pi
Definition: libparse.cc:1143
int PmInteger2Int(const polymake::Integer &pi, bool &ok)
#define IMATELEM(M, I, J)
Definition: intvec.h:77

◆ PmMatrixRational2GfQMatrix()

gfan::QMatrix PmMatrixRational2GfQMatrix ( const polymake::Matrix< polymake::Rational > *  mr)

Definition at line 105 of file polymake_conversion.cc.

106 {
107  int rows=mr->rows();
108  int cols=mr->cols();
109  gfan::QMatrix qm(rows,cols);
110  for(int r=1; r<=rows; r++)
111  for(int c=1; c<=cols; c++)
112  qm[r-1][c-1] = PmRational2GfRational((*mr)(r-1,c-1));
113  return qm;
114 }
gfan::Rational PmRational2GfRational(const polymake::Rational &pr)
const ring r
Definition: syzextra.cc:208

◆ PmPolytope2ZPolytope()

gfan::ZCone* PmPolytope2ZPolytope ( polymake::perl::Object *  pp)

Definition at line 326 of file polymake_conversion.cc.

327 {
328  if (pp->isa("Polytope<Rational>"))
329  {
330  polymake::Integer ambientdim1 = pp->give("CONE_AMBIENT_DIM");
331  bool ok=true; int ambientdim2 = PmInteger2Int(ambientdim1, ok);
332  if (!ok)
333  {
334  WerrorS("overflow while converting polymake::Integer to int");
335  }
336  polymake::Matrix<polymake::Rational> ineqrational = pp->give("FACETS");
337  polymake::Matrix<polymake::Rational> eqrational = pp->give("AFFINE_HULL");
338  // polymake::Matrix<polymake::Rational> vertrational = pp->give("VERTICES");
339  // polymake::Matrix<polymake::Rational> linrational = pp->give("LINEALITY_SPACE");
340 
341  gfan::ZMatrix zv, zw;
342  // the following branching statements are to cover the cases when polymake returns empty matrices
343  // by convention, gfanlib ignores empty matrices, hence zero matrices of right dimensions have to be supplied
344  if (ineqrational.cols()!=0)
345  {
346  polymake::Matrix<polymake::Integer> ineqinteger = polymake::common::primitive(ineqrational);
347  zv = PmMatrixInteger2GfZMatrix(&ineqinteger);
348  }
349  else
350  zv = gfan::ZMatrix(0, ambientdim2);
351 
352  if (eqrational.cols()!=0)
353  {
354  polymake::Matrix<polymake::Integer> eqinteger = polymake::common::primitive(eqrational);
355  zw = PmMatrixInteger2GfZMatrix(&eqinteger);
356  }
357  else
358  zw = gfan::ZMatrix(0, ambientdim2);
359 
360  // if (vertrational.cols()!=0)
361  // {
362  // polymake::Matrix<polymake::Integer> vertinteger = polymake::common::primitive(vertrational);
363  // zx = PmMatrixInteger2GfZMatrix(&vertinteger);
364  // }
365  // else
366  // zx = gfan::ZMatrix(0, ambientdim2);
367  // if (linrational.cols()!=0)
368  // {
369  // polymake::Matrix<polymake::Integer> lininteger = polymake::common::primitive(linrational);
370  // zy = PmMatrixInteger2GfZMatrix(&lininteger);
371  // }
372  // else
373  // zy = gfan::ZMatrix(0, ambientdim2);
374 
375  // gfan::ZCone* zp = new gfan::ZCone(zv,zw,zx,zy,zz,3);
376  gfan::ZCone* zp = new gfan::ZCone(zv,zw,3);
377 
378  return zp;
379  }
380  WerrorS("PmPolytope2ZPolytope: unexpected parameters");
381  return NULL;
382 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
poly pp
Definition: myNF.cc:296
gfan::ZMatrix PmMatrixInteger2GfZMatrix(const polymake::Matrix< polymake::Integer > *mi)
#define NULL
Definition: omList.c:10
int PmInteger2Int(const polymake::Integer &pi, bool &ok)

◆ PmRational2GfRational()

gfan::Rational PmRational2GfRational ( const polymake::Rational &  pr)

Definition at line 87 of file polymake_conversion.cc.

88 {
89  mpq_class cache(pr.get_rep());
90  gfan::Rational gr(cache.get_mpq_t());
91  return gr;
92 }

◆ PmSetInteger2Intvec()

intvec* PmSetInteger2Intvec ( polymake::Set< polymake::Integer > *  si,
bool &  b 
)

Definition at line 249 of file polymake_conversion.cc.

250 {
251  polymake::Vector<polymake::Integer> vi(*si);
252  return PmVectorInteger2Intvec(&vi,b);
253 }
intvec * PmVectorInteger2Intvec(const polymake::Vector< polymake::Integer > *vi, bool &ok)
const poly b
Definition: syzextra.cc:213

◆ PmVectorInteger2Intvec()

intvec* PmVectorInteger2Intvec ( const polymake::Vector< polymake::Integer > *  vi,
bool &  ok 
)

Definition at line 146 of file polymake_conversion.cc.

147 {
148  intvec* iv = new intvec(vi->size());
149  for(int i=1; i<=vi->size(); i++)
150  {
151  (*iv)[i-1] = PmInteger2Int((*vi)[i-1],ok);
152  }
153  return iv;
154 }
Definition: intvec.h:14
int i
Definition: cfEzgcd.cc:123
int PmInteger2Int(const polymake::Integer &pi, bool &ok)

◆ raysOf()

polymake::Matrix<polymake::Integer> raysOf ( gfan::ZFan *  zf)

Definition at line 448 of file polymake_conversion.cc.

449 {
450  int d = zf->getAmbientDimension();
451  int n = zf->numberOfConesOfDimension(1,0,0);
452  gfan::ZMatrix zm(n,d);
453 
454  for (int i=0; i<n; i++)
455  {
456  gfan::ZCone zc = zf->getCone(1,i,0,0);
457  gfan::ZMatrix ray = zc.extremeRays();
458  for (int j=0; j<d; j++)
459  {
460  zm[i][j]=ray[0][j];
461  }
462  }
463 
464  return GfZMatrix2PmMatrixInteger(&zm);
465 }
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
polymake::Matrix< polymake::Integer > GfZMatrix2PmMatrixInteger(const gfan::ZMatrix *zm)

◆ ZCone2PmCone()

polymake::perl::Object* ZCone2PmCone ( gfan::ZCone *  zc)

Definition at line 404 of file polymake_conversion.cc.

405 {
406  polymake::perl::Object* gc = new polymake::perl::Object("Cone<Rational>");
407 
408  gfan::ZMatrix inequalities = zc->getInequalities();
409  gc->take("FACETS") << GfZMatrix2PmMatrixInteger(&inequalities);
410 
411  gfan::ZMatrix equations = zc->getEquations();
412  gc->take("LINEAR_SPAN") << GfZMatrix2PmMatrixInteger(&equations);
413 
414  // if(zc->areExtremeRaysKnown())
415  // {
416  // gfan::ZMatrix extremeRays = zc->extremeRays();
417  // gc->take("RAYS") << GfZMatrix2PmMatrixInteger(&extremeRays);
418  // }
419 
420  // if(zc->areGeneratorsOfLinealitySpaceKnown())
421  // {
422  // gfan::ZMatrix lineality = zc->generatorsOfLinealitySpace();
423  // gc->take("LINEALITY_SPACE") << GfZMatrix2PmMatrixInteger(&lineality);
424  // }
425 
426  return gc;
427 }
BOOLEAN inequalities(leftv res, leftv args)
Definition: bbcone.cc:561
polymake::Matrix< polymake::Integer > GfZMatrix2PmMatrixInteger(const gfan::ZMatrix *zm)
BOOLEAN equations(leftv res, leftv args)
Definition: bbcone.cc:578

◆ ZFan2PmFan()

polymake::perl::Object* ZFan2PmFan ( gfan::ZFan *  zf)

Definition at line 511 of file polymake_conversion.cc.

512 {
513  polymake::perl::Object* pf = new polymake::perl::Object("PolyhedralFan");
514 
515  polymake::Matrix<polymake::Integer> zm = raysOf(zf);
516  pf->take("RAYS") << zm; // using rays here instead of INPUT_RAYS prevents redundant computations
517 
518  polymake::Array<polymake::Set<int> > ar = conesOf(zf);
519  pf->take("MAXIMAL_CONES") << ar;
520 
521  return pf;
522 }
polymake::Array< polymake::Set< int > > conesOf(gfan::ZFan *zf)
polymake::Matrix< polymake::Integer > raysOf(gfan::ZFan *zf)

◆ ZPolytope2PmPolytope()

polymake::perl::Object* ZPolytope2PmPolytope ( gfan::ZCone *  zc)

Definition at line 429 of file polymake_conversion.cc.

430 {
431  polymake::perl::Object* pp = new polymake::perl::Object("Polytope<Rational>");
432 
433  gfan::ZMatrix inequalities = zc->getInequalities();
434  pp->take("FACETS") << GfZMatrix2PmMatrixInteger(&inequalities);
435 
436  gfan::ZMatrix equations = zc->getEquations();
437  pp->take("LINEAR_SPAN") << GfZMatrix2PmMatrixInteger(&equations);
438 
439  // if(zc->areExtremeRaysKnown())
440  // {
441  // gfan::ZMatrix vertices = zc->extremeRays();
442  // pp->take("VERTICES") << GfZMatrix2PmMatrixInteger(&vertices);
443  // }
444 
445  return pp;
446 }
poly pp
Definition: myNF.cc:296
BOOLEAN inequalities(leftv res, leftv args)
Definition: bbcone.cc:561
polymake::Matrix< polymake::Integer > GfZMatrix2PmMatrixInteger(const gfan::ZMatrix *zm)
BOOLEAN equations(leftv res, leftv args)
Definition: bbcone.cc:578