Skip to content

Commit 58caef1

Browse files
committed
Towards 2.18
1 parent 2c4db30 commit 58caef1

File tree

3 files changed

+116
-31
lines changed

3 files changed

+116
-31
lines changed

NormalizModule.cpp

Lines changed: 103 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ static PyObject* CallPythonFuncOnOneArg(PyObject* function, PyObject* single_arg
179179
#ifndef NMZ_RELEASE
180180
static_assert(
181181
false,
182-
"Your Normaliz version (unknown) is too old! Update to 3.9.2 or newer.");
182+
"Your Normaliz version (unknown) is too old! Update to 3.10.0 or newer.");
183183
#endif
184-
#if NMZ_RELEASE < 30904
184+
#if NMZ_RELEASE < 31000
185185
static_assert(false,
186-
"Your Normaliz version is too old! Update to 3.9.2 or newer.");
186+
"Your Normaliz version is too old! Update to 3.10.0 or newer.");
187187
#endif
188188

189189
/***************************************************************************
@@ -1101,16 +1101,16 @@ static PyObject* _NmzConeIntern_renf(PyObject* kwargs)
11011101

11021102
static PyObject* _NmzConeFromFile(PyObject* kwargs)
11031103
{
1104-
1104+
11051105
static const char* from_file = "file";
1106-
PyObject* create_from_file = StringToPyUnicode(from_file);
1106+
PyObject* create_from_file = StringToPyUnicode(from_file);
11071107
PyObject* FileName = PyDict_GetItem(kwargs, create_from_file);
11081108
string project(PyUnicodeToString(FileName));
1109-
1109+
11101110
std::string name_in = project + ".in";
11111111
const char* file_in = name_in.c_str();
11121112

1113-
#ifdef ENFNORMALIZ
1113+
#ifdef ENFNORMALIZ
11141114
std::ifstream in;
11151115
in.open(file_in, std::ifstream::in);
11161116
if (!in.is_open()) {
@@ -1129,19 +1129,19 @@ static PyObject* _NmzConeFromFile(PyObject* kwargs)
11291129
}
11301130
}
11311131
in.close();
1132-
1132+
11331133
if(number_field_in_input){
11341134
boost::intrusive_ptr<const renf_class> renf = renf_class::make(poly, var, emb);
11351135
const renf_class* my_renf = renf.get();
11361136
Cone< renf_elem_class >* C = new Cone< renf_elem_class >(project);
11371137
PyObject* return_container = pack_cone(C, my_renf);
11381138
return return_container;
1139-
}
1139+
}
11401140
#endif
11411141

11421142
static const char* string_for_long_long = "CreateAsLongLong";
11431143
PyObject* create_as_long_long = StringToPyUnicode(string_for_long_long);
1144-
1144+
11451145
if (PyDict_Contains(kwargs, create_as_long_long) == 1) {
11461146
Cone< long long >* C = new Cone< long long >(project);
11471147
PyObject* return_container = pack_cone(C);
@@ -1150,7 +1150,7 @@ static PyObject* _NmzConeFromFile(PyObject* kwargs)
11501150
else{
11511151
Cone< mpz_class >* C = new Cone< mpz_class >(project);
11521152
PyObject* return_container = pack_cone(C);
1153-
return return_container;
1153+
return return_container;
11541154
}
11551155
}
11561156

@@ -1174,7 +1174,7 @@ static PyObject* _NmzCone(PyObject* self, PyObject* args, PyObject* kwargs)
11741174
if (kwargs != NULL && PyDict_Contains(kwargs, create_from_file) == 1) {
11751175
return _NmzConeFromFile(kwargs);
11761176
}
1177-
1177+
11781178
static const char* string_for_long = "CreateAsLongLong";
11791179
PyObject* create_as_long_long = StringToPyUnicode(string_for_long);
11801180
#ifdef ENFNORMALIZ
@@ -2172,9 +2172,9 @@ static PyObject* NmzSetPolynomialEquations(PyObject* self, PyObject* args)
21722172
PyErr_SetString(PyNormaliz_cppError, "Second argument must be a list");
21732173
return NULL;
21742174
}
2175-
2175+
21762176
TempSignalHandler tmpHandler1; // use custom signal handler
2177-
2177+
21782178
size_t nr_polys = PySequence_Size(polys_py);
21792179
vector<string> PolyEquations;
21802180
for(size_t i = 0; i < nr_polys; ++i){
@@ -2224,9 +2224,9 @@ static PyObject* NmzSetPolynomialInequalities(PyObject* self, PyObject* args)
22242224
PyErr_SetString(PyNormaliz_cppError, "Second argument must be a list");
22252225
return NULL;
22262226
}
2227-
2227+
22282228
TempSignalHandler tmpHandler1; // use custom signal handler
2229-
2229+
22302230
size_t nr_polys = PySequence_Size(polys_py);
22312231
vector<string> PolyInequalities;
22322232
for(size_t i = 0; i < nr_polys; ++i){
@@ -2253,7 +2253,7 @@ static PyObject* NmzSetPolynomialInequalities(PyObject* self, PyObject* args)
22532253
cone_ptr->setPolynomialInequalities(PolyInequalities);
22542254
Py_RETURN_TRUE;
22552255
#endif
2256-
2256+
22572257
FUNC_END
22582258
}
22592259

@@ -2302,6 +2302,81 @@ static PyObject* NmzSetFaceCodimBound(PyObject* self, PyObject* args)
23022302
FUNC_END
23032303
}
23042304

2305+
static PyObject* NmzSetGBDegreeBound(PyObject* self, PyObject* args)
2306+
{
2307+
2308+
FUNC_BEGIN
2309+
2310+
PyObject* cone = PyTuple_GetItem(args, 0);
2311+
2312+
if (!is_cone(cone)) {
2313+
PyErr_SetString(PyNormaliz_cppError, "First argument must be a cone");
2314+
return NULL;
2315+
}
2316+
2317+
PyObject* bound_py = PyTuple_GetItem(args, 1);
2318+
2319+
TempSignalHandler tmpHandler; // use custom signal handler
2320+
2321+
int overflow;
2322+
long bound = PyLong_AsLongLongAndOverflow(bound_py, &overflow);
2323+
if (is_cone_mpz(cone)) {
2324+
Cone< mpz_class >* cone_ptr = get_cone_mpz(cone);
2325+
cone_ptr->setGBDegreeBound(bound);
2326+
Py_RETURN_TRUE;
2327+
}
2328+
else if (is_cone_long(cone)) {
2329+
Cone< long long >* cone_ptr = get_cone_long(cone);
2330+
cone_ptr->setGBDegreeBound(bound);
2331+
Py_RETURN_TRUE;
2332+
}
2333+
#ifdef ENFNORMALIZ
2334+
else {
2335+
PyErr_SetString(PyNormaliz_cppError, "GB degree bound not defined for algebraic polyhedra");
2336+
return NULL;
2337+
}
2338+
#endif
2339+
2340+
FUNC_END
2341+
}
2342+
2343+
static PyObject* NmzSetGBMinDegree(PyObject* self, PyObject* args)
2344+
{
2345+
2346+
FUNC_BEGIN
2347+
2348+
PyObject* cone = PyTuple_GetItem(args, 0);
2349+
2350+
if (!is_cone(cone)) {
2351+
PyErr_SetString(PyNormaliz_cppError, "First argument must be a cone");
2352+
return NULL;
2353+
}
2354+
2355+
PyObject* bound_py = PyTuple_GetItem(args, 1);
2356+
2357+
TempSignalHandler tmpHandler; // use custom signal handler
2358+
2359+
int overflow;
2360+
long bound = PyLong_AsLongLongAndOverflow(bound_py, &overflow);
2361+
if (is_cone_mpz(cone)) {
2362+
Cone< mpz_class >* cone_ptr = get_cone_mpz(cone);
2363+
cone_ptr->setGBMinDegree(bound);
2364+
Py_RETURN_TRUE;
2365+
}
2366+
else if (is_cone_long(cone)) {
2367+
Cone< long long >* cone_ptr = get_cone_long(cone);
2368+
cone_ptr->setGBMinDegree(bound);
2369+
}
2370+
#ifdef ENFNORMALIZ
2371+
else {
2372+
PyErr_SetString(PyNormaliz_cppError, "GB min degree not defined for algebraic polyhedra");
2373+
return NULL;
2374+
}
2375+
#endif
2376+
2377+
FUNC_END
2378+
}
2379+
23052380
static PyObject* NmzSetDecimalDigits(PyObject* self, PyObject* args)
23062381
{
23072382

@@ -2710,7 +2785,7 @@ static PyObject* NmzGetRenfInfo(PyObject* self, PyObject* args)
27102785
);
27112786
return NULL;
27122787
}
2713-
2788+
27142789
const renf_class* renf = get_cone_renf_renf(cone_py);
27152790
std::string minpoly_str;
27162791
minpoly_str = fmpq_poly_get_str_pretty(renf->get_renf()->nf->pol, renf->gen_name().c_str());
@@ -2741,9 +2816,9 @@ static PyObject* NmzFieldGenName(PyObject* self, PyObject* args)
27412816
return NULL;
27422817
}
27432818
PyObject* cone_py = PyTuple_GetItem(args, 0);
2744-
2819+
27452820
std::string gen_name_string = "";
2746-
2821+
27472822
if (is_cone_mpz(cone_py)) {
27482823
return PyUnicode_FromString(gen_name_string.c_str());
27492824
}
@@ -2755,8 +2830,8 @@ static PyObject* NmzFieldGenName(PyObject* self, PyObject* args)
27552830
Cone< renf_elem_class >* cone_ptr = get_cone_renf(cone_py);
27562831
gen_name_string = cone_ptr->getRenfGenerator();
27572832
return PyUnicode_FromString(gen_name_string.c_str());
2758-
}
2759-
2833+
}
2834+
27602835
#endif
27612836

27622837
return NULL; // to kmake gcc happy
@@ -2831,6 +2906,10 @@ static PyMethodDef PyNormaliz_cppMethods[] = {
28312906
METH_VARARGS, "Sets the polynomial inequalities for lattice points"},
28322907
{"NmzSetFaceCodimBound", (PyCFunction)NmzSetFaceCodimBound,
28332908
METH_VARARGS, "Sets the maximal codimension for the computed faces"},
2909+
{"NmzSetGBDegreeBound", (PyCFunction)NmzSetGBDegreeBound,
2910+
METH_VARARGS, "Sets the maximal degree for binomials in Gröbner and Markov bases"},
2911+
{"NmzSetGBMinDegree", (PyCFunction)NmzSetGBMinDegree,
2912+
METH_VARARGS, "Sets the minimal degree for binomials in Gröbner and Markov bases"},
28342913
{"NmzGetHilbertSeriesExpansion",
28352914
(PyCFunction)NmzGetHilbertSeriesExpansion, METH_VARARGS,
28362915
"Returns expansion of the hilbert series"},
@@ -2854,12 +2933,12 @@ static PyMethodDef PyNormaliz_cppMethods[] = {
28542933
"Prints the Normaliz cone output into a file"},
28552934
{"NmzWritePrecompData", (PyCFunction)NmzWritePrecompData, METH_VARARGS,
28562935
"Prints the Normaliz cone precomputed data for further input"},
2857-
2936+
28582937
{"NmzGetRenfInfo", (PyCFunction)NmzGetRenfInfo, METH_VARARGS,
28592938
"Outputs info of the number field associated to a renf cone"},
28602939
{"NmzFieldGenName", (PyCFunction)NmzFieldGenName, METH_VARARGS,
28612940
"Returns name of field generator"},
2862-
2941+
28632942
{"NmzModifyCone", (PyCFunction)_NmzModify_Outer, METH_VARARGS,
28642943
"Modifies a given input property of a cone using a new matrix"},
28652944
{

PyNormaliz.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def print_quasipol(poly):
296296

297297
class Cone:
298298

299-
def __init__(self,**kwargs):
299+
def __init__(self,**kwargs):
300300
global name_of_indeterminate
301301
pop_list = []
302302
for entry in kwargs.items():
@@ -336,7 +336,7 @@ def __str__(self):
336336

337337
def __repr__(self):
338338
return "<Normaliz Cone>"
339-
339+
340340
def GetFieldGenName(self):
341341
return PyNormaliz_cpp.NmzFieldGenName(self.cone)
342342

@@ -385,15 +385,21 @@ def SetNrCoeffQuasiPol(self, bound=-1):
385385
def SetFaceCodimBound(self, bound=-1):
386386
return PyNormaliz_cpp.NmzSetFaceCodimBound(self.cone, bound)
387387

388+
def SetGBDegreeBound(self, bound=-1):
389+
return PyNormaliz_cpp.NmzSetGBDegreeBound(self.cone, bound)
390+
391+
def SetGBMinDegree(self, bound=-1):
392+
return PyNormaliz_cpp.NmzSetGBGBMinDegree(self.cone, bound)
393+
388394
def SetDecimalDigits(self, digits=100):
389395
return PyNormaliz_cpp.NmzSetDecimalDigits(self.cone, digits)
390396

391397
def SetPolynomial(self, poly =""):
392398
return PyNormaliz_cpp.NmzSetPolynomial(self.cone, poly)
393-
399+
394400
def SetPolynomialEquations(self, polys =[]):
395401
return PyNormaliz_cpp.NmzSetPolynomialEquations(self.cone, polys)
396-
402+
397403
def SetPolynomialInequalities(self, polys =[]):
398404
return PyNormaliz_cpp.NmzSetPolynomialInequalities(self.cone, polys)
399405

setup.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[metadata]
22
name = PyNormaliz
3-
version = 2.17
3+
version = 2.18
44
description = An interface to Normaliz
5-
author = Sebastian Gutsche, Richard Sieg
6-
author_email = [email protected]
5+
author = Sebastian Gutsche, Richard Sieg, Winfried Bruns
6+
author_email = [email protected]
77
long_description = file: README.md
88
long_description_content_type = text/markdown
99
url = https://github.com/Normaliz/PyNormaliz

0 commit comments

Comments
 (0)