My Project
Loading...
Searching...
No Matches
Macros | 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.

Macros

#define POLYMAKE_VERSION   POLYMAKEVERSION
 

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)
 

Macro Definition Documentation

◆ POLYMAKE_VERSION

#define POLYMAKE_VERSION   POLYMAKEVERSION

Definition at line 5 of file polymake_conversion.cc.

Function Documentation

◆ conesOf()

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

Definition at line 505 of file polymake_conversion.cc.

506{
507 int r = numberOfMaximalConesOf(zf);
508
509 polymake::Matrix<polymake::Integer> pm=raysOf(zf);
510 polymake::Array<polymake::Set<int> > L(r);
511
512 int ii = 0;
513 for (int d=1; d<=zf->getAmbientDimension(); d++)
514 {
515 for (int i=0; i<zf->numberOfConesOfDimension(d,0,1); i++)
516 {
517 gfan::IntVector v = zf->getConeIndices(d,i,0,1);
518 polymake::Set<int> s;
519 for (int j=0; j<(int)v.size(); j++)
520 {
521 s = s+v[j];
522 }
523 L[ii] = s;
524 ii = ii + 1;
525 }
526 }
527 return L;
528}
int i
Definition: cfEzgcd.cc:132
const CanonicalForm int s
Definition: facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
int j
Definition: facHensel.cc:110
polymake::Matrix< polymake::Integer > raysOf(gfan::ZFan *zf)
int numberOfMaximalConesOf(gfan::ZFan *zf)

◆ GfInteger2PmInteger()

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

Definition at line 33 of file polymake_conversion.cc.

34{
35 mpz_t cache; mpz_init(cache);
36 gi.setGmp(cache);
37 polymake::Integer pi(cache);
38 return pi;
39}
#define pi
Definition: libparse.cc:1145

◆ GfQMatrix2PmMatrixRational()

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

Definition at line 70 of file polymake_conversion.cc.

71{
72 int rows=qm->getHeight();
73 int cols=qm->getWidth();
74 polymake::Matrix<polymake::Rational> mr(rows,cols);
75 for(int r=1; r<=rows; r++)
76 for(int c=1; c<=cols; c++)
77 mr(r-1,c-1) = GfRational2PmRational((*qm)[r-1][c-1]);
78 return mr;
79}
polymake::Rational GfRational2PmRational(const gfan::Rational &gr)

◆ GfRational2PmRational()

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

Definition at line 41 of file polymake_conversion.cc.

42{
43 mpq_t cache; mpq_init(cache);
44 gr.setGmp(cache);
45 polymake::Rational pr(cache);
46 return pr;
47}

◆ GfZMatrix2PmMatrixInteger()

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

Definition at line 59 of file polymake_conversion.cc.

60{
61 int rows=zm->getHeight();
62 int cols=zm->getWidth();
63 polymake::Matrix<polymake::Integer> mi(rows,cols);
64 for(int r=1; r<=rows; r++)
65 for(int c=1; c<=cols; c++)
66 mi(r-1,c-1) = GfInteger2PmInteger((*zm)[r-1][c-1]);
67 return mi;
68}
polymake::Integer GfInteger2PmInteger(const gfan::Integer &gi)

◆ Intvec2PmMatrixInteger()

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

Definition at line 272 of file polymake_conversion.cc.

273{
274 int rows=im->rows();
275 int cols=im->cols();
276 polymake::Matrix<polymake::Integer> mi(rows,cols);
277 for(int r=0; r<rows; r++)
278 for(int c=0; c<cols; c++)
279 mi(r,c) = polymake::Integer(IMATELEM(*im, r+1, c+1));
280 return mi;
281}
int cols() const
Definition: intvec.h:95
int rows() const
Definition: intvec.h:96
#define IMATELEM(M, I, J)
Definition: intvec.h:85

◆ Intvec2PmVectorInteger()

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

Definition at line 49 of file polymake_conversion.cc.

