Skip to content

Commit 03ee816

Browse files
author
Winfried Bruns
committed
Merge branch 'master' into new_e-antic
# Conflicts: //SOLVED # NormalizModule.cpp
2 parents 8eefa22 + 64bc2a5 commit 03ee816

File tree

10 files changed

+114
-50
lines changed

10 files changed

+114
-50
lines changed

.ci-install-normaliz.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fi
2424

2525
[ "$COCOALIB" == "yes" ] && ./install_scripts_opt/install_nmz_cocoa.sh && echo "cocoalib complete!"
2626
[ "$FLINT" == "yes" ] && ./install_scripts_opt/install_nmz_flint.sh && echo "flint complete!"
27+
[ "$EANTIC" == "yes" ] && ./install_scripts_opt/install_nmz_flint.sh && echo "flint complete!"
2728
[ "$EANTIC" == "yes" ] && ./install_scripts_opt/install_nmz_arb.sh && echo "arb complete!"
2829
[ "$EANTIC" == "yes" ] && ./install_scripts_opt/install_nmz_e-antic.sh && echo "e-antic complete!"
2930
[ "$NAUTY" == "yes" ] && ./install_scripts_opt/install_nmz_nauty.sh && echo "nauty complete!"

.github/workflows/ci.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ jobs:
1515
- uses: actions/checkout@v2
1616
- name: "Install prerequisites and Normaliz"
1717
run: |
18-
sudo apt-get install libgmp-dev libflint-dev
19-
pip install coverage
20-
pip3 install coverage
21-
pip install setuptools
18+
sudo apt-get install libgmp-dev
19+
sudo apt-get install libpython2-dev
20+
sudo apt-get install libpython3-dev
21+
# pip2 install coverage
22+
# pip3 install coverage
23+
# pip install setuptools
24+
sudo apt-get install python-setuptools
2225
pip3 install setuptools
2326
./.ci-install-normaliz.sh
2427
- name: "Install PyNormaliz"
@@ -38,10 +41,13 @@ jobs:
3841
- uses: actions/checkout@v2
3942
- name: "Install prerequisites and Normaliz"
4043
run: |
41-
sudo apt-get install libgmp-dev
42-
pip install coverage
43-
pip3 install coverage
44-
pip install setuptools
44+
sudo apt-get install libgmp-dev
45+
sudo apt-get install libpython2-dev
46+
sudo apt-get install libpython3-dev
47+
# pip2 install coverage
48+
# pip3 install coverage
49+
# pip install setuptools
50+
sudo apt-get install python-setuptools
4551
pip3 install setuptools
4652
./.ci-install-normaliz.sh
4753
- name: "Install PyNormaliz"

NormalizModule.cpp

Lines changed: 62 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ static PyObject* CallPythonFuncOnOneArg(PyObject* function, PyObject* single_arg
177177
#ifndef NMZ_RELEASE
178178
static_assert(
179179
false,
180-
"Your Normaliz version (unknown) is to old! Update to 3.8.10 or newer.");
180+
"Your Normaliz version (unknown) is to old! Update to 3.9.0 or newer.");
181181
#endif
182-
#if NMZ_RELEASE < 30810
182+
#if NMZ_RELEASE < 30900
183183
static_assert(false,
184-
"Your Normaliz version is to old! Update to 3.8.10 or newer.");
184+
"Your Normaliz version is to old! Update to 3.9.0 or newer.");
185185
#endif
186186

