My Project  UNKNOWN_GIT_VERSION
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 498 of file polymake_conversion.cc.

499 {
500  int r = numberOfMaximalConesOf(zf);
501 
502  polymake::Matrix<polymake::Integer> pm=raysOf(zf);
503  polymake::Array<polymake::Set<int> > L(r);
504 
505  int ii = 0;
506  for (int d=1; d<=zf->getAmbientDimension(); d++)
507  {
508  for (int i=0; i<zf->numberOfConesOfDimension(d,0,1); i++)
509  {
510  gfan::IntVector v = zf->getConeIndices(d,i,0,1);
511  polymake::Set<int> s;
512  for (int j=0; j<(int)v.size(); j++)
513  {
514  s = s+v[j];
515  }
516  L[ii] = s;
517  ii = ii + 1;
518  }
519  }
520  return L;
521 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int j
Definition: facHensel.cc:105
int numberOfMaximalConesOf(gfan::ZFan *zf)
polymake::Matrix< polymake::Integer > raysOf(gfan::ZFan *zf)
int i
Definition: cfEzgcd.cc:125
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 }
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)

◆ Intvec2PmMatrixInteger()

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

Definition at line 269 of file polymake_conversion.cc.

270 {
271  int rows=im->rows();
272  int cols=im->cols();
273  polymake::Matrix<polymake::Integer> mi(rows,cols);
274  for(int r=0; r<rows; r++)
275  for(int c=0; c<cols; c++)
276  mi(r,c) = polymake::Integer(IMATELEM(*im, r+1, c+1));
277  return mi;
278 }
int rows() const
Definition: intvec.h:94
int cols() const
Definition: intvec.h:93
#define IMATELEM(M, I, J)
Definition: intvec.h:83

◆ 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:125
int length() const
Definition: intvec.h:92

◆ numberOfMaximalConesOf()

int numberOfMaximalConesOf ( gfan::ZFan *  zf)

Definition at line 485 of file polymake_conversion.cc.

486 {
487  int d = zf->getAmbientDimension();
488  int n = 0;
489 
490  for (int i=0; i<=d; i++)
491  {
492  n = n + zf->numberOfConesOfDimension(i,0,1);
493  }
494 
495  return n;
496 }
int i
Definition: cfEzgcd.cc:125

◆ numberOfRaysOf()

int numberOfRaysOf ( gfan::ZFan *  zf)

Definition at line 479 of file polymake_conversion.cc.

480 {
481  int n = zf->numberOfConesOfDimension(1,0,0);
482  return n;
483 }

◆ PmAdjacencyMatrix2ListOfEdges()

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

Definition at line 223 of file polymake_conversion.cc.

