passagemath-latte-4ti2 10.6.33__cp314-cp314t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of passagemath-latte-4ti2 might be problematic. Click here for more details.
- passagemath_latte_4ti2-10.6.33.dist-info/METADATA +157 -0
- passagemath_latte_4ti2-10.6.33.dist-info/RECORD +65 -0
- passagemath_latte_4ti2-10.6.33.dist-info/WHEEL +6 -0
- passagemath_latte_4ti2-10.6.33.dist-info/top_level.txt +2 -0
- passagemath_latte_4ti2.libs/lib4ti2common-a503c59a.so.0.0.0 +0 -0
- passagemath_latte_4ti2.libs/lib4ti2gmp-cc07667c.so.0.0.0 +0 -0
- passagemath_latte_4ti2.libs/lib4ti2int32-8edd6011.so.0.0.0 +0 -0
- passagemath_latte_4ti2.libs/lib4ti2int64-f6cc34ab.so.0.0.0 +0 -0
- passagemath_latte_4ti2.libs/lib4ti2util-1e2ba2e1.so.0.0.0 +0 -0
- passagemath_latte_4ti2.libs/libLiDIA-e2c3e770.so.0.0.0 +0 -0
- passagemath_latte_4ti2.libs/libcddgmp-ac579979.so.0.1.3 +0 -0
- passagemath_latte_4ti2.libs/libgf2x-fbd36f80.so.3.0.0 +0 -0
- passagemath_latte_4ti2.libs/libglpk-30fa236a.so.40.3.1 +0 -0
- passagemath_latte_4ti2.libs/libgmp-93ebf16a.so.10.5.0 +0 -0
- passagemath_latte_4ti2.libs/libgmpxx-0d9ed651.so.4.7.0 +0 -0
- passagemath_latte_4ti2.libs/liblatte-5119da9a.so.0.0.0 +0 -0
- passagemath_latte_4ti2.libs/libnormalize-2d5ac6a7.so.0.0.0 +0 -0
- passagemath_latte_4ti2.libs/libntl-0043a3a2.so.44.0.1 +0 -0
- passagemath_latte_4ti2.libs/libzsolve-acbcdf65.so.0.0.0 +0 -0
- sage/all__sagemath_latte_4ti2.py +4 -0
- sage/interfaces/all__sagemath_latte_4ti2.py +1 -0
- sage/interfaces/four_ti_2.py +531 -0
- sage/interfaces/latte.py +632 -0
- sage/libs/all__sagemath_latte_4ti2.py +1 -0
- sage/libs/latte_int.cpython-314t-aarch64-linux-gnu.so +0 -0
- sage/libs/latte_int.pyx +1 -0
- sage_wheels/bin/4ti2gmp +0 -0
- sage_wheels/bin/4ti2int32 +0 -0
- sage_wheels/bin/4ti2int64 +0 -0
- sage_wheels/bin/ConvertCDDextToLatte +0 -0
- sage_wheels/bin/ConvertCDDineToLatte +0 -0
- sage_wheels/bin/circuits +64 -0
- sage_wheels/bin/count +0 -0
- sage_wheels/bin/count-linear-forms-from-polynomial +0 -0
- sage_wheels/bin/ehrhart +0 -0
- sage_wheels/bin/ehrhart3 +0 -0
- sage_wheels/bin/genmodel +0 -0
- sage_wheels/bin/gensymm +0 -0
- sage_wheels/bin/graver +17 -0
- sage_wheels/bin/groebner +64 -0
- sage_wheels/bin/hilbert +17 -0
- sage_wheels/bin/hilbert-from-rays +0 -0
- sage_wheels/bin/hilbert-from-rays-symm +0 -0
- sage_wheels/bin/integrate +0 -0
- sage_wheels/bin/latte-maximize +0 -0
- sage_wheels/bin/latte-minimize +0 -0
- sage_wheels/bin/latte2ext +0 -0
- sage_wheels/bin/latte2ine +0 -0
- sage_wheels/bin/markov +64 -0
- sage_wheels/bin/minimize +64 -0
- sage_wheels/bin/normalform +64 -0
- sage_wheels/bin/output +0 -0
- sage_wheels/bin/polyhedron-to-cones +0 -0
- sage_wheels/bin/ppi +0 -0
- sage_wheels/bin/qsolve +64 -0
- sage_wheels/bin/rays +64 -0
- sage_wheels/bin/top-ehrhart-knapsack +0 -0
- sage_wheels/bin/triangulate +0 -0
- sage_wheels/bin/walk +64 -0
- sage_wheels/bin/zbasis +64 -0
- sage_wheels/bin/zsolve +0 -0
- sage_wheels/share/latte-int/m-knapsack.mpl +1245 -0
- sage_wheels/share/latte-int/simplify.add +7 -0
- sage_wheels/share/latte-int/simplify2.add +9 -0
- sage_wheels/share/latte-int/simplify3.add +13 -0
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-latte-4ti2
|
|
2
|
+
# sage.doctest: optional - 4ti2
|
|
3
|
+
r"""
|
|
4
|
+
Interface to 4ti2
|
|
5
|
+
|
|
6
|
+
https://4ti2.github.io/
|
|
7
|
+
|
|
8
|
+
You must have the 4ti2 Sage package installed on your computer
|
|
9
|
+
for this interface to work.
|
|
10
|
+
|
|
11
|
+
Use ``sage -i 4ti2`` to install the package.
|
|
12
|
+
|
|
13
|
+
AUTHORS:
|
|
14
|
+
|
|
15
|
+
- Mike Hansen (2009): Initial version.
|
|
16
|
+
|
|
17
|
+
- Bjarke Hammersholt Roune (2009-06-26): Added Groebner, made code
|
|
18
|
+
usable as part of the Sage library and added documentation and some
|
|
19
|
+
doctests.
|
|
20
|
+
|
|
21
|
+
- Marshall Hampton (2011): Minor fixes to documentation.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
# ****************************************************************************
|
|
25
|
+
# Copyright (C) 2009 Mike Hansen <mhansen@gmail.com>
|
|
26
|
+
# Copyright (C) 2009 Bjarke Hammersholt Roune <www.broune.com>
|
|
27
|
+
#
|
|
28
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
29
|
+
#
|
|
30
|
+
# This code is distributed in the hope that it will be useful,
|
|
31
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
32
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
33
|
+
# General Public License for more details.
|
|
34
|
+
#
|
|
35
|
+
# The full text of the GPL is available at:
|
|
36
|
+
#
|
|
37
|
+
# https://www.gnu.org/licenses/
|
|
38
|
+
# ****************************************************************************
|
|
39
|
+
|
|
40
|
+
from sage.rings.integer_ring import ZZ
|
|
41
|
+
from sage.features.four_ti_2 import FourTi2Executable
|
|
42
|
+
|
|
43
|
+
import os
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class FourTi2:
|
|
47
|
+
r"""
|
|
48
|
+
An interface to the program 4ti2.
|
|
49
|
+
|
|
50
|
+
Each 4ti2 command is exposed as a method of this class.
|
|
51
|
+
"""
|
|
52
|
+
def __init__(self, directory=None):
|
|
53
|
+
r"""
|
|
54
|
+
Initialize this object.
|
|
55
|
+
|
|
56
|
+
INPUT:
|
|
57
|
+
|
|
58
|
+
- ``directory`` -- 4ti2 only deals with files, and this is the
|
|
59
|
+
directory that Sage will write input files to and run 4ti2
|
|
60
|
+
in. Use an appropriate temporary directory if the value is
|
|
61
|
+
``None``.
|
|
62
|
+
|
|
63
|
+
EXAMPLES::
|
|
64
|
+
|
|
65
|
+
sage: from sage.interfaces.four_ti_2 import FourTi2
|
|
66
|
+
sage: f = FourTi2("/tmp/")
|
|
67
|
+
sage: f.directory()
|
|
68
|
+
'/tmp/'
|
|
69
|
+
"""
|
|
70
|
+
self._directory = directory
|
|
71
|
+
|
|
72
|
+
##################
|
|
73
|
+
# Input / output #
|
|
74
|
+
##################
|
|
75
|
+
|
|
76
|
+
def directory(self):
|
|
77
|
+
r"""
|
|
78
|
+
Return the directory where the input files for 4ti2 are
|
|
79
|
+
written by Sage and where 4ti2 is run.
|
|
80
|
+
|
|
81
|
+
EXAMPLES::
|
|
82
|
+
|
|
83
|
+
sage: from sage.interfaces.four_ti_2 import FourTi2
|
|
84
|
+
sage: f = FourTi2("/tmp/")
|
|
85
|
+
sage: f.directory()
|
|
86
|
+
'/tmp/'
|
|
87
|
+
"""
|
|
88
|
+
from sage.misc.temporary_file import tmp_dir
|
|
89
|
+
if self._directory is None:
|
|
90
|
+
# we have to put this here rather than in the __init__
|
|
91
|
+
# method since apparently importing sage.misc.misc does not
|
|
92
|
+
# work until Sage is done starting up.
|
|
93
|
+
self._directory = tmp_dir()
|
|
94
|
+
return self._directory
|
|
95
|
+
|
|
96
|
+
def temp_project(self):
|
|
97
|
+
r"""
|
|
98
|
+
Return an input project file name that has not been used yet.
|
|
99
|
+
|
|
100
|
+
EXAMPLES::
|
|
101
|
+
|
|
102
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
103
|
+
sage: four_ti_2.temp_project()
|
|
104
|
+
'project_...'
|
|
105
|
+
"""
|
|
106
|
+
n = 0
|
|
107
|
+
while True:
|
|
108
|
+
project = "project_%s" % n
|
|
109
|
+
touch_file = os.path.join(self.directory(), project) + '.touch'
|
|
110
|
+
if not os.path.exists(touch_file):
|
|
111
|
+
break
|
|
112
|
+
n += 1
|
|
113
|
+
f = open(touch_file, 'w')
|
|
114
|
+
f.write(' ')
|
|
115
|
+
f.close()
|
|
116
|
+
return project
|
|
117
|
+
|
|
118
|
+
def write_matrix(self, mat, filename):
|
|
119
|
+
r"""
|
|
120
|
+
Write the matrix ``mat`` to the file ``filename`` in 4ti2 format.
|
|
121
|
+
|
|
122
|
+
INPUT:
|
|
123
|
+
|
|
124
|
+
- ``mat`` -- a matrix of integers or something that can be
|
|
125
|
+
converted to that
|
|
126
|
+
- ``filename`` -- a file name not including a path
|
|
127
|
+
|
|
128
|
+
EXAMPLES::
|
|
129
|
+
|
|
130
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
131
|
+
sage: four_ti_2.write_matrix([[1,2],[3,4]], "test_file")
|
|
132
|
+
"""
|
|
133
|
+
from sage.matrix.constructor import matrix
|
|
134
|
+
from sage.structure.element import Matrix
|
|
135
|
+
if not isinstance(mat, Matrix):
|
|
136
|
+
mat = matrix(ZZ, mat)
|
|
137
|
+
if mat.base_ring() != ZZ:
|
|
138
|
+
mat = mat.change_ring(ZZ)
|
|
139
|
+
|
|
140
|
+
self.write_array(mat, mat.nrows(), mat.ncols(), filename)
|
|
141
|
+
|
|
142
|
+
def write_single_row(self, row, filename):
|
|
143
|
+
r"""
|
|
144
|
+
Write the list ``row`` to the file ``filename`` in 4ti2 format
|
|
145
|
+
as a matrix with one row.
|
|
146
|
+
|
|
147
|
+
INPUT:
|
|
148
|
+
|
|
149
|
+
- ``row`` -- list of integers
|
|
150
|
+
- ``filename`` -- a file name not including a path
|
|
151
|
+
|
|
152
|
+
EXAMPLES::
|
|
153
|
+
|
|
154
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
155
|
+
sage: four_ti_2.write_single_row([1,2,3,4], "test_file")
|
|
156
|
+
"""
|
|
157
|
+
self.write_array([row], 1, len(row), filename)
|
|
158
|
+
|
|
159
|
+
def write_array(self, array, nrows, ncols, filename):
|
|
160
|
+
r"""
|
|
161
|
+
Write the integer matrix ``array`` to the file ``filename``
|
|
162
|
+
in directory ``directory()`` in 4ti2 format.
|
|
163
|
+
|
|
164
|
+
The matrix must have ``nrows`` rows and ``ncols`` columns.
|
|
165
|
+
It can be provided as a list of lists.
|
|
166
|
+
|
|
167
|
+
INPUT:
|
|
168
|
+
|
|
169
|
+
- ``array`` -- a matrix of integers. Can be represented as a list
|
|
170
|
+
of lists
|
|
171
|
+
- ``nrows`` -- the number of rows in ``array``
|
|
172
|
+
- ``ncols`` -- the number of columns in ``array``
|
|
173
|
+
- ``file`` -- a file name not including a path
|
|
174
|
+
|
|
175
|
+
EXAMPLES::
|
|
176
|
+
|
|
177
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
178
|
+
sage: four_ti_2.write_array([[1,2,3],[3,4,5]], 2, 3, "test_file")
|
|
179
|
+
"""
|
|
180
|
+
f = open(os.path.join(self.directory(), filename), 'w')
|
|
181
|
+
f.write("%s %s\n" % (nrows, ncols))
|
|
182
|
+
for row in array:
|
|
183
|
+
f.write(" ".join(map(str, row)))
|
|
184
|
+
f.write("\n")
|
|
185
|
+
f.close()
|
|
186
|
+
|
|
187
|
+
def read_matrix(self, filename):
|
|
188
|
+
r"""
|
|
189
|
+
Read a matrix in 4ti2 format from the file ``filename`` in
|
|
190
|
+
directory ``directory()``.
|
|
191
|
+
|
|
192
|
+
INPUT:
|
|
193
|
+
|
|
194
|
+
- ``filename`` -- the name of the file to read from
|
|
195
|
+
|
|
196
|
+
OUTPUT: the data from the file as a matrix over `\ZZ`
|
|
197
|
+
|
|
198
|
+
EXAMPLES::
|
|
199
|
+
|
|
200
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
201
|
+
sage: four_ti_2.write_matrix([[1,2,3],[3,4,6]], "test_file")
|
|
202
|
+
sage: four_ti_2.read_matrix("test_file")
|
|
203
|
+
[1 2 3]
|
|
204
|
+
[3 4 6]
|
|
205
|
+
"""
|
|
206
|
+
from sage.matrix.constructor import matrix
|
|
207
|
+
try:
|
|
208
|
+
f = open(os.path.join(self.directory(), filename))
|
|
209
|
+
lines = f.readlines()
|
|
210
|
+
f.close()
|
|
211
|
+
except OSError:
|
|
212
|
+
return matrix(ZZ, 0, 0)
|
|
213
|
+
|
|
214
|
+
nrows, ncols = map(ZZ, lines.pop(0).strip().split())
|
|
215
|
+
return matrix(ZZ, nrows, ncols,
|
|
216
|
+
[[ZZ(_) for _ in line.strip().split()] for line in lines
|
|
217
|
+
if line.strip() != ""])
|
|
218
|
+
|
|
219
|
+
def _process_input(self, kwds):
|
|
220
|
+
r"""
|
|
221
|
+
Process the input in the dictionary ``kwds``.
|
|
222
|
+
|
|
223
|
+
The values are written to files with extensions given
|
|
224
|
+
by the keys, except for the keys ``self`` and ``project``.
|
|
225
|
+
|
|
226
|
+
This interesting method is intended to be called as the first
|
|
227
|
+
thing going on in a method implementing some action of 4ti2,
|
|
228
|
+
where the value of ``locals()`` is passed as the dict, thus
|
|
229
|
+
achieving to write out many project files to the right places
|
|
230
|
+
just by giving the parameters of the method names that are the
|
|
231
|
+
extension of the corresponding files.
|
|
232
|
+
|
|
233
|
+
Nothing is written if the value is ``None``. Otherwise the value
|
|
234
|
+
is written as a matrix to the file given by the value of the
|
|
235
|
+
key ``'project'`` with extension given by the key.
|
|
236
|
+
|
|
237
|
+
INPUT:
|
|
238
|
+
|
|
239
|
+
- ``kwds`` -- dictionary controlling what data is written to what files
|
|
240
|
+
|
|
241
|
+
OUTPUT: the value of the key ``project``
|
|
242
|
+
|
|
243
|
+
EXAMPLES::
|
|
244
|
+
|
|
245
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
246
|
+
sage: pr = four_ti_2._process_input(
|
|
247
|
+
....: {'project': "test_file",
|
|
248
|
+
....: 'self': None,
|
|
249
|
+
....: 'tst': [[1,2,3],[3,4,5]]})
|
|
250
|
+
sage: four_ti_2.read_matrix("test_file.tst")
|
|
251
|
+
[1 2 3]
|
|
252
|
+
[3 4 5]
|
|
253
|
+
"""
|
|
254
|
+
# Get the project
|
|
255
|
+
project = kwds.get('project', None)
|
|
256
|
+
if project is None:
|
|
257
|
+
project = self.temp_project()
|
|
258
|
+
|
|
259
|
+
for ext, value in kwds.items():
|
|
260
|
+
if value is None:
|
|
261
|
+
continue
|
|
262
|
+
if ext == "project" or ext == "self":
|
|
263
|
+
continue
|
|
264
|
+
|
|
265
|
+
if (isinstance(value, list) and
|
|
266
|
+
not (value and isinstance(value[0], list))):
|
|
267
|
+
self.write_single_row(value, project + "." + ext)
|
|
268
|
+
else:
|
|
269
|
+
self.write_matrix(value, project + "." + ext)
|
|
270
|
+
|
|
271
|
+
return project
|
|
272
|
+
|
|
273
|
+
############
|
|
274
|
+
# Commands #
|
|
275
|
+
############
|
|
276
|
+
|
|
277
|
+
def call(self, command, project, verbose=True, *, options=()):
|
|
278
|
+
r"""
|
|
279
|
+
Run the 4ti2 program ``command`` on the project named
|
|
280
|
+
``project`` in the directory ``directory()``.
|
|
281
|
+
|
|
282
|
+
INPUT:
|
|
283
|
+
|
|
284
|
+
- ``command`` -- the 4ti2 program to run
|
|
285
|
+
- ``project`` -- the file name of the project to run on
|
|
286
|
+
- ``verbose`` -- display the output of 4ti2 if ``True``
|
|
287
|
+
- ``options`` -- list of strings to pass to the program
|
|
288
|
+
|
|
289
|
+
EXAMPLES::
|
|
290
|
+
|
|
291
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
292
|
+
sage: four_ti_2.write_matrix([[6,10,15]], "test_file")
|
|
293
|
+
sage: four_ti_2.call("groebner", "test_file", False) # optional - 4ti2
|
|
294
|
+
sage: four_ti_2.read_matrix("test_file.gro") # optional - 4ti2
|
|
295
|
+
[-5 0 2]
|
|
296
|
+
[-5 3 0]
|
|
297
|
+
"""
|
|
298
|
+
import subprocess
|
|
299
|
+
import shlex
|
|
300
|
+
feature = FourTi2Executable(command)
|
|
301
|
+
executable = feature.absolute_filename()
|
|
302
|
+
options = " ".join(options)
|
|
303
|
+
cmd = f'{shlex.quote(executable)} {options} {project}'
|
|
304
|
+
if verbose is False:
|
|
305
|
+
cmd += " > /dev/null 2> /dev/null"
|
|
306
|
+
subprocess.call(cmd, shell=True, cwd=self.directory())
|
|
307
|
+
|
|
308
|
+
def zsolve(self, mat=None, rel=None, rhs=None, sign=None, lat=None, project=None):
|
|
309
|
+
r"""
|
|
310
|
+
Run the 4ti2 program ``zsolve`` on the parameters.
|
|
311
|
+
|
|
312
|
+
See `4ti2 website <https://4ti2.github.io/>`_ for details.
|
|
313
|
+
|
|
314
|
+
EXAMPLES::
|
|
315
|
+
|
|
316
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
317
|
+
sage: A = [[1,1,1],[1,2,3]]
|
|
318
|
+
sage: rel = ['<', '<']
|
|
319
|
+
sage: rhs = [2, 3]
|
|
320
|
+
sage: sign = [1,0,1]
|
|
321
|
+
sage: four_ti_2.zsolve(A, rel, rhs, sign) # optional - 4ti2
|
|
322
|
+
[
|
|
323
|
+
[ 1 -1 0]
|
|
324
|
+
[ 0 -1 0]
|
|
325
|
+
[0 0 1] [ 0 -3 2]
|
|
326
|
+
[1 1 0] [ 1 -2 1]
|
|
327
|
+
[0 1 0], [ 0 -2 1], []
|
|
328
|
+
]
|
|
329
|
+
sage: four_ti_2.zsolve(lat=[[1,2,3],[1,1,1]]) # optional - 4ti2
|
|
330
|
+
[
|
|
331
|
+
[1 2 3]
|
|
332
|
+
[0 0 0], [], [1 1 1]
|
|
333
|
+
]
|
|
334
|
+
"""
|
|
335
|
+
project = self._process_input(locals())
|
|
336
|
+
self.call('zsolve', project, options=['-q'])
|
|
337
|
+
return [self.read_matrix(project+'.'+ext) for ext in
|
|
338
|
+
['zinhom', 'zhom', 'zfree']]
|
|
339
|
+
|
|
340
|
+
def qsolve(self, mat=None, rel=None, sign=None, project=None):
|
|
341
|
+
r"""
|
|
342
|
+
Run the 4ti2 program ``qsolve`` on the parameters.
|
|
343
|
+
|
|
344
|
+
See `4ti2 website <https://4ti2.github.io/>`_ for details.
|
|
345
|
+
|
|
346
|
+
EXAMPLES::
|
|
347
|
+
|
|
348
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
349
|
+
sage: A = [[1,1,1],[1,2,3]]
|
|
350
|
+
sage: four_ti_2.qsolve(A) # optional - 4ti2
|
|
351
|
+
[[], [ 1 -2 1]]
|
|
352
|
+
"""
|
|
353
|
+
project = self._process_input(locals())
|
|
354
|
+
self.call('qsolve', project, options=['-q', '-parbitrary'])
|
|
355
|
+
return [self.read_matrix(project+'.'+ext) for ext in
|
|
356
|
+
['qhom', 'qfree']]
|
|
357
|
+
|
|
358
|
+
def rays(self, mat=None, project=None):
|
|
359
|
+
r"""
|
|
360
|
+
Run the 4ti2 program ``rays`` on the parameters.
|
|
361
|
+
|
|
362
|
+
See `4ti2 website <https://4ti2.github.io/>`_ for details.
|
|
363
|
+
|
|
364
|
+
EXAMPLES::
|
|
365
|
+
|
|
366
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
367
|
+
sage: four_ti_2.rays(four_ti_2._magic3x3()) # optional - 4ti2
|
|
368
|
+
[0 2 1 2 1 0 1 0 2]
|
|
369
|
+
[1 0 2 2 1 0 0 2 1]
|
|
370
|
+
[1 2 0 0 1 2 2 0 1]
|
|
371
|
+
[2 0 1 0 1 2 1 2 0]
|
|
372
|
+
"""
|
|
373
|
+
project = self._process_input(locals())
|
|
374
|
+
self.call('rays', project, options=['-q', '-parbitrary'])
|
|
375
|
+
return self.read_matrix(project+'.ray')
|
|
376
|
+
|
|
377
|
+
def hilbert(self, mat=None, lat=None, project=None):
|
|
378
|
+
r"""
|
|
379
|
+
Run the 4ti2 program ``hilbert`` on the parameters.
|
|
380
|
+
|
|
381
|
+
See `4ti2 website <https://4ti2.github.io/>`_ for details.
|
|
382
|
+
|
|
383
|
+
EXAMPLES::
|
|
384
|
+
|
|
385
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
386
|
+
sage: four_ti_2.hilbert(four_ti_2._magic3x3()) # optional - 4ti2
|
|
387
|
+
[2 0 1 0 1 2 1 2 0]
|
|
388
|
+
[1 0 2 2 1 0 0 2 1]
|
|
389
|
+
[0 2 1 2 1 0 1 0 2]
|
|
390
|
+
[1 2 0 0 1 2 2 0 1]
|
|
391
|
+
[1 1 1 1 1 1 1 1 1]
|
|
392
|
+
sage: four_ti_2.hilbert(lat=[[1,2,3],[1,1,1]]) # optional - 4ti2
|
|
393
|
+
[2 1 0]
|
|
394
|
+
[0 1 2]
|
|
395
|
+
[1 1 1]
|
|
396
|
+
"""
|
|
397
|
+
project = self._process_input(locals())
|
|
398
|
+
self.call('hilbert', project, options=['-q'])
|
|
399
|
+
return self.read_matrix(project+'.hil')
|
|
400
|
+
|
|
401
|
+
def graver(self, mat=None, lat=None, project=None):
|
|
402
|
+
r"""
|
|
403
|
+
Run the 4ti2 program ``graver`` on the parameters.
|
|
404
|
+
|
|
405
|
+
See `4ti2 website <https://4ti2.github.io/>`_ for details.
|
|
406
|
+
|
|
407
|
+
EXAMPLES::
|
|
408
|
+
|
|
409
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
410
|
+
sage: four_ti_2.graver([1,2,3]) # optional - 4ti2
|
|
411
|
+
[ 2 -1 0]
|
|
412
|
+
[ 3 0 -1]
|
|
413
|
+
[ 1 1 -1]
|
|
414
|
+
[ 1 -2 1]
|
|
415
|
+
[ 0 3 -2]
|
|
416
|
+
sage: four_ti_2.graver(lat=[[1,2,3],[1,1,1]]) # optional - 4ti2
|
|
417
|
+
[ 1 0 -1]
|
|
418
|
+
[ 0 1 2]
|
|
419
|
+
[ 1 1 1]
|
|
420
|
+
[ 2 1 0]
|
|
421
|
+
"""
|
|
422
|
+
project = self._process_input(locals())
|
|
423
|
+
self.call('graver', project, options=['-q'])
|
|
424
|
+
return self.read_matrix(project+'.gra')
|
|
425
|
+
|
|
426
|
+
def ppi(self, n):
|
|
427
|
+
r"""
|
|
428
|
+
Run the 4ti2 program ``ppi`` on the parameters.
|
|
429
|
+
|
|
430
|
+
See `4ti2 website <https://4ti2.github.io/>`_ for details.
|
|
431
|
+
|
|
432
|
+
EXAMPLES::
|
|
433
|
+
|
|
434
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
435
|
+
sage: four_ti_2.ppi(3) # optional - 4ti2
|
|
436
|
+
[-2 1 0]
|
|
437
|
+
[ 0 -3 2]
|
|
438
|
+
[-1 -1 1]
|
|
439
|
+
[-3 0 1]
|
|
440
|
+
[ 1 -2 1]
|
|
441
|
+
"""
|
|
442
|
+
self.call('ppi', f'{n} 2> /dev/null')
|
|
443
|
+
return self.read_matrix('ppi%s.gra' % n)
|
|
444
|
+
|
|
445
|
+
def circuits(self, mat=None, project=None):
|
|
446
|
+
r"""
|
|
447
|
+
Run the 4ti2 program ``circuits`` on the parameters.
|
|
448
|
+
|
|
449
|
+
See `4ti2 website <https://4ti2.github.io/>`_ for details.
|
|
450
|
+
|
|
451
|
+
EXAMPLES::
|
|
452
|
+
|
|
453
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
454
|
+
sage: four_ti_2.circuits([1,2,3]) # optional - 4ti2
|
|
455
|
+
[ 0 3 -2]
|
|
456
|
+
[ 2 -1 0]
|
|
457
|
+
[ 3 0 -1]
|
|
458
|
+
"""
|
|
459
|
+
project = self._process_input(locals())
|
|
460
|
+
self.call('circuits', project, options=['-q', '-parbitrary'])
|
|
461
|
+
return self.read_matrix(project+'.cir')
|
|
462
|
+
|
|
463
|
+
def minimize(self, mat=None, lat=None):
|
|
464
|
+
r"""
|
|
465
|
+
Run the 4ti2 program ``minimize`` on the parameters.
|
|
466
|
+
|
|
467
|
+
See `4ti2 website <https://4ti2.github.io/>`_ for details.
|
|
468
|
+
|
|
469
|
+
EXAMPLES::
|
|
470
|
+
|
|
471
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
472
|
+
sage: four_ti_2.minimize() # optional - 4ti2
|
|
473
|
+
Traceback (most recent call last):
|
|
474
|
+
...
|
|
475
|
+
NotImplementedError: 4ti2 command 'minimize' not implemented in Sage.
|
|
476
|
+
"""
|
|
477
|
+
raise NotImplementedError("4ti2 command 'minimize' not implemented "
|
|
478
|
+
"in Sage.")
|
|
479
|
+
|
|
480
|
+
def groebner(self, mat=None, lat=None, project=None):
|
|
481
|
+
r"""
|
|
482
|
+
Run the 4ti2 program ``groebner`` on the parameters.
|
|
483
|
+
|
|
484
|
+
This computes a toric Groebner basis of a matrix.
|
|
485
|
+
|
|
486
|
+
See `4ti2 website <https://4ti2.github.io/>`_ for details.
|
|
487
|
+
|
|
488
|
+
EXAMPLES::
|
|
489
|
+
|
|
490
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
491
|
+
sage: A = [6,10,15]
|
|
492
|
+
sage: four_ti_2.groebner(A) # optional - 4ti2
|
|
493
|
+
[-5 0 2]
|
|
494
|
+
[-5 3 0]
|
|
495
|
+
sage: four_ti_2.groebner(lat=[[1,2,3],[1,1,1]]) # optional - 4ti2
|
|
496
|
+
[-1 0 1]
|
|
497
|
+
[ 2 1 0]
|
|
498
|
+
"""
|
|
499
|
+
project = self._process_input(locals())
|
|
500
|
+
self.call('groebner', project, options=['-q', '-parbitrary'])
|
|
501
|
+
return self.read_matrix(project+'.gro')
|
|
502
|
+
|
|
503
|
+
def _magic3x3(self):
|
|
504
|
+
r"""
|
|
505
|
+
Return a matrix used for testing this class.
|
|
506
|
+
|
|
507
|
+
EXAMPLES::
|
|
508
|
+
|
|
509
|
+
sage: from sage.interfaces.four_ti_2 import four_ti_2
|
|
510
|
+
sage: four_ti_2._magic3x3() # optional - 4ti2
|
|
511
|
+
[ 1 1 1 -1 -1 -1 0 0 0]
|
|
512
|
+
[ 1 1 1 0 0 0 -1 -1 -1]
|
|
513
|
+
[ 0 1 1 -1 0 0 -1 0 0]
|
|
514
|
+
[ 1 0 1 0 -1 0 0 -1 0]
|
|
515
|
+
[ 1 1 0 0 0 -1 0 0 -1]
|
|
516
|
+
[ 0 1 1 0 -1 0 0 0 -1]
|
|
517
|
+
[ 1 1 0 0 -1 0 -1 0 0]
|
|
518
|
+
"""
|
|
519
|
+
from sage.matrix.constructor import matrix
|
|
520
|
+
return matrix(ZZ, 7, 9,
|
|
521
|
+
[[1, 1, 1, -1, -1, -1, 0, 0, 0],
|
|
522
|
+
[1, 1, 1, 0, 0, 0, -1, -1, -1],
|
|
523
|
+
[0, 1, 1, -1, 0, 0, -1, 0, 0],
|
|
524
|
+
[1, 0, 1, 0, -1, 0, 0, -1, 0],
|
|
525
|
+
[1, 1, 0, 0, 0, -1, 0, 0, -1],
|
|
526
|
+
[0, 1, 1, 0, -1, 0, 0, 0, -1],
|
|
527
|
+
[1, 1, 0, 0, -1, 0, -1, 0, 0]])
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
# The instance that should be used outside this file.
|
|
531
|
+
four_ti_2 = FourTi2()
|