50{
51 polymake::Vector<polymake::Integer> vi(iv->length());
52 for(int i=1; i<=iv->length(); i++)
53 {
54 vi[i-1]=(*iv)[i-1];
55 }
56 return vi;
57}
int length() const
Definition: intvec.h:94

◆ numberOfMaximalConesOf()

int numberOfMaximalConesOf ( gfan::ZFan *  zf)

Definition at line 492 of file polymake_conversion.cc.

493{
494 int d = zf->getAmbientDimension();
495 int n = 0;
496
497 for (int i=0; i<=d; i++)
498 {
499 n = n + zf->numberOfConesOfDimension(i,0,1);
500 }
501
502 return n;
503}

◆ numberOfRaysOf()

int numberOfRaysOf ( gfan::ZFan *  zf)

Definition at line 486 of file polymake_conversion.cc.

487{
488 int n = zf->numberOfConesOfDimension(1,0,0);
489 return n;
490}

◆ PmAdjacencyMatrix2ListOfEdges()

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

Definition at line 226 of file polymake_conversion.cc.

227{
228 int rows = icmat->rows();
229 int cols = icmat->cols();
230
231 // counting number of edges
232 int i=0; int r, c;
233 for (r=0; r<rows; r++)
234 {
235 for (c=0; c<cols; c++)
236 {
237 if ((*icmat).row(r).exists(c) && r<c)
238 i++;
239 }
240 }
241
243 L->Init(i);
244
245 i=0;
246 for (r=0; r<rows; r++)
247 {
248 for (c=0; c<cols; c++)
249 {
250 if ((*icmat).row(r).exists(c) && r<c)
251 {
252 intvec* iv = new intvec(2);
253 (*iv)[0]=r; (*iv)[1]=c;
254 L->m[i].rtyp = INTVEC_CMD;
255 L->m[i].data = (void*) iv;
256 i++;
257 }
258 }
259 }
260
261 return L;
262}
Definition: intvec.h:23
int rtyp
Definition: subexpr.h:91
void * data
Definition: subexpr.h:88
Definition: lists.h:24
sleftv * m
Definition: lists.h:46
INLINE_THIS void Init(int l=0)
VAR omBin slists_bin
Definition: lists.cc:23
slists * lists
Definition: mpr_numeric.h:146
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
@ INTVEC_CMD
Definition: tok.h:101

◆ PmCone2ZCone()

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

Definition at line 286 of file polymake_conversion.cc.

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

◆ PmFan2ZFan()

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

Definition at line 399 of file polymake_conversion.cc.

400{
401 if (pf->isa("PolyhedralFan"))
402 {
403 int d = (int) pf->give("FAN_AMBIENT_DIM");
404 gfan::ZFan* zf = new gfan::ZFan(d);
405
406 int n = pf->give("N_MAXIMAL_CONES");
407 for (int i=0; i<n; i++)
408 {
409 #if (POLYMAKE_VERSION >= 305)
410 polymake::perl::Object pmcone=pf->call_method("cone",i);
411 #else
412 polymake::perl::Object pmcone=pf->CallPolymakeMethod("cone",i);
413 #endif
414 gfan::ZCone* zc=PmCone2ZCone(&pmcone);
415 zf->insert(*zc);
416 }
417 return zf;
418 }
419 WerrorS("PmFan2ZFan: unexpected parameters");
420 return NULL;
421}
gfan::ZCone * PmCone2ZCone(polymake::perl::Object *pc)

◆ PmIncidenceMatrix2ListOfIntvecs()

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

Definition at line 203 of file polymake_conversion.cc.

204{
205 int rows = icmat->rows();
206 int cols = icmat->cols();
208 L->Init(rows);
209
210 for (int r = 0; r < rows; r++)
211 {
212 intvec* iv = new intvec(cols); int i=0;
213 for (int c = 0; c < cols; c++)
214 {
215 if ((*icmat).row(r).exists(c))
216 { (*iv)[i]=c; i++; }
217 }
218 iv->resize(i);
219 L->m[r].rtyp = INTVEC_CMD;
220 L->m[r].data = (void*) iv;
221 }
222
223 return L;
224}
void resize(int new_length)
Definition: intvec.cc:106

