Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
_init_from_normaliz_data: New, use it in _init_from_*representation
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Apr 4, 2018
1 parent 4dbdc7d commit 1dcef4c
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/sage/geometry/polyhedron/backend_normaliz.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ def _init_from_normaliz_cone(self, normaliz_cone):
self._init_Vrepresentation_from_normaliz()
self._init_Hrepresentation_from_normaliz()

def _init_from_normaliz_data(self, data, verbose=False):
import PyNormaliz
if verbose:
print("# Calling PyNormaliz.NmzCone(**{})".format(data))
cone = PyNormaliz.NmzCone(**data)
assert cone, "NmzCone(**{}) did not return a cone".format(data)
self._init_from_normaliz_cone(cone)

def _init_from_Vrepresentation(self, vertices, rays, lines, minimize=True, verbose=False):
r"""
Construct polyhedron from V-representation data.
Expand Down Expand Up @@ -203,7 +211,6 @@ def _init_from_Vrepresentation(self, vertices, rays, lines, minimize=True, verbo
sage: from sage.geometry.polyhedron.backend_normaliz import Polyhedron_normaliz # optional - pynormaliz
sage: Polyhedron_normaliz._init_from_Vrepresentation(p, [], [], []) # optional - pynormaliz
"""
import PyNormaliz
if vertices is None:
vertices = []
nmz_vertices = []
Expand Down Expand Up @@ -233,11 +240,7 @@ def _init_from_Vrepresentation(self, vertices, rays, lines, minimize=True, verbo
data = {"vertices": nmz_vertices,
"cone": nmz_rays,
"subspace": nmz_lines}
if verbose:
print("# Calling PyNormaliz.NmzCone(**{})".format(data))
cone = PyNormaliz.NmzCone(**data)
assert cone, "NmzCone(**{}) did not return a cone".format(data)
self._init_from_normaliz_cone(cone)
self._init_from_normaliz_data(data, verbose=verbose)

def _init_from_Hrepresentation(self, ieqs, eqns, minimize=True, verbose=False):
r"""
Expand All @@ -264,7 +267,6 @@ def _init_from_Hrepresentation(self, ieqs, eqns, minimize=True, verbose=False):
sage: from sage.geometry.polyhedron.backend_normaliz import Polyhedron_normaliz # optional - pynormaliz
sage: Polyhedron_normaliz._init_from_Hrepresentation(p, [], []) # optional - pynormaliz
"""
import PyNormaliz
if ieqs is None: ieqs = []
nmz_ieqs = []
for ieq in ieqs:
Expand All @@ -288,12 +290,7 @@ def _init_from_Hrepresentation(self, ieqs, eqns, minimize=True, verbose=False):
nmz_eqns.append(A + [b])
data = {"inhom_equations": nmz_eqns,
"inhom_inequalities": nmz_ieqs}
self._normaliz_cone = PyNormaliz.NmzCone(**data)
if verbose:
print("# Calling PyNormaliz.NmzCone(**{})".format(data))
cone = PyNormaliz.NmzCone(**data)
assert cone, "NmzCone(**{}) did not return a cone".format(data)
self._init_from_normaliz_cone(cone)
self._init_from_normaliz_data(data, verbose=verbose)

def _init_Vrepresentation_from_normaliz(self):
r"""
Expand Down

0 comments on commit 1dcef4c

Please sign in to comment.