224 {
225  int rows = icmat->rows();
226  int cols = icmat->cols();
227 
228  // counting number of edges
229  int i=0; int r, c;
230  for (r=0; r<rows; r++)
231  {
232  for (c=0; c<cols; c++)
233  {
234  if ((*icmat).row(r).exists(c) && r<c)
235  i++;
236  }
237  }
238 
240  L->Init(i);
241 
242  i=0;
243  for (r=0; r<rows; r++)
244  {
245  for (c=0; c<cols; c++)
246  {
247  if ((*icmat).row(r).exists(c) && r<c)
248  {
249  intvec* iv = new intvec(2);
250  (*iv)[0]=r; (*iv)[1]=c;
251  L->m[i].rtyp = INTVEC_CMD;
252  L->m[i].data = (void*) iv;
253  i++;
254  }
255  }
256  }
257 
258  return L;
259 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
sleftv * m
Definition: lists.h:45
Definition: lists.h:22
void * data
Definition: subexpr.h:88
Definition: intvec.h:17
int i
Definition: cfEzgcd.cc:125
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 283 of file polymake_conversion.cc.

284 {
285  if (pc->isa("Cone"))
286  {
287  polymake::Integer ambientdim1 = pc->give("CONE_AMBIENT_DIM");
288  bool ok=true; int ambientdim2 = PmInteger2Int(ambientdim1, ok);
289  if (!ok)
290  {
291  WerrorS("PmCone2ZCone: overflow while converting polymake::Integer to int");
292  }
293  polymake::Matrix<polymake::Rational> ineqrational = pc->give("FACETS");
294  polymake::Matrix<polymake::Rational> eqrational = pc->give("LINEAR_SPAN");
295  // polymake::Matrix<polymake::Rational> exraysrational = pc->give("RAYS");
296  // polymake::Matrix<polymake::Rational> linrational = pc->give("LINEALITY_SPACE");
297 
298  gfan::ZMatrix zv, zw, zx, zy, zz;
299  // the following branching statements are to cover cases in which polymake returns empty matrices
300  // by convention, gfanlib ignores empty matrices, hence zero matrices of right dimensions have to be supplied
301  if (ineqrational.cols()!=0)
302  {
303  polymake::Matrix<polymake::Integer> ineqinteger = polymake::common::primitive(ineqrational);
304  zv = PmMatrixInteger2GfZMatrix(&ineqinteger);
305  }
306  else
307  zv = gfan::ZMatrix(0, ambientdim2);
308  if (eqrational.cols()!=0)
309  {
310  polymake::Matrix<polymake::Integer> eqinteger = polymake::common::primitive(eqrational);
311  zw = PmMatrixInteger2GfZMatrix(&eqinteger);
312  }
313  else
314  zw = gfan::ZMatrix(0, ambientdim2);
315  // if (exraysrational.cols()!=0)
316  // {
317  // polymake::Matrix<polymake::Integer> exraysinteger = polymake::common::primitive(exraysrational);
318  // zx = PmMatrixInteger2GfZMatrix(&exraysinteger);
319  // }
320  // else
321  // zx = gfan::ZMatrix(0, ambientdim2);
322  // if (linrational.cols()!=0)
323  // {
324  // polymake::Matrix<polymake::Integer> lininteger = polymake::common::primitive(linrational);
325  // zy = PmMatrixInteger2GfZMatrix(&lininteger);
326  // }
327  // else
328  // zy = gfan::ZMatrix(0, ambientdim2);
329 
330  // gfan::ZCone* zc = new gfan::ZCone(zv,zw,zx,zy,zz,3);
331  gfan::ZCone* zc = new gfan::ZCone(zv,zw,3);
332  return zc;
333  }
334  WerrorS("PmCone2ZCone: unexpected parameters");
335  return NULL;
336 }
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 396 of file polymake_conversion.cc.

397 {
398  if (pf->isa("PolyhedralFan"))
399  {
400  int d = (int) pf->give("FAN_AMBIENT_DIM");
401  gfan::ZFan* zf = new gfan::ZFan(d);
402 
403  int n = pf->give("N_MAXIMAL_CONES");
404  for (int i=0; i<n; i++)
405  {
406  polymake::perl::Object pmcone=pf->call_method("cone",i);
407  gfan::ZCone* zc=PmCone2ZCone(&pmcone);
408  zf->insert(*zc);
409  }
410  return zf;
411  }
412  WerrorS("PmFan2ZFan: unexpected parameters");
413  return NULL;
414 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
gfan::ZCone * PmCone2ZCone(polymake::perl::Object *pc)
int i
Definition: cfEzgcd.cc:125
#define NULL
Definition: omList.c:10

◆ PmIncidenceMatrix2ListOfIntvecs()

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

Definition at line 200 of file polymake_conversion.cc.

201 {
202  int rows = icmat->rows();
203  int cols = icmat->cols();
205  L->Init(rows);
206 
207  for (int r = 0; r < rows; r++)
208  {
209  intvec* iv = new intvec(cols); int i=0;
210  for (int c = 0; c < cols; c++)
211  {
212  if ((*icmat).row(r).exists(c))
213  { (*iv)[i]=c; i++; }
214  }
215  iv->resize(i);
216  L->m[r].rtyp = INTVEC_CMD;
217  L->m[r].data = (void*) iv;
218  }
219 
220  return L;
221 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
sleftv * m
Definition: lists.h:45
void resize(int new_length)
Definition: intvec.cc:106
Definition: lists.h:22
void * data
Definition: subexpr.h:88
Definition: intvec.h:17
int i
Definition: cfEzgcd.cc:125
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 #if POLYMAKE_VERSION >= 301 /* 3.1 */
124  i=int(pi);
125 #else
126  i = pi.to_int();
127 #endif
128  }
129  catch (const std::exception& ex)
130  {
131  WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
132  ok = false;
133  }
134  return i;
135 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
int i
Definition: cfEzgcd.cc:125
#define pi
Definition: libparse.cc:1143

◆ PmInteger2Number()

number PmInteger2Number ( const polymake::Integer &  pi)

Definition at line 137 of file polymake_conversion.cc.

138 {
139  mpz_class cache(pi.get_rep());
140  long m = 268435456;
141  if(mpz_cmp_si(cache.get_mpz_t(),m))
142  {
143  int temp = (int) mpz_get_si(cache.get_mpz_t());
144  return n_Init(temp,coeffs_BIGINT);
145  }
146  else
147  return n_InitMPZ(cache.get_mpz_t(),coeffs_BIGINT);
148 }
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:538
coeffs coeffs_BIGINT
Definition: ipid.cc:52
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition: coeffs.h:542
int m
Definition: cfEzgcd.cc:121
#define pi
Definition: libparse.cc:1143

◆ PmMatrixInteger2Bigintmat()

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

Definition at line 179 of file polymake_conversion.cc.

180 {
181  int rows = mi->rows();
182  int cols = mi->cols();
183  bigintmat* bim= new bigintmat(rows,cols,coeffs_BIGINT);
184 #if POLYMAKE_VERSION >= 301 /*3.1*/
185  pm::array_traits<pm::Integer>::iterator pi = concat_rows(*mi).begin();
186 #else
187  const polymake::Integer* pi = concat_rows(*mi).begin();
188 #endif
189  for (int r = 1; r <= rows; r++)
190  for (int c = 1; c <= cols; c++)
191  {
192  number temp = PmInteger2Number(*pi);
193  bim->set(r,c,temp);
194  n_Delete(&temp,coeffs_BIGINT);
195  pi++;
196  }
197  return bim;
198 }
number PmInteger2Number(const polymake::Integer &pi)
Matrices of numbers.
Definition: bigintmat.h:51
coeffs coeffs_BIGINT
Definition: ipid.cc:52
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:95
#define pi
Definition: libparse.cc:1143
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455

◆ 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 }
gfan::Integer PmInteger2GfInteger(const polymake::Integer &pi)

◆ PmMatrixInteger2Intvec()

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

Definition at line 160 of file polymake_conversion.cc.

161 {
162  int rows = mi->rows();
163  int cols = mi->cols();
164  intvec* iv = new intvec(rows,cols,0);
165 #if POLYMAKE_VERSION >= 301 /*3.1*/
166  pm::array_traits<pm::Integer>::iterator pi = concat_rows(*mi).begin();
167 #else
168  const polymake::Integer* pi = concat_rows(*mi).begin();
169 #endif
170  for (int r = 1; r <= rows; r++)
171  for (int c = 1; c <= cols; c++)
172  {
173  IMATELEM(*iv,r,c) = PmInteger2Int(*pi, ok);
174  pi++;
175  }
176  return iv;
177 }
Definition: intvec.h:17
#define pi
Definition: libparse.cc:1143
int PmInteger2Int(const polymake::Integer &pi, bool &ok)
#define IMATELEM(M, I, J)
Definition: intvec.h:83

◆ 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)

