#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 269 of file polymake_conversion.cc.
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));
#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 223 of file polymake_conversion.cc.
225 int rows = icmat->rows();
226 int cols = icmat->cols();
230 for (r=0; r<rows; r++)
232 for (c=0; c<cols; c++)
234 if ((*icmat).row(r).exists(c) && r<c)
243 for (r=0; r<rows; r++)
245 for (c=0; c<cols; c++)
247 if ((*icmat).row(r).exists(c) && r<c)
250 (*iv)[0]=r; (*iv)[1]=c;
252 L->
m[
i].
data = (
void*) iv;
INLINE_THIS void Init(int l=0)
◆ PmCone2ZCone()
gfan::ZCone* PmCone2ZCone |
( |
polymake::perl::Object * |
pc | ) |
|
Definition at line 283 of file polymake_conversion.cc.
287 polymake::Integer ambientdim1 = pc->give(
"CONE_AMBIENT_DIM");
288 bool ok=
true;
int ambientdim2 =
PmInteger2Int(ambientdim1, ok);
291 WerrorS(
"PmCone2ZCone: overflow while converting polymake::Integer to int");
293 polymake::Matrix<polymake::Rational> ineqrational = pc->give(
"FACETS");
294 polymake::Matrix<polymake::Rational> eqrational = pc->give(
"LINEAR_SPAN");
298 gfan::ZMatrix zv, zw, zx, zy, zz;
301 if (ineqrational.cols()!=0)
303 polymake::Matrix<polymake::Integer> ineqinteger = polymake::common::primitive(ineqrational);
307 zv = gfan::ZMatrix(0, ambientdim2);
308 if (eqrational.cols()!=0)
310 polymake::Matrix<polymake::Integer> eqinteger = polymake::common::primitive(eqrational);
314 zw = gfan::ZMatrix(0, ambientdim2);
331 gfan::ZCone* zc =
new gfan::ZCone(zv,zw,3);
334 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 396 of file polymake_conversion.cc.
398 if (pf->isa(
"PolyhedralFan"))
400 int d = (int) pf->give(
"FAN_AMBIENT_DIM");
401 gfan::ZFan* zf =
new gfan::ZFan(d);
403 int n = pf->give(
"N_MAXIMAL_CONES");
404 for (
int i=0;
i<n;
i++)
406 polymake::perl::Object pmcone=pf->CallPolymakeMethod(
"cone",
i);
412 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 200 of file polymake_conversion.cc.
202 int rows = icmat->rows();
203 int cols = icmat->cols();
207 for (
int r = 0; r < rows; r++)
210 for (
int c = 0; c < cols; c++)
212 if ((*icmat).row(r).exists(c))
217 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 |
|
) |
| |
Definition at line 118 of file polymake_conversion.cc.
123 #if POLYMAKE_VERSION >= 301 129 catch (
const std::exception& ex)
void WerrorS(const char *s)
◆ PmInteger2Number()
number PmInteger2Number |
( |
const polymake::Integer & |
pi | ) |
|
Definition at line 137 of file polymake_conversion.cc.
139 mpz_class cache(
pi.get_rep());
141 if(mpz_cmp_si(cache.get_mpz_t(),
m))
143 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 179 of file polymake_conversion.cc.
181 int rows = mi->rows();
182 int cols = mi->cols();
184 #if POLYMAKE_VERSION >= 301 185 pm::array_traits<pm::Integer>::iterator
pi = concat_rows(*mi).begin();
187 const polymake::Integer* pi = concat_rows(*mi).begin();
189 for (
int r = 1; r <= rows; r++)
190 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 160 of file polymake_conversion.cc.
162 int rows = mi->rows();
163 int cols = mi->cols();
165 #if POLYMAKE_VERSION >= 301 166 pm::array_traits<pm::Integer>::iterator
pi = concat_rows(*mi).begin();
168 const polymake::Integer* pi = concat_rows(*mi).begin();
170 for (
int r = 1; r <= rows; r++)
171 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 338 of file polymake_conversion.cc.
340 if (
pp->isa(
"Polytope<Rational>"))
342 polymake::Integer ambientdim1 =
pp->give(
"CONE_AMBIENT_DIM");
343 bool ok=
true;
int ambientdim2 =
PmInteger2Int(ambientdim1, ok);
346 WerrorS(
"overflow while converting polymake::Integer to int");
348 polymake::Matrix<polymake::Rational> ineqrational =
pp->give(
"FACETS");
349 polymake::Matrix<polymake::Rational> eqrational =
pp->give(
"AFFINE_HULL");
353 gfan::ZMatrix zv, zw;
356 if (ineqrational.cols()!=0)
358 polymake::Matrix<polymake::Integer> ineqinteger = polymake::common::primitive(ineqrational);
362 zv = gfan::ZMatrix(0, ambientdim2);
364 if (eqrational.cols()!=0)
366 polymake::Matrix<polymake::Integer> eqinteger = polymake::common::primitive(eqrational);
370 zw = gfan::ZMatrix(0, ambientdim2);
388 gfan::ZCone* zp =
new gfan::ZCone(zv,zw,3);
392 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 261 of file polymake_conversion.cc.
263 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 150 of file polymake_conversion.cc.
153 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 416 of file polymake_conversion.cc.
418 polymake::perl::Object* gc =
new polymake::perl::Object(
"Cone<Rational>");
423 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 523 of file polymake_conversion.cc.
525 polymake::perl::Object* pf =
new polymake::perl::Object(
"PolyhedralFan");
527 polymake::Matrix<polymake::Integer> zm =
raysOf(zf);
528 pf->take(
"RAYS") << zm;
530 polymake::Array<polymake::Set<int> > ar =
conesOf(zf);
531 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 441 of file polymake_conversion.cc.
443 polymake::perl::Object*
pp =
new polymake::perl::Object(
"Polytope<Rational>");
448 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)