187187
/***************************************************************************
@@ -473,10 +473,11 @@ static bool prepare_nf_input(vector< vector< NumberFieldElem > >& out,
473473
if (!current_res) {
474474
return false;
475475
}
476-
current_elem = renf_elem_class(nf->shared_from_this(),current_vector);
476+
current_elem = NumberFieldElem(*nf, current_vector);
477477
}
478478
if (string_check(current_element)) {
479-
current_elem =renf_elem_class(nf->shared_from_this(),PyUnicodeToString(current_element));
479+
current_elem = NumberFieldElem(*nf);
480+
current_elem = PyUnicodeToString(current_element);
480481
}
481482
if (PyFloat_Check(current_element)){
482483
throw PyNormalizInputException("Nonintegral numbers must be given as strings");
@@ -713,27 +714,60 @@ template < typename Integer >
713714
static PyObject*
714715
NmzAutomorphismsToPython(const AutomorphismGroup< Integer >& grp)
715716
{
717+
int list_size = 6;
718+
if(grp.IsInput() || grp.IsAmbient())
719+
list_size =7;
716720

717-
PyObject* list = PyList_New(4);
721+
PyObject* list = PyList_New(list_size);
718722

719723
PyList_SetItem(list, 0, NmzToPyNumber(grp.getOrder()));
724+
PyList_SetItem(list, 1, BoolToPyBool(grp.IsIntegralityChecked()));
725+
PyList_SetItem(list, 2, BoolToPyBool(grp.IsIntegral()));
726+
727+
if(grp.IsInput() || grp.IsAmbient()){
728+
PyList_SetItem(list, 6, NmzMatrixToPyList(grp.getGens().get_elements()));
729+
PyObject* current = PyList_New(2);
730+
PyList_SetItem(current, 0, NmzMatrixToPyList(grp.getGensPerms()));
731+
PyList_SetItem(current, 1, NmzMatrixToPyList(grp.getGensOrbits()));
732+
PyList_SetItem(list, 3, current);
733+
734+
current = PyList_New(2);
735+
vector<vector<long> > Empty;
736+
PyList_SetItem(current, 0, NmzMatrixToPyList(Empty));
737+
PyList_SetItem(current, 1, NmzMatrixToPyList(Empty));
738+
PyList_SetItem(list, 4, current);
739+
740+
if(grp.IsAmbient()){
741+
current = PyList_New(2);
742+
PyList_SetItem(current, 0, NmzMatrixToPyList(grp.getLinFormsPerms()));
743+
PyList_SetItem(current, 1, NmzMatrixToPyList(grp.getLinFormsOrbits()));
744+
PyList_SetItem(list, 5, current);
745+
}
746+
else{
747+
vector<vector<long> > Empty;
748+
PyList_SetItem(current, 0, NmzMatrixToPyList(Empty));
749+
PyList_SetItem(current, 1, NmzMatrixToPyList(Empty));
750+
PyList_SetItem(list, 5, current);
751+
}
752+
}
753+
else{
754+
PyObject* current = PyList_New(2);
755+
PyList_SetItem(current, 0, NmzMatrixToPyList(grp.getExtremeRaysPerms()));
756+
PyList_SetItem(current, 1, NmzMatrixToPyList(grp.getExtremeRaysOrbits()));
757+
PyList_SetItem(list, 3, current);
720758

721-
PyObject* current = PyList_New(2);
722-
PyList_SetItem(current, 0, NmzMatrixToPyList(grp.getExtremeRaysPerms()));
723-
PyList_SetItem(current, 1, NmzMatrixToPyList(grp.getExtremeRaysOrbits()));
724-
PyList_SetItem(list, 1, current);
725-
726-
current = PyList_New(2);
727-
PyList_SetItem(current, 0, NmzMatrixToPyList(grp.getVerticesPerms()));
728-
PyList_SetItem(current, 1, NmzMatrixToPyList(grp.getVerticesOrbits()));
729-
PyList_SetItem(list, 2, current);
759+
current = PyList_New(2);
760+
PyList_SetItem(current, 0, NmzMatrixToPyList(grp.getVerticesPerms()));
761+
PyList_SetItem(current, 1, NmzMatrixToPyList(grp.getVerticesOrbits()));
762+
PyList_SetItem(list, 4, current);
730763

731-
current = PyList_New(2);
732-
PyList_SetItem(current, 0,
733-
NmzMatrixToPyList(grp.getSupportHyperplanesPerms()));
734-
PyList_SetItem(current, 1,
735-
NmzMatrixToPyList(grp.getSupportHyperplanesOrbits()));
736-
PyList_SetItem(list, 3, current);
764+
current = PyList_New(2);
765+
PyList_SetItem(current, 0,
766+
NmzMatrixToPyList(grp.getSupportHyperplanesPerms()));
767+
PyList_SetItem(current, 1,
768+
NmzMatrixToPyList(grp.getSupportHyperplanesOrbits()));
769+
PyList_SetItem(list, 5, current);
770+
}
737771

738772
return list;
739773
}
@@ -1012,6 +1046,7 @@ static PyObject* _NmzConeIntern_renf(PyObject* kwargs)
10121046
}
10131047

10141048

1049+
renf_class* renf;
10151050
// number_field_data contains 3 entries: poly, var, emb
10161051
// All are strings
10171052
string poly = PyUnicodeToString(PySequence_GetItem(number_field_data, 0));
@@ -1041,7 +1076,7 @@ static PyObject* _NmzConeIntern_renf(PyObject* kwargs)
10411076
continue;
10421077
vector< vector< renf_elem_class > > Mat;
10431078
try {
1044-
prepare_nf_input(Mat, current_value, my_renf);
1079+
prepare_nf_input(Mat, current_value, renf);
10451080
}
10461081
catch (PyNormalizInputException& e) {
10471082
PyErr_SetString(PyNormaliz_cppError,
@@ -1730,6 +1765,10 @@ _NmzResultImpl(Cone< Integer >* C, PyObject* prop_obj, const void* nf = nullptr)
17301765
case libnormaliz::ConeProperty::AmbientAutomorphisms:
17311766
return NmzAutomorphismsToPython(C->getAutomorphismGroup(
17321767
libnormaliz::ConeProperty::AmbientAutomorphisms));
1768+
1769+
case libnormaliz::ConeProperty::InputAutomorphisms:
1770+
return NmzAutomorphismsToPython(C->getAutomorphismGroup(
1771+
libnormaliz::ConeProperty::InputAutomorphisms));
17331772

17341773
case libnormaliz::ConeProperty::CombinatorialAutomorphisms:
17351774
return NmzAutomorphismsToPython(C->getAutomorphismGroup(
@@ -2427,7 +2466,7 @@ static PyObject* NmzGetRenfInfo(PyObject* self, PyObject* args)
24272466
}
24282467
const renf_class* renf = get_cone_renf_renf(cone_py);
24292468
std::string minpoly_str;
2430-
minpoly_str = fmpq_poly_get_str_pretty(renf->get_renf()->nf->pol, renf->gen_name().c_str());
2469+
minpoly_str = fmpq_poly_get_str_pretty(renf->get_renf()->nf->pol, renf->gen_name.c_str());
24312470
std::string res1 = arb_get_str(renf->get_renf()->emb, 64, 0);
24322471
// long prec = renf->get_renf()->prec;
24332472
return PyTuple_Pack(2, StringToPyUnicode(minpoly_str), StringToPyUnicode(res1));

PyNormaliz.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,31 @@ def print_perms_and_orbits(data, name):
2727

2828
def print_automs(Automs):
2929
print("order ", Automs[0])
30-
if len(Automs[1][0]) >0:
31-
print_perms_and_orbits(Automs[1],"extreme rays of (recession) cone")
32-
if len(Automs[2][0]) >0:
33-
print_perms_and_orbits(Automs[2],"vertices of polyhedron")
30+
if Automs[1]:
31+
if Automs[2]:
32+
print("automorphisms are integral")
33+
else:
34+
print("automorphisms are not integral")
35+
else:
36+
print("integrality of automorphisms unknown")
37+
38+
gen_name ="extreme rays of (recession) cone"
39+
if len(Automs) == 7:
40+
gen_name = "input vectors";
41+
lf_name = "support hyperplanes"
42+
if len(Automs) == 7:
43+
lf_name = "coordinates"
44+
3445
if len(Automs[3][0]) >0:
35-
print_perms_and_orbits(Automs[3],"support hyperplanes")
46+
print_perms_and_orbits(Automs[3],gen_name)
47+
if len(Automs[4][0]) >0:
48+
print_perms_and_orbits(Automs[4],"vertices of polyhedron")
49+
if len(Automs[5][0]) >0:
50+
print_perms_and_orbits(Automs[5],lf_name)
51+
52+
if len(Automs) == 7:
53+
print("input vectors")
54+
print_matrix(Automs[6])
3655
return
3756

3857
def print_Stanley_dec(dec):
@@ -207,7 +226,7 @@ def isPositive(x):
207226
def getDenominator(coefficients):
208227
exponents = [(inner, coefficients.count(inner))
209228
for inner in set(coefficients)]
210-
denominator = ' '.join('(1 - t{}){}'. format(to_sup(x[0]) if x[0] is not 1 else '', to_sup(x[1]) if x[1] is not 1 else '') for x in exponents)
229+
denominator = ' '.join('(1 - t{}){}'. format(to_sup(x[0]) if x[0] != 1 else '', to_sup(x[1]) if x[1] != 1 else '') for x in exponents)
211230
return denominator
212231

213232
num = getNumerator(numCoefficients)

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ A full documentation is conatined in [Appendix E](doc/PyNormaliz.pdf) of the Nor
1313
## Requirements
1414

1515
* python 2.7 or higher or python 3.4 or higher
16-
* Normaliz 3.8.10 or higher <https://github.com/Normaliz/Normaliz/releases>
16+
* Normaliz 3.9.0 or higher <https://github.com/Normaliz/Normaliz/releases>
1717

18-
(The current version of PyNormaliz is under construction. Normaliz 3.8.10 not yet released. Use current master of Normaliz for current master of PyNormaliz.) The source packages of the Normaliz realeases contain PyNormaliz.
18+
(The current version of PyNormaliz is under construction. Normaliz 3.9.0 not yet released. Use current master of Normaliz for current master of PyNormaliz.) The source packages of the Normaliz realeases contain PyNormaliz.
1919

2020
## Installation
2121

@@ -137,7 +137,8 @@ By using Python functions, the functionality of Normaliz can be extended. For ex
137137

138138
def intersection(cone1, cone2):
139139
intersection_ineq = cone1.SupportHyperplanes()+cone2.SupportHyperplanes()
140-
C = Cone(inequalities = intersection_ineq)
140+
intersection_equat = cone1.Equations()+cone2.Equations()
141+
C = Cone(inequalities = intersection_ineq, equations = intersection_equat)
141142
return C
142143

143144
computes the intersection of two cones. So

doc/PyNormaliz.pdf

1.96 KB
Binary file not shown.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = PyNormaliz
3-
version = 2.14
3+
version = 2.15
44
description = An interface to Normaliz
55
author = Sebastian Gutsche, Richard Sieg
66
author_email = [email protected]

tests/autom.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Test automorphism group
44
>>> from PyNormaliz import Cone, NmzCone, NmzResult
55
>>> V = [[-1, -1, 1], [-1, 0, 1], [-1, 1, 1], [0, -1, 1], [0, 0, 1], [0, 1, 1], [1, -1, 1], [1, 0, 1], [1, 1, 1]]
66
>>> cube2 = NmzCone(vertices=V)
7-
>>> NmzResult(cube2,"Automorphisms") == [8, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
7+
>>> NmzResult(cube2,"Automorphisms") == [8, True, True, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
88
True
99

tests/generic_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class Test2(GenericPyNormalizTest):
192192

193193
# expected results
194194
AffineDim = 2
195-
Automorphisms = [8, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
195+
Automorphisms = [8, True, True, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
196196
Congruences = []
197197
Dehomogenization = normaliz_error
198198
EmbeddingDim = 5

tests/test_rational_cones.txt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,15 @@ True
6767
True
6868
>>> len(NmzResult(cube2, "FaceLattice")) == 10
6969
True
70-
>>> cube1.Automorphisms() == [8, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
70+
>>> cube1.Automorphisms() == [8, True, True, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
7171
True
72-
>>> cube1.Automorphisms() == [8, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
72+
>>> cube1.CombinatorialAutomorphisms() == [8, False, False, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
7373
True
74-
>>> cube1.CombinatorialAutomorphisms() == [8, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
74+
>>> cube1.RationalAutomorphisms() == [8, True, True, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
7575
True
76-
>>> cube1.RationalAutomorphisms() == [8, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
76+
>>> cube1.RationalAutomorphisms() == [8, True, True, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
7777
True
78-
>>> cube1.RationalAutomorphisms() == [8, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
79-
True
80-
>>> cube1.EuclideanAutomorphisms() == [8, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
78+
>>> cube1.EuclideanAutomorphisms() == [8, False, False, [[], []], [[[0, 2, 1, 3], [1, 0, 3, 2]], [[0, 1, 2, 3]]], [[[1, 0, 3, 2], [0, 2, 1, 3]], [[0, 1, 2, 3]]]]
8179
True
8280
>>> cube1.Incidence() == [[0, 0, 1, 1], [0, 1, 0, 1], [1, 0, 1, 0], [1, 1, 0, 0]]
8381
True

0 commit comments

Comments
 (0)