◆ PmPolytope2ZPolytope()

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

Definition at line 338 of file polymake_conversion.cc.

339 {
340  if (pp->isa("Polytope<Rational>"))
341  {
342  polymake::Integer ambientdim1 = pp->give("CONE_AMBIENT_DIM");
343  bool ok=true; int ambientdim2 = PmInteger2Int(ambientdim1, ok);
344  if (!ok)
345  {
346  WerrorS("overflow while converting polymake::Integer to int");
347  }
348  polymake::Matrix<polymake::Rational> ineqrational = pp->give("FACETS");
349  polymake::Matrix<polymake::Rational> eqrational = pp->give("AFFINE_HULL");
350  // polymake::Matrix<polymake::Rational> vertrational = pp->give("VERTICES");
351  // polymake::Matrix<polymake::Rational> linrational = pp->give("LINEALITY_SPACE");
352 
353  gfan::ZMatrix zv, zw;
354  // the following branching statements are to cover the cases when polymake returns empty matrices
355  // by convention, gfanlib ignores empty matrices, hence zero matrices of right dimensions have to be supplied
356  if (ineqrational.cols()!=0)
357  {
358  polymake::Matrix<polymake::Integer> ineqinteger = polymake::common::primitive(ineqrational);
359  zv = PmMatrixInteger2GfZMatrix(&ineqinteger);
360  }
361  else
362  zv = gfan::ZMatrix(0, ambientdim2);
363 
364  if (eqrational.cols()!=0)
365  {
366  polymake::Matrix<polymake::Integer> eqinteger = polymake::common::primitive(eqrational);
367  zw = PmMatrixInteger2GfZMatrix(&eqinteger);
368  }
369  else
370  zw = gfan::ZMatrix(0, ambientdim2);
371 
372  // if (vertrational.cols()!=0)
373  // {
374  // polymake::Matrix<polymake::Integer> vertinteger = polymake::common::primitive(vertrational);
375  // zx = PmMatrixInteger2GfZMatrix(&vertinteger);
376  // }
377  // else
378  // zx = gfan::ZMatrix(0, ambientdim2);
379  // if (linrational.cols()!=0)
380  // {
381  // polymake::Matrix<polymake::Integer> lininteger = polymake::common::primitive(linrational);
382  // zy = PmMatrixInteger2GfZMatrix(&lininteger);
383  // }
384  // else
385  // zy = gfan::ZMatrix(0, ambientdim2);
386 
387  // gfan::ZCone* zp = new gfan::ZCone(zv,zw,zx,zy,zz,3);
388  gfan::ZCone* zp = new gfan::ZCone(zv,zw,3);
389 
390  return zp;
391  }
392  WerrorS("PmPolytope2ZPolytope: unexpected parameters");
393  return NULL;
394 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
gfan::ZMatrix PmMatrixInteger2GfZMatrix(const polymake::Matrix< polymake::Integer > *mi)
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:248
#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 261 of file polymake_conversion.cc.

262 {
263  polymake::Vector<polymake::Integer> vi(*si);
264  return PmVectorInteger2Intvec(&vi,b);
265 }
CanonicalForm b
Definition: cfModGcd.cc:4044
intvec * PmVectorInteger2Intvec(const polymake::Vector< polymake::Integer > *vi, bool &ok)

◆ PmVectorInteger2Intvec()

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

Definition at line 150 of file polymake_conversion.cc.

151 {
152  intvec* iv = new intvec(vi->size());
153  for(int i=1; i<=vi->size(); i++)
154  {
155  (*iv)[i-1] = PmInteger2Int((*vi)[i-1],ok);
156  }
157  return iv;
158 }
Definition: intvec.h:17
int i
Definition: cfEzgcd.cc:125
int PmInteger2Int(const polymake::Integer &pi, bool &ok)

◆ raysOf()

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

Definition at line 460 of file polymake_conversion.cc.

461 {
462  int d = zf->getAmbientDimension();
463  int n = zf->numberOfConesOfDimension(1,0,0);
464  gfan::ZMatrix zm(n,d);
465 
466  for (int i=0; i<n; i++)
467  {
468  gfan::ZCone zc = zf->getCone(1,i,0,0);
469  gfan::ZMatrix ray = zc.extremeRays();
470  for (int j=0; j<d; j++)
471  {
472  zm[i][j]=ray[0][j];
473  }
474  }
475 
476  return GfZMatrix2PmMatrixInteger(&zm);
477 }
int j
Definition: facHensel.cc:105
int i
Definition: cfEzgcd.cc:125
polymake::Matrix< polymake::Integer > GfZMatrix2PmMatrixInteger(const gfan::ZMatrix *zm)

◆ ZCone2PmCone()

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

Definition at line 416 of file polymake_conversion.cc.

417 {
418  polymake::perl::Object* gc = new polymake::perl::Object("Cone<Rational>");
419 
420  gfan::ZMatrix inequalities = zc->getInequalities();
421  gc->take("FACETS") << GfZMatrix2PmMatrixInteger(&inequalities);
422 
423  gfan::ZMatrix equations = zc->getEquations();
424  gc->take("LINEAR_SPAN") << GfZMatrix2PmMatrixInteger(&equations);
425 
426  // if(zc->areExtremeRaysKnown())
427  // {
428  // gfan::ZMatrix extremeRays = zc->extremeRays();
429  // gc->take("RAYS") << GfZMatrix2PmMatrixInteger(&extremeRays);
430  // }
431 
432  // if(zc->areGeneratorsOfLinealitySpaceKnown())
433  // {
434  // gfan::ZMatrix lineality = zc->generatorsOfLinealitySpace();
435  // gc->take("LINEALITY_SPACE") << GfZMatrix2PmMatrixInteger(&lineality);
436  // }
437 
438  return gc;
439 }
BOOLEAN inequalities(leftv res, leftv args)
Definition: bbcone.cc:560
polymake::Matrix< polymake::Integer > GfZMatrix2PmMatrixInteger(const gfan::ZMatrix *zm)
BOOLEAN equations(leftv res, leftv args)
Definition: bbcone.cc:577

◆ ZFan2PmFan()

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

Definition at line 523 of file polymake_conversion.cc.

524 {
525  polymake::perl::Object* pf = new polymake::perl::Object("PolyhedralFan");
526 
527  polymake::Matrix<polymake::Integer> zm = raysOf(zf);
528  pf->take("RAYS") << zm; // using rays here instead of INPUT_RAYS prevents redundant computations
529 
530  polymake::Array<polymake::Set<int> > ar = conesOf(zf);
531  pf->take("MAXIMAL_CONES") << ar;
532 
533  return pf;
534 }
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 441 of file polymake_conversion.cc.

442 {
443  polymake::perl::Object* pp = new polymake::perl::Object("Polytope<Rational>");
444 
445  gfan::ZMatrix inequalities = zc->getInequalities();
446  pp->take("FACETS") << GfZMatrix2PmMatrixInteger(&inequalities);
447 
448  gfan::ZMatrix equations = zc->getEquations();
449  pp->take("LINEAR_SPAN") << GfZMatrix2PmMatrixInteger(&equations);
450 
451  // if(zc->areExtremeRaysKnown())
452  // {
453  // gfan::ZMatrix vertices = zc->extremeRays();
454  // pp->take("VERTICES") << GfZMatrix2PmMatrixInteger(&vertices);
455  // }
456 
457  return pp;
458 }
BOOLEAN inequalities(leftv res, leftv args)
Definition: bbcone.cc:560
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:248
polymake::Matrix< polymake::Integer > GfZMatrix2PmMatrixInteger(const gfan::ZMatrix *zm)
BOOLEAN equations(leftv res, leftv args)
Definition: bbcone.cc:577