◆ PmInteger2GfInteger()

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

Definition at line 83 of file polymake_conversion.cc.

84{
85 mpz_class cache(pi.get_rep());
86 gfan::Integer gi(cache.get_mpz_t());
87 return gi;
88}

◆ PmInteger2Int()

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

Definition at line 121 of file polymake_conversion.cc.

122{
123 int i=0;
124 try
125 {
126#if POLYMAKE_VERSION >= 301 /* 3.1 */
127 i=int(pi);
128#else
129 i = pi.to_int();
130#endif
131 }
132 catch (const std::exception& ex)
133 {
134 WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
135 ok = false;
136 }
137 return i;
138}

◆ PmInteger2Number()

number PmInteger2Number ( const polymake::Integer &  pi)

Definition at line 140 of file polymake_conversion.cc.

141{
142 mpz_class cache(pi.get_rep());
143 long m = 268435456;
144 if(mpz_cmp_si(cache.get_mpz_t(),m))
145 {
146 int temp = (int) mpz_get_si(cache.get_mpz_t());
147 return n_Init(temp,coeffs_BIGINT);
148 }
149 else
150 return n_InitMPZ(cache.get_mpz_t(),coeffs_BIGINT);
151}
int m
Definition: cfEzgcd.cc:128
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition: coeffs.h:539
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:535
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50

◆ PmMatrixInteger2Bigintmat()

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

Definition at line 182 of file polymake_conversion.cc.

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

◆ PmMatrixInteger2GfZMatrix()

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

Definition at line 97 of file polymake_conversion.cc.

98{
99 int rows=mi->rows();
100 int cols=mi->cols();
101 gfan::ZMatrix zm(rows,cols);
102 for(int r=1; r<=rows; r++)
103 for(int c=1; c<=cols; c++)
104 zm[r-1][c-1] = PmInteger2GfInteger((*mi)(r-1,c-1));
105 return zm;
106}
gfan::Integer PmInteger2GfInteger(const polymake::Integer &pi)

◆ PmMatrixInteger2Intvec()

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

Definition at line 163 of file polymake_conversion.cc.

164{
165 int rows = mi->rows();
166 int cols = mi->cols();
167 intvec* iv = new intvec(rows,cols,0);
168#if POLYMAKE_VERSION >= 301 /*3.1*/
169 pm::array_traits<pm::Integer>::iterator pi = concat_rows(*mi).begin();
170#else
171 const polymake::Integer* pi = concat_rows(*mi).begin();
172#endif
173 for (int r = 1; r <= rows; r++)
174 for (int c = 1; c <= cols; c++)
175 {
176 IMATELEM(*iv,r,c) = PmInteger2Int(*pi, ok);
177 pi++;
178 }
179 return iv;
180}

◆ PmMatrixRational2GfQMatrix()

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

Definition at line 108 of file polymake_conversion.cc.

109{
110 int rows=mr->rows();
111 int cols=mr->cols();
112 gfan::QMatrix qm(rows,cols);
113 for(int r=1; r<=rows; r++)
114 for(int c=1; c<=cols; c++)
115 qm[r-1][c-1] = PmRational2GfRational((*mr)(r-1,c-1));
116 return qm;
117}
gfan::Rational PmRational2GfRational(const polymake::Rational &pr)

◆ PmPolytope2ZPolytope()

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

Definition at line 341 of file polymake_conversion.cc.

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

◆ PmRational2GfRational()

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

Definition at line 90 of file polymake_conversion.cc.

91{
92 mpq_class cache(pr.get_rep());
93 gfan::Rational gr(cache.get_mpq_t());
94 return gr;
95}

◆ PmSetInteger2Intvec()

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

Definition at line 264 of file polymake_conversion.cc.

265{
266 polymake::Vector<polymake::Integer> vi(*si);
267 return PmVectorInteger2Intvec(&vi,b);
268}
CanonicalForm b
Definition: cfModGcd.cc:4103
intvec * PmVectorInteger2Intvec(const polymake::Vector< polymake::Integer > *vi, bool &ok)

