Skip to content

Commit a6beff6

Browse files
author
Winfried Bruns
committed
setDecimalDigits added
1 parent 64bc2a5 commit a6beff6

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

NormalizModule.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,45 @@ static PyObject* NmzSetFaceCodimBound(PyObject* self, PyObject* args)
21312131
FUNC_END
21322132
}
21332133

2134+
static PyObject* NmzSetDecimalDigits(PyObject* self, PyObject* args)
2135+
{
2136+
2137+
FUNC_BEGIN
2138+
2139+
PyObject* cone = PyTuple_GetItem(args, 0);
2140+
2141+
if (!is_cone(cone)) {
2142+
PyErr_SetString(PyNormaliz_cppError, "First argument must be a cone");
2143+
return NULL;
2144+
}
2145+
2146+
PyObject* digits_py = PyTuple_GetItem(args, 1);
2147+
2148+
TempSignalHandler tmpHandler; // use custom signal handler
2149+
2150+
int overflow;
2151+
long digits = PyLong_AsLongLongAndOverflow(digits_py, &overflow);
2152+
if (is_cone_mpz(cone)) {
2153+
Cone< mpz_class >* cone_ptr = get_cone_mpz(cone);
2154+
cone_ptr->setDecimalDigits(digits);
2155+
Py_RETURN_TRUE;
2156+
}
2157+
else if (is_cone_long(cone)) {
2158+
Cone< long long >* cone_ptr = get_cone_long(cone);
2159+
cone_ptr->setDecimalDigits(digits);
2160+
Py_RETURN_TRUE;
2161+
}
2162+
#ifdef ENFNORMALIZ
2163+
else {
2164+
Cone<renf_elem_class>* cone_ptr = get_cone_renf(cone);
2165+
cone_ptr->setDecimalDigits(digits);
2166+
Py_RETURN_TRUE;
2167+
}
2168+
#endif
2169+
2170+
FUNC_END
2171+
}
2172+
21342173
/***************************************************************************
21352174
*
21362175
* Get Symmetrized cone
@@ -2526,7 +2565,9 @@ static PyMethodDef PyNormaliz_cppMethods[] = {
25262565
(PyCFunction)NmzSetNumberOfNormalizThreads, METH_VARARGS,
25272566
"Sets the Normaliz thread limit"},
25282567
{"NmzSetNrCoeffQuasiPol", (PyCFunction)NmzSetNrCoeffQuasiPol,
2529-
METH_VARARGS, "Sets the number of computed coefficients for the quasi-polynomial"},
2568+
METH_VARARGS, "Sets the number of computed coefficients for the quasi-polynomial"},
2569+
{"NmzSetDecimalDigits", (PyCFunction)NmzSetDecimalDigits,
2570+
METH_VARARGS, "Sets the number of decimal digits for fixed precision"},
25302571
{"NmzSetPolynomial", (PyCFunction)NmzSetPolynomial,
25312572
METH_VARARGS, "Sets the polynomial for integration and weighted series"},
25322573
{"NmzSetFaceCodimBound", (PyCFunction)NmzSetFaceCodimBound,

PyNormaliz.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ def SetNrCoeffQuasiPol(self, bound=-1):
387387
def SetFaceCodimBound(self, bound=-1):
388388
return PyNormaliz_cpp.NmzSetFaceCodimBound(self.cone, bound)
389389

390+
def SetDecimalDigits(self, digits=100):
391+
return PyNormaliz_cpp.NmzSetDecimalDigits(self.cone, digits)
392+
390393
def SetPolynomial(self, poly =""):
391394
return PyNormaliz_cpp.NmzSetPolynomial(self.cone, poly)
392395

0 commit comments

Comments
 (0)