[SCM] an open source computer algebra system branch, cleanedupstream, updated. 6125e540ca6d66c307958938a9d53b245507c323
Bernhard R. Link
brlink at debian.org
Tue Apr 24 15:54:21 UTC 2012
The following commit has been merged in the cleanedupstream branch:
commit d29674bf6af1ce41f8bf6a43ffe72fc187c4f269
Author: Yue Ren <ren at mathematik.uni-kl.de>
Date: Fri Mar 16 14:25:50 2012 +0100
chg: header files of callpolymake
diff --git a/callpolymake/polymake_conversion.cc b/callpolymake/polymake_conversion.cc
index 71f23c0..310b881 100644
--- a/callpolymake/polymake_conversion.cc
+++ b/callpolymake/polymake_conversion.cc
@@ -1,30 +1,30 @@
+#include <gmpxx.h>
+
#include <polymake/Main.h>
#include <polymake/Matrix.h>
#include <polymake/Rational.h>
#include <polymake/Integer.h>
-#include <polymake/polytope/lattice_tools.h>
-#include <polymake/perl/macros.h>
#include <polymake/Set.h>
-#include <polymake/IncidenceMatrix.h>
+#include <polymake/common/lattice_tools.h>
+// #include <polymake/perl/macros.h>
+// #include <polymake/IncidenceMatrix.h>
#include <gfanlib/gfanlib.h>
#include <gfanlib/gfanlib_q.h>
-#include <gmpxx.h>
-
#include <kernel/mod2.h>
-#include <kernel/structs.h>
-#include <kernel/febase.h>
+// #include <kernel/structs.h>
+// #include <kernel/febase.h>
#include <kernel/intvec.h>
-#include <callgfanlib/bbcone.h>
-#include <callgfanlib/bbfan.h>
-#include <callgfanlib/bbpolytope.h>
+// #include <callgfanlib/bbcone.h>
+// #include <callgfanlib/bbfan.h>
+// #include <callgfanlib/bbpolytope.h>
-#include <Singular/blackbox.h>
-#include <Singular/ipshell.h>
-#include <Singular/subexpr.h>
-#include <Singular/tok.h>
+// #include <Singular/blackbox.h>
+// #include <Singular/ipshell.h>
+// #include <Singular/subexpr.h>
+// #include <Singular/tok.h>
/* Functions for converting Integers, Rationals and their Matrices
@@ -125,7 +125,7 @@ int PmInteger2Int(const polymake::Integer& pi, bool &ok)
int i;
try
{
- i = (int) pi;
+ i = pi.to_int();
}
catch (const std::exception& ex)
{
@@ -145,7 +145,7 @@ intvec* PmVectorInteger2Intvec (const polymake::Vector<polymake::Integer>* vi, b
return iv;
}
-intvec* PmMatrixInteger2Intvec (polymake::Matrix<polymake::Integer>* mi)
+intvec* PmMatrixInteger2Intvec (polymake::Matrix<polymake::Integer>* mi, bool &ok)
{
int rows = mi->rows();
int cols = mi->cols();
@@ -153,20 +153,23 @@ intvec* PmMatrixInteger2Intvec (polymake::Matrix<polymake::Integer>* mi)
const polymake::Integer* pi = concat_rows(*mi).begin();
for (int r = 1; r <= rows; r++)
for (int c = 1; c <= cols; c++)
- IMATELEM(*iv,r,c) = *pi++;
+ {
+ IMATELEM(*iv,r,c) = PmInteger2Int(*pi, ok);
+ pi++;
+ }
return iv;
}
-intvec* PmIncidenceMatrix2Intvec (polymake::IncidenceMatrix<polymake::NonSymmetric>* icmat)
-{
- int rows = icmat->rows();
- int cols = icmat->cols();
- intvec* iv = new intvec(rows,cols,0);
- for (int r = 1; r <= rows; r++)
- for (int c = 1; c <= cols; c++)
- IMATELEM(*iv,r,c) = (int) (*icmat).row(r).exists(c);
- return iv;
-}
+// intvec* PmIncidenceMatrix2Intvec (polymake::IncidenceMatrix<polymake::NonSymmetric>* icmat)
+// {
+// int rows = icmat->rows();
+// int cols = icmat->cols();
+// intvec* iv = new intvec(rows,cols,0);
+// for (int r = 1; r <= rows; r++)
+// for (int c = 1; c <= cols; c++)
+// IMATELEM(*iv,r,c) = (int) (*icmat).row(r).exists(c);
+// return iv;
+// }
intvec* PmSetInteger2Intvec (polymake::Set<polymake::Integer>* si, bool &b)
{
@@ -210,28 +213,28 @@ gfan::ZCone PmCone2ZCone (polymake::perl::Object* pc)
// by convention, gfanlib ignores empty matrices, hence zero matrices of right dimensions have to be supplied
if (ineqrational.cols()!=0)
{
- polymake::Matrix<polymake::Integer> ineqinteger = polymake::polytope::multiply_by_common_denominator(ineqrational);
+ polymake::Matrix<polymake::Integer> ineqinteger = polymake::common::primitive(ineqrational);
zv = PmMatrixInteger2GfZMatrix(&ineqinteger);
}
else
zv = gfan::ZMatrix(0, ambientdim2);
if (eqrational.cols()!=0)
{
- polymake::Matrix<polymake::Integer> eqinteger = polymake::polytope::multiply_by_common_denominator(eqrational);
+ polymake::Matrix<polymake::Integer> eqinteger = polymake::common::primitive(eqrational);
zw = PmMatrixInteger2GfZMatrix(&eqinteger);
}
else
zw = gfan::ZMatrix(0, ambientdim2);
if (exraysrational.cols()!=0)
{
- polymake::Matrix<polymake::Integer> exraysinteger = polymake::polytope::multiply_by_common_denominator(exraysrational);
+ polymake::Matrix<polymake::Integer> exraysinteger = polymake::common::primitive(exraysrational);
zx = PmMatrixInteger2GfZMatrix(&exraysinteger);
}
else
zx = gfan::ZMatrix(0, ambientdim2);
if (linrational.cols()!=0)
{
- polymake::Matrix<polymake::Integer> lininteger = polymake::polytope::multiply_by_common_denominator(linrational);
+ polymake::Matrix<polymake::Integer> lininteger = polymake::common::primitive(linrational);
zy = PmMatrixInteger2GfZMatrix(&lininteger);
}
else
@@ -265,7 +268,7 @@ gfan::ZCone PmPolytope2ZPolytope (polymake::perl::Object* pp)
// by convention, gfanlib ignores empty matrices, hence zero matrices of right dimensions have to be supplied
if (ineqrational.cols()!=0)
{
- polymake::Matrix<polymake::Integer> ineqinteger = polymake::polytope::multiply_by_common_denominator(ineqrational);
+ polymake::Matrix<polymake::Integer> ineqinteger = polymake::common::primitive(ineqrational);
zv = PmMatrixInteger2GfZMatrix(&ineqinteger);
}
else
@@ -273,7 +276,7 @@ gfan::ZCone PmPolytope2ZPolytope (polymake::perl::Object* pp)
if (eqrational.cols()!=0)
{
- polymake::Matrix<polymake::Integer> eqinteger = polymake::polytope::multiply_by_common_denominator(eqrational);
+ polymake::Matrix<polymake::Integer> eqinteger = polymake::common::primitive(eqrational);
zw = PmMatrixInteger2GfZMatrix(&eqinteger);
}
else
@@ -281,14 +284,14 @@ gfan::ZCone PmPolytope2ZPolytope (polymake::perl::Object* pp)
if (vertrational.cols()!=0)
{
- polymake::Matrix<polymake::Integer> vertinteger = polymake::polytope::multiply_by_common_denominator(vertrational);
+ polymake::Matrix<polymake::Integer> vertinteger = polymake::common::primitive(vertrational);
zx = PmMatrixInteger2GfZMatrix(&vertinteger);
}
else
zx = gfan::ZMatrix(0, ambientdim2);
if (linrational.cols()!=0)
{
- polymake::Matrix<polymake::Integer> lininteger = polymake::polytope::multiply_by_common_denominator(linrational);
+ polymake::Matrix<polymake::Integer> lininteger = polymake::common::primitive(linrational);
zy = PmMatrixInteger2GfZMatrix(&lininteger);
}
else
diff --git a/callpolymake/polymake_conversion.h b/callpolymake/polymake_conversion.h
index 499acc7..e83747c 100644
--- a/callpolymake/polymake_conversion.h
+++ b/callpolymake/polymake_conversion.h
@@ -1,30 +1,30 @@
+#include <gmpxx.h>
+
#include <polymake/Main.h>
#include <polymake/Matrix.h>
#include <polymake/Rational.h>
#include <polymake/Integer.h>
-#include <polymake/polytope/lattice_tools.h>
-#include <polymake/perl/macros.h>
#include <polymake/Set.h>
-#include <polymake/IncidenceMatrix.h>
+#include <polymake/common/lattice_tools.h>
+// #include <polymake/perl/macros.h>
+// #include <polymake/IncidenceMatrix.h>
#include <gfanlib/gfanlib.h>
#include <gfanlib/gfanlib_q.h>
-#include <gmpxx.h>
-
#include <kernel/mod2.h>
-#include <kernel/structs.h>
-#include <kernel/febase.h>
+/* #include <kernel/structs.h> */
+/* #include <kernel/febase.h> */
#include <kernel/intvec.h>
-#include <callgfanlib/bbcone.h>
-#include <callgfanlib/bbfan.h>
-#include <callgfanlib/bbpolytope.h>
+/* #include <callgfanlib/bbcone.h> */
+/* #include <callgfanlib/bbfan.h> */
+/* #include <callgfanlib/bbpolytope.h> */
-#include <Singular/blackbox.h>
-#include <Singular/ipshell.h>
-#include <Singular/subexpr.h>
-#include <Singular/tok.h>
+/* #include <Singular/blackbox.h> */
+/* #include <Singular/ipshell.h> */
+/* #include <Singular/subexpr.h> */
+/* #include <Singular/tok.h> */
/* Functions for converting Integers, Rationals and their Matrices
@@ -49,8 +49,8 @@ gfan::QMatrix PmMatrixRational2GfQMatrix (const polymake::Matrix<polymake::Ratio
int PmInteger2Int(const polymake::Integer& pi, bool &ok);
intvec* PmVectorInteger2Intvec (const polymake::Vector<polymake::Integer>* vi, bool &ok);
-intvec* PmMatrixInteger2Intvec (polymake::Matrix<polymake::Integer>* mi);
-intvec* PmIncidenceMatrix2Intvec (polymake::IncidenceMatrix<polymake::NonSymmetric>* icmat);
+intvec* PmMatrixInteger2Intvec (polymake::Matrix<polymake::Integer>* mi, bool &ok);
+// intvec* PmIncidenceMatrix2Intvec (polymake::IncidenceMatrix<polymake::NonSymmetric>* icmat);
intvec* PmSetInteger2Intvec (polymake::Set<polymake::Integer>* si, bool &b);
/* polymake <- singular */
diff --git a/callpolymake/polymake_wrapper.cc b/callpolymake/polymake_wrapper.cc
index 3fda6f8..db17794 100644
--- a/callpolymake/polymake_wrapper.cc
+++ b/callpolymake/polymake_wrapper.cc
@@ -1,25 +1,23 @@
-// #ifndef HAVE_FANS
-// #define HAVE_FANS
-// #endif
+#include <polymake_conversion.h>
-#include <polymake/Main.h>
-#include <polymake/Matrix.h>
-#include <polymake/Rational.h>
-#include <polymake/Integer.h>
-#include <polymake/polytope/lattice_tools.h>
-#include <polymake/perl/macros.h>
-#include <polymake/Set.h>
-#include <polymake/IncidenceMatrix.h>
+// #include <polymake/Main.h>
+// #include <polymake/Matrix.h>
+// #include <polymake/Rational.h>
+// #include <polymake/Integer.h>
+// #include <polymake/common/lattice_tools.h>
+// #include <polymake/perl/macros.h>
+// #include <polymake/Set.h>
+// #include <polymake/IncidenceMatrix.h>
-#include <gfanlib/gfanlib.h>
-#include <gfanlib/gfanlib_q.h>
+// #include <gfanlib/gfanlib.h>
+// #include <gfanlib/gfanlib_q.h>
-#include <gmpxx.h>
+// #include <gmpxx.h>
-#include <kernel/mod2.h>
-#include <kernel/structs.h>
-#include <kernel/febase.h>
-#include <kernel/intvec.h>
+// #include <kernel/mod2.h>
+// #include <kernel/structs.h>
+// #include <kernel/febase.h>
+// #include <kernel/intvec.h>
#include <callgfanlib/bbcone.h>
#include <callgfanlib/bbfan.h>
@@ -28,9 +26,7 @@
#include <Singular/blackbox.h>
#include <Singular/ipshell.h>
#include <Singular/subexpr.h>
-#include <Singular/tok.h>
-
-#include <polymake_conversion.h>
+// #include <Singular/tok.h>
using namespace polymake;
@@ -701,11 +697,17 @@ BOOLEAN PMfacetVertexLatticeDistances(leftv res, leftv args)
{
gfan::ZCone* zp = (gfan::ZCone*)u->Data();
intvec* ld;
+ bool ok=true;
try
{
polymake::perl::Object p = ZPolytope2PmPolytope(zp);
polymake::Matrix<polymake::Integer> pld = p.give("FACET_VERTEX_LATTICE_DISTANCES");
- ld = PmMatrixInteger2Intvec(&pld);
+ ld = PmMatrixInteger2Intvec(&pld,ok);
+ if (!ok)
+ {
+ WerrorS("overflow while converting polymake::Integer to int");
+ return TRUE;
+ }
}
catch (const std::exception& ex)
{
@@ -810,7 +812,13 @@ BOOLEAN PMlatticePoints(leftv res, leftv args)
{
polymake::perl::Object p = ZPolytope2PmPolytope(zp);
polymake::Matrix<polymake::Integer> lp = p.give("LATTICE_POINTS");
- iv = PmMatrixInteger2Intvec(&lp);
+ bool ok = true;
+ iv = PmMatrixInteger2Intvec(&lp,ok);
+ if (!ok)
+ {
+ WerrorS("overflow while converting polymake::Integer to int");
+ return TRUE;
+ }
}
catch (const std::exception& ex)
{
@@ -870,7 +878,13 @@ BOOLEAN PMinteriorLatticePoints(leftv res, leftv args)
{
polymake::perl::Object p = ZPolytope2PmPolytope(zp);
polymake::Matrix<polymake::Integer> lp = p.give("INTERIOR_LATTICE_POINTS");
- iv = PmMatrixInteger2Intvec(&lp);
+ bool ok = true;
+ iv = PmMatrixInteger2Intvec(&lp,ok);
+ if (!ok)
+ {
+ WerrorS("overflow while converting polymake::Integer to int");
+ return TRUE;
+ }
}
catch (const std::exception& ex)
{
@@ -930,7 +944,13 @@ BOOLEAN PMboundaryLatticePoints(leftv res, leftv args)
{
polymake::perl::Object p = ZPolytope2PmPolytope(zp);
polymake::Matrix<polymake::Integer> lp = p.give("BOUNDARY_LATTICE_POINTS");
- iv = PmMatrixInteger2Intvec(&lp);
+ bool ok = true;
+ iv = PmMatrixInteger2Intvec(&lp,ok);
+ if (!ok)
+ {
+ WerrorS("overflow while converting polymake::Integer to int");
+ return TRUE;
+ }
}
catch (const std::exception& ex)
{
@@ -990,7 +1010,13 @@ BOOLEAN PMhilbertBasis(leftv res, leftv args)
{
polymake::perl::Object p = ZPolytope2PmPolytope(zp);
polymake::Matrix<polymake::Integer> lp = p.give("HILBERT_BASIS");
- iv = PmMatrixInteger2Intvec(&lp);
+ bool ok = true;
+ iv = PmMatrixInteger2Intvec(&lp,ok);
+ if (!ok)
+ {
+ WerrorS("overflow while converting polymake::Integer to int");
+ return TRUE;
+ }
}
catch (const std::exception& ex)
{
@@ -1110,7 +1136,13 @@ BOOLEAN PMmaximalFace(leftv res, leftv args)
p.take("LP") << o;
polymake::Set<polymake::Integer> mf = p.give("LP.MAXIMAL_FACE");
polymake::Matrix<polymake::Integer> rays = raysOf(&p,&mf);
- maxface = new intvec(PmMatrixInteger2Intvec(&rays));
+ bool ok = true;
+ maxface = new intvec(PmMatrixInteger2Intvec(&rays,ok));
+ if (!ok)
+ {
+ WerrorS("overflow while converting polymake::Integer to int");
+ return TRUE;
+ }
}
catch (const std::exception& ex)
{
@@ -1146,7 +1178,13 @@ BOOLEAN PMminimalFace(leftv res, leftv args)
p.take("LP") << o;
polymake::Set<polymake::Integer> mf = p.give("LP.MINIMAL_FACE");
polymake::Matrix<polymake::Integer> rays = raysOf(&p,&mf);
- minface = new intvec(PmMatrixInteger2Intvec(&rays));
+ bool ok = true;
+ minface = new intvec(PmMatrixInteger2Intvec(&rays,ok));
+ if (!ok)
+ {
+ WerrorS("overflow while converting polymake::Integer to int");
+ return TRUE;
+ }
}
catch (const std::exception& ex)
{
--
an open source computer algebra system
More information about the debian-science-commits
mailing list