#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 <coeffs/numbers.h>
#include <coeffs/bigintmat.h>
#include <misc/intvec.h>
#include <Singular/lists.h>
Go to the source code of this file.
◆ GfInteger2PmInteger()
| polymake::Integer GfInteger2PmInteger |
( |
const gfan::Integer & |
gi | ) |
|
◆ GfQMatrix2PmMatrixRational()
| polymake::Matrix<polymake::Rational> GfQMatrix2PmMatrixRational |
( |
const gfan::QMatrix * |
qm | ) |
|
Definition at line 67 of file polymake_conversion.cc.
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++)
polymake::Rational GfRational2PmRational(const gfan::Rational &gr)
◆ GfRational2PmRational()
| polymake::Rational GfRational2PmRational |
( |
const gfan::Rational & |
gr | ) |
|
◆ GfZMatrix2PmMatrixInteger()
| polymake::Matrix<polymake::Integer> GfZMatrix2PmMatrixInteger |
( |
const gfan::ZMatrix * |
zm | ) |
|
Definition at line 56 of file polymake_conversion.cc.
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++)
polymake::Integer GfInteger2PmInteger(const gfan::Integer &gi)
◆ Intvec2PmMatrixInteger()
| polymake::Matrix<polymake::Integer> Intvec2PmMatrixInteger |
( |
const intvec * |
im | ) |
|
Definition at line 257 of file polymake_conversion.cc.
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));
#define IMATELEM(M, I, J)
◆ Intvec2PmVectorInteger()
| polymake::Vector<polymake::Integer> Intvec2PmVectorInteger |
( |
const intvec * |
iv | ) |
|
◆ PmAdjacencyMatrix2ListOfEdges()
| lists PmAdjacencyMatrix2ListOfEdges |
( |
polymake::IncidenceMatrix< polymake::NonSymmetric > * |
icmat | ) |
|
Definition at line 211 of file polymake_conversion.cc.
213 int rows = icmat->rows();
214 int cols = icmat->cols();
218 for (
r=0;
r<rows;
r++)
220 for (c=0; c<cols; c++)
222 if ((*icmat).row(
r).exists(c) &&
r<c)
231 for (
r=0;
r<rows;
r++)
233 for (c=0; c<cols; c++)
235 if ((*icmat).row(
r).exists(c) &&
r<c)
238 (*iv)[0]=
r; (*iv)[1]=c;
240 L->
m[
i].
data = (
void*) iv;
INLINE_THIS void Init(int l=0)
◆ PmCone2ZCone()
| gfan::ZCone* PmCone2ZCone |
( |
polymake::perl::Object * |
pc | ) |
|
Definition at line 271 of file polymake_conversion.cc.
275 polymake::Integer ambientdim1 = pc->give(
"CONE_AMBIENT_DIM");
276 bool ok=
true;
int ambientdim2 =
PmInteger2Int(ambientdim1, ok);
279 WerrorS(
"PmCone2ZCone: overflow while converting polymake::Integer to int");
281 polymake::Matrix<polymake::Rational> ineqrational = pc->give(
"FACETS");
282 polymake::Matrix<polymake::Rational> eqrational = pc->give(
"LINEAR_SPAN");
286 gfan::ZMatrix zv, zw, zx, zy, zz;
289 if (ineqrational.cols()!=0)
291 polymake::Matrix<polymake::Integer> ineqinteger = polymake::common::primitive(ineqrational);
295 zv = gfan::ZMatrix(0, ambientdim2);
296 if (eqrational.cols()!=0)
298 polymake::Matrix<polymake::Integer> eqinteger = polymake::common::primitive(eqrational);
302 zw = gfan::ZMatrix(0, ambientdim2);
319 gfan::ZCone* zc =
new gfan::ZCone(zv,zw,3);
322 WerrorS(
"PmCone2ZCone: unexpected parameters");
void WerrorS(const char *s)
gfan::ZMatrix PmMatrixInteger2GfZMatrix(const polymake::Matrix< polymake::Integer > *mi)
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.
386 if (pf->isa(
"PolyhedralFan"))
388 int d = (int) pf->give(
"FAN_AMBIENT_DIM");
389 gfan::ZFan* zf =
new gfan::ZFan(d);
391 int n = pf->give(
"N_MAXIMAL_CONES");
392 for (
int i=0;
i<n;
i++)
394 polymake::perl::Object pmcone=pf->CallPolymakeMethod(
"cone",
i);
400 WerrorS(
"PmFan2ZFan: unexpected parameters");
void WerrorS(const char *s)
gfan::ZCone * PmCone2ZCone(polymake::perl::Object *pc)
◆ PmIncidenceMatrix2ListOfIntvecs()
| lists PmIncidenceMatrix2ListOfIntvecs |
( |
polymake::IncidenceMatrix< polymake::NonSymmetric > * |
icmat | ) |
|
Definition at line 188 of file polymake_conversion.cc.
190 int rows = icmat->rows();
191 int cols = icmat->cols();
195 for (
int r = 0;
r < rows;
r++)
198 for (
int c = 0; c < cols; c++)
200 if ((*icmat).row(
r).exists(c))
205 L->
m[
r].
data = (
void*) iv;
void resize(int new_length)
INLINE_THIS void Init(int l=0)
◆ PmInteger2GfInteger()
| gfan::Integer PmInteger2GfInteger |
( |
const polymake::Integer & |
pi | ) |
|
◆ PmInteger2Int()
| int PmInteger2Int |
( |
const polymake::Integer & |
pi, |
|
|
bool & |
ok |
|
) |
| |
◆ PmInteger2Number()
| number PmInteger2Number |
( |
const polymake::Integer & |
pi | ) |
|
Definition at line 133 of file polymake_conversion.cc.
135 mpz_class cache(
pi.get_rep());
137 if(mpz_cmp_si(cache.get_mpz_t(),
m))
139 int temp = (int) mpz_get_si(cache.get_mpz_t());
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
◆ PmMatrixInteger2Bigintmat()
| bigintmat* PmMatrixInteger2Bigintmat |
( |
polymake::Matrix< polymake::Integer > * |
mi | ) |
|
Definition at line 171 of file polymake_conversion.cc.
173 int rows = mi->rows();
174 int cols = mi->cols();
176 pm::array_traits<pm::Integer>::iterator
pi = concat_rows(*mi).begin();
177 for (
int r = 1;
r <= rows;
r++)
178 for (
int c = 1; c <= cols; c++)
number PmInteger2Number(const polymake::Integer &pi)
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]
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
◆ PmMatrixInteger2GfZMatrix()
| gfan::ZMatrix PmMatrixInteger2GfZMatrix |
( |
const polymake::Matrix< polymake::Integer > * |
mi | ) |
|
Definition at line 94 of file polymake_conversion.cc.
98 gfan::ZMatrix zm(rows,cols);
99 for(
int r=1;
r<=rows;
r++)
100 for(
int c=1; c<=cols; c++)
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.
158 int rows = mi->rows();
159 int cols = mi->cols();
161 pm::array_traits<pm::Integer>::iterator
pi = concat_rows(*mi).begin();
162 for (
int r = 1;
r <= rows;
r++)
163 for (
int c = 1; c <= cols; c++)
int PmInteger2Int(const polymake::Integer &pi, bool &ok)
#define IMATELEM(M, I, J)
◆ PmMatrixRational2GfQMatrix()
| gfan::QMatrix PmMatrixRational2GfQMatrix |
( |
const polymake::Matrix< polymake::Rational > * |
mr | ) |
|
Definition at line 105 of file polymake_conversion.cc.
109 gfan::QMatrix qm(rows,cols);
110 for(
int r=1;
r<=rows;
r++)
111 for(
int c=1; c<=cols; c++)
gfan::Rational PmRational2GfRational(const polymake::Rational &pr)
◆ PmPolytope2ZPolytope()
| gfan::ZCone* PmPolytope2ZPolytope |
( |
polymake::perl::Object * |
pp | ) |
|
Definition at line 326 of file polymake_conversion.cc.
328 if (
pp->isa(
"Polytope<Rational>"))
330 polymake::Integer ambientdim1 =
pp->give(
"CONE_AMBIENT_DIM");
331 bool ok=
true;
int ambientdim2 =
PmInteger2Int(ambientdim1, ok);
334 WerrorS(
"overflow while converting polymake::Integer to int");
336 polymake::Matrix<polymake::Rational> ineqrational =
pp->give(
"FACETS");
337 polymake::Matrix<polymake::Rational> eqrational =
pp->give(
"AFFINE_HULL");
341 gfan::ZMatrix zv, zw;
344 if (ineqrational.cols()!=0)
346 polymake::Matrix<polymake::Integer> ineqinteger = polymake::common::primitive(ineqrational);
350 zv = gfan::ZMatrix(0, ambientdim2);
352 if (eqrational.cols()!=0)
354 polymake::Matrix<polymake::Integer> eqinteger = polymake::common::primitive(eqrational);
358 zw = gfan::ZMatrix(0, ambientdim2);
376 gfan::ZCone* zp =
new gfan::ZCone(zv,zw,3);
380 WerrorS(
"PmPolytope2ZPolytope: unexpected parameters");
void WerrorS(const char *s)
gfan::ZMatrix PmMatrixInteger2GfZMatrix(const polymake::Matrix< polymake::Integer > *mi)
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.
89 mpq_class cache(pr.get_rep());
90 gfan::Rational gr(cache.get_mpq_t());
◆ PmSetInteger2Intvec()
| intvec* PmSetInteger2Intvec |
( |
polymake::Set< polymake::Integer > * |
si, |
|
|
bool & |
b |
|
) |
| |
Definition at line 249 of file polymake_conversion.cc.
251 polymake::Vector<polymake::Integer> vi(*si);
intvec * PmVectorInteger2Intvec(const polymake::Vector< polymake::Integer > *vi, bool &ok)
◆ PmVectorInteger2Intvec()
| intvec* PmVectorInteger2Intvec |
( |
const polymake::Vector< polymake::Integer > * |
vi, |
|
|
bool & |
ok |
|
) |
| |
Definition at line 146 of file polymake_conversion.cc.
149 for(
int i=1;
i<=vi->size();
i++)
int PmInteger2Int(const polymake::Integer &pi, bool &ok)
◆ ZCone2PmCone()
| polymake::perl::Object* ZCone2PmCone |
( |
gfan::ZCone * |
zc | ) |
|
Definition at line 404 of file polymake_conversion.cc.
406 polymake::perl::Object* gc =
new polymake::perl::Object(
"Cone<Rational>");
411 gfan::ZMatrix
equations = zc->getEquations();
BOOLEAN inequalities(leftv res, leftv args)
polymake::Matrix< polymake::Integer > GfZMatrix2PmMatrixInteger(const gfan::ZMatrix *zm)
BOOLEAN equations(leftv res, leftv args)
◆ ZFan2PmFan()
| polymake::perl::Object* ZFan2PmFan |
( |
gfan::ZFan * |
zf | ) |
|
Definition at line 511 of file polymake_conversion.cc.
513 polymake::perl::Object* pf =
new polymake::perl::Object(
"PolyhedralFan");
515 polymake::Matrix<polymake::Integer> zm =
raysOf(zf);
516 pf->take(
"RAYS") << zm;
518 polymake::Array<polymake::Set<int> > ar =
conesOf(zf);
519 pf->take(
"MAXIMAL_CONES") << ar;
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.
431 polymake::perl::Object*
pp =
new polymake::perl::Object(
"Polytope<Rational>");
436 gfan::ZMatrix
equations = zc->getEquations();
BOOLEAN inequalities(leftv res, leftv args)
polymake::Matrix< polymake::Integer > GfZMatrix2PmMatrixInteger(const gfan::ZMatrix *zm)
BOOLEAN equations(leftv res, leftv args)