◆ PmVectorInteger2Intvec()

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

Definition at line 153 of file polymake_conversion.cc.

154{
155 intvec* iv = new intvec(vi->size());
156 for(int i=1; i<=vi->size(); i++)
157 {
158 (*iv)[i-1] = PmInteger2Int((*vi)[i-1],ok);
159 }
160 return iv;
161}

◆ raysOf()

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

Definition at line 467 of file polymake_conversion.cc.

468{
469 int d = zf->getAmbientDimension();
470 int n = zf->numberOfConesOfDimension(1,0,0);
471 gfan::ZMatrix zm(n,d);
472
473 for (int i=0; i<n; i++)
474 {
475 gfan::ZCone zc = zf->getCone(1,i,0,0);
476 gfan::ZMatrix ray = zc.extremeRays();
477 for (int j=0; j<d; j++)
478 {
479 zm[i][j]=ray[0][j];
480 }
481 }
482
483 return GfZMatrix2PmMatrixInteger(&zm);
484}
polymake::Matrix< polymake::Integer > GfZMatrix2PmMatrixInteger(const gfan::ZMatrix *zm)

◆ ZCone2PmCone()

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

Definition at line 423 of file polymake_conversion.cc.

424{
425 polymake::perl::Object* gc = new polymake::perl::Object("Cone<Rational>");
426
427 gfan::ZMatrix inequalities = zc->getInequalities();
428 gc->take("FACETS") << GfZMatrix2PmMatrixInteger(&inequalities);
429
430 gfan::ZMatrix equations = zc->getEquations();
431 gc->take("LINEAR_SPAN") << GfZMatrix2PmMatrixInteger(&equations);
432
433 // if(zc->areExtremeRaysKnown())
434 // {
435 // gfan::ZMatrix extremeRays = zc->extremeRays();
436 // gc->take("RAYS") << GfZMatrix2PmMatrixInteger(&extremeRays);
437 // }
438
439 // if(zc->areGeneratorsOfLinealitySpaceKnown())
440 // {
441 // gfan::ZMatrix lineality = zc->generatorsOfLinealitySpace();
442 // gc->take("LINEALITY_SPACE") << GfZMatrix2PmMatrixInteger(&lineality);
443 // }
444
445 return gc;
446}
BOOLEAN equations(leftv res, leftv args)
Definition: bbcone.cc:577
BOOLEAN inequalities(leftv res, leftv args)
Definition: bbcone.cc:560

◆ ZFan2PmFan()

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

Definition at line 530 of file polymake_conversion.cc.

531{
532 polymake::perl::Object* pf = new polymake::perl::Object("PolyhedralFan");
533
534 polymake::Matrix<polymake::Integer> zm = raysOf(zf);
535 pf->take("RAYS") << zm; // using rays here instead of INPUT_RAYS prevents redundant computations
536
537 polymake::Array<polymake::Set<int> > ar = conesOf(zf);
538 pf->take("MAXIMAL_CONES") << ar;
539
540 return pf;
541}
polymake::Array< polymake::Set< int > > conesOf(gfan::ZFan *zf)

◆ ZPolytope2PmPolytope()

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

Definition at line 448 of file polymake_conversion.cc.

449{
450 polymake::perl::Object* pp = new polymake::perl::Object("Polytope<Rational>");
451
452 gfan::ZMatrix inequalities = zc->getInequalities();
453 pp->take("FACETS") << GfZMatrix2PmMatrixInteger(&inequalities);
454
455 gfan::ZMatrix equations = zc->getEquations();
456 pp->take("LINEAR_SPAN") << GfZMatrix2PmMatrixInteger(&equations);
457
458 // if(zc->areExtremeRaysKnown())
459 // {
460 // gfan::ZMatrix vertices = zc->extremeRays();
461 // pp->take("VERTICES") << GfZMatrix2PmMatrixInteger(&vertices);
462 // }
463
464 return pp;
465}