passagemath-polyhedra 10.6.37__cp314-cp314-musllinux_1_2_x86_64.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.
- passagemath_polyhedra/__init__.py +3 -0
- passagemath_polyhedra-10.6.37.dist-info/METADATA +367 -0
- passagemath_polyhedra-10.6.37.dist-info/METADATA.bak +369 -0
- passagemath_polyhedra-10.6.37.dist-info/RECORD +209 -0
- passagemath_polyhedra-10.6.37.dist-info/WHEEL +5 -0
- passagemath_polyhedra-10.6.37.dist-info/top_level.txt +3 -0
- passagemath_polyhedra.libs/libgcc_s-0cd532bd.so.1 +0 -0
- passagemath_polyhedra.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
- passagemath_polyhedra.libs/libgomp-8949ffbe.so.1.0.0 +0 -0
- passagemath_polyhedra.libs/libstdc++-5d72f927.so.6.0.33 +0 -0
- sage/all__sagemath_polyhedra.py +50 -0
- sage/game_theory/all.py +8 -0
- sage/game_theory/catalog.py +6 -0
- sage/game_theory/catalog_normal_form_games.py +923 -0
- sage/game_theory/cooperative_game.py +844 -0
- sage/game_theory/matching_game.py +1181 -0
- sage/game_theory/normal_form_game.py +2697 -0
- sage/game_theory/parser.py +275 -0
- sage/geometry/all__sagemath_polyhedra.py +22 -0
- sage/geometry/cone.py +6940 -0
- sage/geometry/cone_catalog.py +847 -0
- sage/geometry/cone_critical_angles.py +1027 -0
- sage/geometry/convex_set.py +1119 -0
- sage/geometry/fan.py +3743 -0
- sage/geometry/fan_isomorphism.py +389 -0
- sage/geometry/fan_morphism.py +1884 -0
- sage/geometry/hasse_diagram.py +202 -0
- sage/geometry/hyperplane_arrangement/affine_subspace.py +390 -0
- sage/geometry/hyperplane_arrangement/all.py +1 -0
- sage/geometry/hyperplane_arrangement/arrangement.py +3905 -0
- sage/geometry/hyperplane_arrangement/check_freeness.py +145 -0
- sage/geometry/hyperplane_arrangement/hyperplane.py +773 -0
- sage/geometry/hyperplane_arrangement/library.py +825 -0
- sage/geometry/hyperplane_arrangement/ordered_arrangement.py +642 -0
- sage/geometry/hyperplane_arrangement/plot.py +520 -0
- sage/geometry/integral_points.py +35 -0
- sage/geometry/integral_points_generic_dense.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/integral_points_generic_dense.pyx +7 -0
- sage/geometry/lattice_polytope.py +5894 -0
- sage/geometry/linear_expression.py +773 -0
- sage/geometry/newton_polygon.py +767 -0
- sage/geometry/point_collection.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/point_collection.pyx +1008 -0
- sage/geometry/polyhedral_complex.py +2616 -0
- sage/geometry/polyhedron/all.py +8 -0
- sage/geometry/polyhedron/backend_cdd.py +460 -0
- sage/geometry/polyhedron/backend_cdd_rdf.py +231 -0
- sage/geometry/polyhedron/backend_field.py +347 -0
- sage/geometry/polyhedron/backend_normaliz.py +2503 -0
- sage/geometry/polyhedron/backend_number_field.py +168 -0
- sage/geometry/polyhedron/backend_polymake.py +765 -0
- sage/geometry/polyhedron/backend_ppl.py +582 -0
- sage/geometry/polyhedron/base.py +1206 -0
- sage/geometry/polyhedron/base0.py +1444 -0
- sage/geometry/polyhedron/base1.py +886 -0
- sage/geometry/polyhedron/base2.py +812 -0
- sage/geometry/polyhedron/base3.py +1845 -0
- sage/geometry/polyhedron/base4.py +1262 -0
- sage/geometry/polyhedron/base5.py +2700 -0
- sage/geometry/polyhedron/base6.py +1741 -0
- sage/geometry/polyhedron/base7.py +997 -0
- sage/geometry/polyhedron/base_QQ.py +1258 -0
- sage/geometry/polyhedron/base_RDF.py +98 -0
- sage/geometry/polyhedron/base_ZZ.py +934 -0
- sage/geometry/polyhedron/base_mutable.py +215 -0
- sage/geometry/polyhedron/base_number_field.py +122 -0
- sage/geometry/polyhedron/cdd_file_format.py +155 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/all.py +1 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/base.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +76 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +3859 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +39 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +1038 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/conversions.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +9 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +501 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd +207 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +102 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +2274 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +370 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx +84 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +31 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +587 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +52 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +560 -0
- sage/geometry/polyhedron/constructor.py +773 -0
- sage/geometry/polyhedron/double_description.py +753 -0
- sage/geometry/polyhedron/double_description_inhomogeneous.py +564 -0
- sage/geometry/polyhedron/face.py +1060 -0
- sage/geometry/polyhedron/generating_function.py +1810 -0
- sage/geometry/polyhedron/lattice_euclidean_group_element.py +178 -0
- sage/geometry/polyhedron/library.py +3502 -0
- sage/geometry/polyhedron/misc.py +121 -0
- sage/geometry/polyhedron/modules/all.py +1 -0
- sage/geometry/polyhedron/modules/formal_polyhedra_module.py +155 -0
- sage/geometry/polyhedron/palp_database.py +447 -0
- sage/geometry/polyhedron/parent.py +1279 -0
- sage/geometry/polyhedron/plot.py +1986 -0
- sage/geometry/polyhedron/ppl_lattice_polygon.py +556 -0
- sage/geometry/polyhedron/ppl_lattice_polytope.py +1257 -0
- sage/geometry/polyhedron/representation.py +1723 -0
- sage/geometry/pseudolines.py +515 -0
- sage/geometry/relative_interior.py +445 -0
- sage/geometry/toric_plotter.py +1103 -0
- sage/geometry/triangulation/all.py +2 -0
- sage/geometry/triangulation/base.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/triangulation/base.pyx +963 -0
- sage/geometry/triangulation/data.h +147 -0
- sage/geometry/triangulation/data.pxd +4 -0
- sage/geometry/triangulation/element.py +914 -0
- sage/geometry/triangulation/functions.h +10 -0
- sage/geometry/triangulation/functions.pxd +4 -0
- sage/geometry/triangulation/point_configuration.py +2256 -0
- sage/geometry/triangulation/triangulations.h +49 -0
- sage/geometry/triangulation/triangulations.pxd +7 -0
- sage/geometry/voronoi_diagram.py +319 -0
- sage/interfaces/all__sagemath_polyhedra.py +1 -0
- sage/interfaces/polymake.py +2028 -0
- sage/numerical/all.py +13 -0
- sage/numerical/all__sagemath_polyhedra.py +11 -0
- sage/numerical/backends/all.py +1 -0
- sage/numerical/backends/all__sagemath_polyhedra.py +1 -0
- sage/numerical/backends/cvxopt_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/cvxopt_backend.pyx +1006 -0
- sage/numerical/backends/cvxopt_backend_test.py +19 -0
- sage/numerical/backends/cvxopt_sdp_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/cvxopt_sdp_backend.pyx +382 -0
- sage/numerical/backends/cvxpy_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/cvxpy_backend.pxd +41 -0
- sage/numerical/backends/cvxpy_backend.pyx +934 -0
- sage/numerical/backends/cvxpy_backend_test.py +13 -0
- sage/numerical/backends/generic_backend_test.py +24 -0
- sage/numerical/backends/interactivelp_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/interactivelp_backend.pxd +36 -0
- sage/numerical/backends/interactivelp_backend.pyx +1231 -0
- sage/numerical/backends/interactivelp_backend_test.py +12 -0
- sage/numerical/backends/logging_backend.py +391 -0
- sage/numerical/backends/matrix_sdp_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/matrix_sdp_backend.pxd +15 -0
- sage/numerical/backends/matrix_sdp_backend.pyx +478 -0
- sage/numerical/backends/ppl_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/ppl_backend.pyx +1126 -0
- sage/numerical/backends/ppl_backend_test.py +13 -0
- sage/numerical/backends/scip_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/scip_backend.pxd +22 -0
- sage/numerical/backends/scip_backend.pyx +1289 -0
- sage/numerical/backends/scip_backend_test.py +13 -0
- sage/numerical/interactive_simplex_method.py +5338 -0
- sage/numerical/knapsack.py +665 -0
- sage/numerical/linear_functions.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/linear_functions.pxd +31 -0
- sage/numerical/linear_functions.pyx +1648 -0
- sage/numerical/linear_tensor.py +470 -0
- sage/numerical/linear_tensor_constraints.py +448 -0
- sage/numerical/linear_tensor_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/linear_tensor_element.pxd +6 -0
- sage/numerical/linear_tensor_element.pyx +459 -0
- sage/numerical/mip.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/mip.pxd +40 -0
- sage/numerical/mip.pyx +3667 -0
- sage/numerical/sdp.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/sdp.pxd +39 -0
- sage/numerical/sdp.pyx +1433 -0
- sage/rings/all__sagemath_polyhedra.py +3 -0
- sage/rings/polynomial/all__sagemath_polyhedra.py +10 -0
- sage/rings/polynomial/omega.py +982 -0
- sage/schemes/all__sagemath_polyhedra.py +2 -0
- sage/schemes/toric/all.py +10 -0
- sage/schemes/toric/chow_group.py +1248 -0
- sage/schemes/toric/divisor.py +2082 -0
- sage/schemes/toric/divisor_class.cpython-314-x86_64-linux-musl.so +0 -0
- sage/schemes/toric/divisor_class.pyx +322 -0
- sage/schemes/toric/fano_variety.py +1606 -0
- sage/schemes/toric/homset.py +650 -0
- sage/schemes/toric/ideal.py +451 -0
- sage/schemes/toric/library.py +1322 -0
- sage/schemes/toric/morphism.py +1958 -0
- sage/schemes/toric/points.py +1032 -0
- sage/schemes/toric/sheaf/all.py +1 -0
- sage/schemes/toric/sheaf/constructor.py +302 -0
- sage/schemes/toric/sheaf/klyachko.py +921 -0
- sage/schemes/toric/toric_subscheme.py +905 -0
- sage/schemes/toric/variety.py +3460 -0
- sage/schemes/toric/weierstrass.py +1078 -0
- sage/schemes/toric/weierstrass_covering.py +457 -0
- sage/schemes/toric/weierstrass_higher.py +288 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.info +10 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v03 +0 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v04 +0 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v05 +1 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v06 +1 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.info +22 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v04 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v05 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v06 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v07 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v08 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v09 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v10 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v11 +1 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v12 +1 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v13 +1 -0
- sage_wheels/share/reflexive_polytopes/reflexive_polytopes_2d +80 -0
- sage_wheels/share/reflexive_polytopes/reflexive_polytopes_3d +37977 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* sage_setup: distribution = sagemath-polyhedra
|
|
2
|
+
*/
|
|
3
|
+
#ifndef TRIANGULATION__H
|
|
4
|
+
#define TRIANGULATION__H
|
|
5
|
+
|
|
6
|
+
#include "data.h"
|
|
7
|
+
#include <Python.h>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class triangulations: public std::vector<compact_simplices>
|
|
11
|
+
{
|
|
12
|
+
private:
|
|
13
|
+
hash_value hash_max;
|
|
14
|
+
compact_simplices no_triangulation_instance;
|
|
15
|
+
compact_simplices::const_iterator no_triangulation;
|
|
16
|
+
std::vector<size_t> hash_list;
|
|
17
|
+
flips bistellar_flips;
|
|
18
|
+
int position;
|
|
19
|
+
int star;
|
|
20
|
+
bool fine;
|
|
21
|
+
mutable bool need_resize;
|
|
22
|
+
protected:
|
|
23
|
+
void find_hash_position(const compact_simplices&, hash_value&, bool&) const;
|
|
24
|
+
void add_triangulation(const compact_simplices &);
|
|
25
|
+
public:
|
|
26
|
+
triangulations(const flips&);
|
|
27
|
+
|
|
28
|
+
void add_triang_if_new(const compact_simplices &);
|
|
29
|
+
void add_neighbours(const simplices &);
|
|
30
|
+
|
|
31
|
+
void require_star_triangulation(const int s=-1) { star=s; };
|
|
32
|
+
void require_fine_triangulation(const bool f=true) { fine=f; };
|
|
33
|
+
|
|
34
|
+
bool have_more_triangulations();
|
|
35
|
+
const compact_simplices& next_triangulation();
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
typedef triangulations* triangulations_ptr;
|
|
40
|
+
|
|
41
|
+
triangulations_ptr init_triangulations
|
|
42
|
+
(int n, int d, int star, bool fine, PyObject* py_seed, PyObject* py_flips);
|
|
43
|
+
|
|
44
|
+
PyObject* next_triangulation(triangulations_ptr);
|
|
45
|
+
|
|
46
|
+
void delete_triangulations(triangulations_ptr);
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
#endif
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-polyhedra
|
|
2
|
+
cdef extern from "triangulations.h":
|
|
3
|
+
ctypedef void* triangulations_ptr
|
|
4
|
+
cdef triangulations_ptr init_triangulations \
|
|
5
|
+
(int n, int d, int star, bint fine, object seed, object flips)
|
|
6
|
+
cdef object next_triangulation(triangulations_ptr)
|
|
7
|
+
cdef void delete_triangulations(triangulations_ptr)
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-polyhedra
|
|
2
|
+
r"""
|
|
3
|
+
Voronoi diagram
|
|
4
|
+
|
|
5
|
+
This module provides the class :class:`VoronoiDiagram` for computing the
|
|
6
|
+
Voronoi diagram of a finite list of points in `\RR^d`.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# ****************************************************************************
|
|
10
|
+
# Copyright (C) 2012 Moritz Firsching <moritz@math.fu-berlin.de>
|
|
11
|
+
#
|
|
12
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
13
|
+
#
|
|
14
|
+
# https://www.gnu.org/licenses/
|
|
15
|
+
# ****************************************************************************
|
|
16
|
+
|
|
17
|
+
from sage.structure.sage_object import SageObject
|
|
18
|
+
from sage.geometry.polyhedron.constructor import Polyhedron
|
|
19
|
+
from sage.rings.rational_field import QQ
|
|
20
|
+
import sage.rings.abc
|
|
21
|
+
from sage.geometry.triangulation.point_configuration import PointConfiguration
|
|
22
|
+
from sage.modules.free_module_element import vector
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class VoronoiDiagram(SageObject):
|
|
26
|
+
r"""
|
|
27
|
+
Base class for the Voronoi diagram.
|
|
28
|
+
|
|
29
|
+
Compute the Voronoi diagram of a list of points.
|
|
30
|
+
|
|
31
|
+
INPUT:
|
|
32
|
+
|
|
33
|
+
- ``points`` -- list of points; any valid input for the
|
|
34
|
+
:class:`PointConfiguration` will do
|
|
35
|
+
|
|
36
|
+
OUTPUT: an instance of the VoronoiDiagram class
|
|
37
|
+
|
|
38
|
+
EXAMPLES:
|
|
39
|
+
|
|
40
|
+
Get the Voronoi diagram for some points in `\RR^3`::
|
|
41
|
+
|
|
42
|
+
sage: V = VoronoiDiagram([[1, 3, .3], [2, -2, 1], [-1, 2, -.1]]); V # needs cddexec_gmp
|
|
43
|
+
The Voronoi diagram of 3 points of dimension 3 in the Real Double Field
|
|
44
|
+
|
|
45
|
+
sage: VoronoiDiagram([])
|
|
46
|
+
The empty Voronoi diagram.
|
|
47
|
+
|
|
48
|
+
Get the Voronoi diagram of a regular pentagon in ``AA^2``.
|
|
49
|
+
All cells meet at the origin::
|
|
50
|
+
|
|
51
|
+
sage: DV = VoronoiDiagram([[AA(c) for c in v] # needs sage.rings.number_field
|
|
52
|
+
....: for v in polytopes.regular_polygon(5).vertices_list()]); DV
|
|
53
|
+
The Voronoi diagram of 5 points of dimension 2 in the Algebraic Real Field
|
|
54
|
+
sage: all(P.contains([0, 0]) for P in DV.regions().values()) # needs sage.rings.number_field
|
|
55
|
+
True
|
|
56
|
+
sage: any(P.interior_contains([0, 0]) for P in DV.regions().values()) # needs sage.rings.number_field
|
|
57
|
+
False
|
|
58
|
+
|
|
59
|
+
If the vertices are not converted to ``AA`` before, the method throws an error::
|
|
60
|
+
|
|
61
|
+
sage: polytopes.dodecahedron().vertices_list()[0][0].parent() # needs sage.groups sage.rings.number_field
|
|
62
|
+
Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?
|
|
63
|
+
sage: VoronoiDiagram(polytopes.dodecahedron().vertices_list()) # needs sage.groups sage.rings.number_field
|
|
64
|
+
Traceback (most recent call last):
|
|
65
|
+
...
|
|
66
|
+
NotImplementedError: Base ring of the Voronoi diagram must be
|
|
67
|
+
one of QQ, RDF, AA.
|
|
68
|
+
|
|
69
|
+
ALGORITHM:
|
|
70
|
+
|
|
71
|
+
We use hyperplanes tangent to the paraboloid one dimension higher to
|
|
72
|
+
get a convex polyhedron and then project back to one dimension lower.
|
|
73
|
+
|
|
74
|
+
.. TODO::
|
|
75
|
+
|
|
76
|
+
- The dual construction: Delaunay triangulation
|
|
77
|
+
- improve 2d-plotting
|
|
78
|
+
- implement 3d-plotting
|
|
79
|
+
- more general constructions, like Voroi diagrams with weights (power diagrams)
|
|
80
|
+
|
|
81
|
+
REFERENCES:
|
|
82
|
+
|
|
83
|
+
- [Mat2002]_ Ch.5.7, p.118.
|
|
84
|
+
|
|
85
|
+
AUTHORS:
|
|
86
|
+
|
|
87
|
+
- Moritz Firsching (2012-09-21)
|
|
88
|
+
"""
|
|
89
|
+
def __init__(self, points):
|
|
90
|
+
r"""
|
|
91
|
+
See ``VoronoiDiagram`` for full documentation.
|
|
92
|
+
|
|
93
|
+
EXAMPLES::
|
|
94
|
+
|
|
95
|
+
sage: V = VoronoiDiagram([[1, 3, 3], [2, -2, 1], [-1 ,2, -1]]); V
|
|
96
|
+
The Voronoi diagram of 3 points of dimension 3 in the Rational Field
|
|
97
|
+
"""
|
|
98
|
+
self._P = {}
|
|
99
|
+
self._points = PointConfiguration(points)
|
|
100
|
+
self._n = self._points.n_points()
|
|
101
|
+
if not self._n or self._points.base_ring().is_subring(QQ):
|
|
102
|
+
self._base_ring = QQ
|
|
103
|
+
elif isinstance(self._points.base_ring(), (sage.rings.abc.RealDoubleField, sage.rings.abc.AlgebraicRealField)):
|
|
104
|
+
self._base_ring = self._points.base_ring()
|
|
105
|
+
elif isinstance(self._points.base_ring(), sage.rings.abc.RealField):
|
|
106
|
+
from sage.rings.real_double import RDF
|
|
107
|
+
self._base_ring = RDF
|
|
108
|
+
self._points = PointConfiguration([[RDF(cor) for cor in poi]
|
|
109
|
+
for poi in self._points])
|
|
110
|
+
else:
|
|
111
|
+
raise NotImplementedError('Base ring of the Voronoi diagram must '
|
|
112
|
+
'be one of QQ, RDF, AA.')
|
|
113
|
+
|
|
114
|
+
if self._n > 0:
|
|
115
|
+
self._d = self._points.ambient_dim()
|
|
116
|
+
e = [([sum(vector(i)[k] ** 2
|
|
117
|
+
for k in range(self._d))] +
|
|
118
|
+
[(-2) * vector(i)[l] for l in range(self._d)] + [1])
|
|
119
|
+
for i in self._points]
|
|
120
|
+
# we attach hyperplane to the paraboloid
|
|
121
|
+
|
|
122
|
+
e = [[self._base_ring(i) for i in k] for k in e]
|
|
123
|
+
p = Polyhedron(ieqs=e, base_ring=self._base_ring)
|
|
124
|
+
# To understand the reordering that takes place when
|
|
125
|
+
# defining a rational polyhedron, we generate two sorted
|
|
126
|
+
# lists, that are used a few lines below
|
|
127
|
+
if self.base_ring() == QQ:
|
|
128
|
+
enormalized = []
|
|
129
|
+
for ineq in e:
|
|
130
|
+
if ineq[0] == 0:
|
|
131
|
+
enormalized.append(ineq)
|
|
132
|
+
else:
|
|
133
|
+
enormalized.append([i / ineq[0] for i in ineq[1:]])
|
|
134
|
+
hlist = [list(ineq) for ineq in p.Hrepresentation()]
|
|
135
|
+
hlistnormalized = []
|
|
136
|
+
for ineq in hlist:
|
|
137
|
+
if ineq[0] == 0:
|
|
138
|
+
hlistnormalized.append(ineq)
|
|
139
|
+
else:
|
|
140
|
+
hlistnormalized.append([i / ineq[0] for i in ineq[1:]])
|
|
141
|
+
|
|
142
|
+
for i in range(self._n):
|
|
143
|
+
# for base ring RDF and AA, Polyhedron keeps the order of the
|
|
144
|
+
# points in the input, for QQ we resort
|
|
145
|
+
if self.base_ring() == QQ:
|
|
146
|
+
equ = p.Hrepresentation(hlistnormalized.index(enormalized[i]))
|
|
147
|
+
else:
|
|
148
|
+
equ = p.Hrepresentation(i)
|
|
149
|
+
pvert = [[u[k] for k in range(self._d)] for u in equ.incident()
|
|
150
|
+
if u.is_vertex()]
|
|
151
|
+
prays = [[u[k] for k in range(self._d)] for u in equ.incident()
|
|
152
|
+
if u.is_ray()]
|
|
153
|
+
pline = [[u[k] for k in range(self._d)] for u in equ.incident()
|
|
154
|
+
if u.is_line()]
|
|
155
|
+
(self._P)[self._points[i]] = Polyhedron(vertices=pvert,
|
|
156
|
+
lines=pline, rays=prays,
|
|
157
|
+
base_ring=self._base_ring)
|
|
158
|
+
|
|
159
|
+
def points(self):
|
|
160
|
+
r"""
|
|
161
|
+
Return the input points (as a PointConfiguration).
|
|
162
|
+
|
|
163
|
+
EXAMPLES::
|
|
164
|
+
|
|
165
|
+
sage: V = VoronoiDiagram([[.5, 3], [2, 5], [4, 5], [4, -1]]); V.points() # needs cddexec_gmp
|
|
166
|
+
A point configuration in affine 2-space over Real Field
|
|
167
|
+
with 53 bits of precision consisting of 4 points.
|
|
168
|
+
The triangulations of this point configuration are
|
|
169
|
+
assumed to be connected, not necessarily fine,
|
|
170
|
+
not necessarily regular.
|
|
171
|
+
"""
|
|
172
|
+
return self._points
|
|
173
|
+
|
|
174
|
+
def ambient_dim(self):
|
|
175
|
+
r"""
|
|
176
|
+
Return the ambient dimension of the points.
|
|
177
|
+
|
|
178
|
+
EXAMPLES::
|
|
179
|
+
|
|
180
|
+
sage: # needs cddexec_gmp
|
|
181
|
+
sage: V = VoronoiDiagram([[.5, 3], [2, 5], [4, 5], [4, -1]])
|
|
182
|
+
sage: V.ambient_dim()
|
|
183
|
+
2
|
|
184
|
+
sage: V = VoronoiDiagram([[1, 2, 3, 4, 5, 6]]); V.ambient_dim()
|
|
185
|
+
6
|
|
186
|
+
"""
|
|
187
|
+
return self._d
|
|
188
|
+
|
|
189
|
+
def regions(self):
|
|
190
|
+
r"""
|
|
191
|
+
Return the Voronoi regions of the Voronoi diagram as a
|
|
192
|
+
dictionary of polyhedra.
|
|
193
|
+
|
|
194
|
+
EXAMPLES::
|
|
195
|
+
|
|
196
|
+
sage: # needs cddexec_gmp
|
|
197
|
+
sage: V = VoronoiDiagram([[1, 3, .3], [2, -2, 1], [-1, 2, -.1]])
|
|
198
|
+
sage: P = V.points()
|
|
199
|
+
sage: V.regions() == {P[0]: Polyhedron(base_ring=RDF, lines=[(-RDF(0.375), RDF(0.13888888890000001), RDF(1.5277777779999999))],
|
|
200
|
+
....: rays=[(RDF(9), -RDF(1), -RDF(20)), (RDF(4.5), RDF(1), -RDF(25))],
|
|
201
|
+
....: vertices=[(-RDF(1.1074999999999999), RDF(1.149444444), RDF(9.0138888890000004))]),
|
|
202
|
+
....: P[1]: Polyhedron(base_ring=RDF, lines=[(-RDF(0.375), RDF(0.13888888890000001), RDF(1.5277777779999999))],
|
|
203
|
+
....: rays=[(RDF(9), -RDF(1), -RDF(20)), (-RDF(2.25), -RDF(1), RDF(2.5))],
|
|
204
|
+
....: vertices=[(-RDF(1.1074999999999999), RDF(1.149444444), RDF(9.0138888890000004))]),
|
|
205
|
+
....: P[2]: Polyhedron(base_ring=RDF, lines=[(-RDF(0.375), RDF(0.13888888890000001), RDF(1.5277777779999999))],
|
|
206
|
+
....: rays=[(RDF(4.5), RDF(1), -RDF(25)), (-RDF(2.25), -RDF(1), RDF(2.5))],
|
|
207
|
+
....: vertices=[(-RDF(1.1074999999999999), RDF(1.149444444), RDF(9.0138888890000004))])}
|
|
208
|
+
True
|
|
209
|
+
"""
|
|
210
|
+
return self._P
|
|
211
|
+
|
|
212
|
+
def base_ring(self):
|
|
213
|
+
r"""
|
|
214
|
+
Return the base_ring of the regions of the Voronoi diagram.
|
|
215
|
+
|
|
216
|
+
EXAMPLES::
|
|
217
|
+
|
|
218
|
+
sage: V = VoronoiDiagram([[1, 3, 1], [2, -2, 1], [-1, 2, 1/2]]); V.base_ring()
|
|
219
|
+
Rational Field
|
|
220
|
+
sage: V = VoronoiDiagram([[1, 3.14], [2, -2/3], [-1, 22]]); V.base_ring() # needs cddexec_gmp
|
|
221
|
+
Real Double Field
|
|
222
|
+
sage: V = VoronoiDiagram([[1, 3], [2, 4]]); V.base_ring()
|
|
223
|
+
Rational Field
|
|
224
|
+
"""
|
|
225
|
+
return self._base_ring
|
|
226
|
+
|
|
227
|
+
def _repr_(self):
|
|
228
|
+
r"""
|
|
229
|
+
Return a description of the Voronoi diagram.
|
|
230
|
+
|
|
231
|
+
EXAMPLES::
|
|
232
|
+
|
|
233
|
+
sage: V = VoronoiDiagram(polytopes.regular_polygon(3).vertices()); V # needs sage.rings.number_field
|
|
234
|
+
The Voronoi diagram of 3 points of dimension 2 in the Algebraic Real Field
|
|
235
|
+
sage: VoronoiDiagram([])
|
|
236
|
+
The empty Voronoi diagram.
|
|
237
|
+
"""
|
|
238
|
+
if self._n:
|
|
239
|
+
desc = 'The Voronoi diagram of ' + str(self._n)
|
|
240
|
+
desc += ' points of dimension ' + str(self.ambient_dim())
|
|
241
|
+
desc += ' in the ' + str(self.base_ring())
|
|
242
|
+
return desc
|
|
243
|
+
|
|
244
|
+
return 'The empty Voronoi diagram.'
|
|
245
|
+
|
|
246
|
+
def plot(self, cell_colors=None, **kwds):
|
|
247
|
+
"""
|
|
248
|
+
Return a graphical representation for 2-dimensional Voronoi diagrams.
|
|
249
|
+
|
|
250
|
+
INPUT:
|
|
251
|
+
|
|
252
|
+
- ``cell_colors`` -- (default: ``None``) provide the colors for the cells, either as
|
|
253
|
+
dictionary. Randomly colored cells are provided with ``None``.
|
|
254
|
+
- ``**kwds`` -- optional keyword parameters, passed on as arguments for
|
|
255
|
+
plot()
|
|
256
|
+
|
|
257
|
+
OUTPUT: a graphics object
|
|
258
|
+
|
|
259
|
+
EXAMPLES::
|
|
260
|
+
|
|
261
|
+
sage: # needs cddexec_gmp sage.plot
|
|
262
|
+
sage: P = [[0.671, 0.650], [0.258, 0.767], [0.562, 0.406],
|
|
263
|
+
....: [0.254, 0.709], [0.493, 0.879]]
|
|
264
|
+
sage: V = VoronoiDiagram(P); S = V.plot()
|
|
265
|
+
sage: show(S, xmin=0, xmax=1, ymin=0, ymax=1, aspect_ratio=1, axes=false)
|
|
266
|
+
sage: S = V.plot(cell_colors={0: 'red', 1: 'blue', 2: 'green',
|
|
267
|
+
....: 3: 'white', 4: 'yellow'})
|
|
268
|
+
sage: show(S, xmin=0, xmax=1, ymin=0, ymax=1, aspect_ratio=1, axes=false)
|
|
269
|
+
sage: S = V.plot(cell_colors=['red', 'blue', 'red', 'white', 'white'])
|
|
270
|
+
sage: show(S, xmin=0, xmax=1, ymin=0, ymax=1, aspect_ratio=1, axes=false)
|
|
271
|
+
sage: S = V.plot(cell_colors='something else')
|
|
272
|
+
Traceback (most recent call last):
|
|
273
|
+
...
|
|
274
|
+
AssertionError: 'cell_colors' must be a list or a dictionary
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
Trying to plot a Voronoi diagram of dimension other than 2 gives an
|
|
278
|
+
error::
|
|
279
|
+
|
|
280
|
+
sage: VoronoiDiagram([[1, 2, 3], [6, 5, 4]]).plot() # needs sage.plot
|
|
281
|
+
Traceback (most recent call last):
|
|
282
|
+
...
|
|
283
|
+
NotImplementedError: Plotting of 3-dimensional Voronoi diagrams not
|
|
284
|
+
implemented
|
|
285
|
+
"""
|
|
286
|
+
from sage.plot.all import line, point, rainbow, plot
|
|
287
|
+
|
|
288
|
+
if self.ambient_dim() == 2:
|
|
289
|
+
S = line([])
|
|
290
|
+
|
|
291
|
+
if cell_colors is None:
|
|
292
|
+
from random import shuffle
|
|
293
|
+
cell_colors = rainbow(self._n)
|
|
294
|
+
shuffle(cell_colors)
|
|
295
|
+
else:
|
|
296
|
+
if not isinstance(cell_colors, (list, dict)):
|
|
297
|
+
raise AssertionError("'cell_colors' must be a list or a dictionary")
|
|
298
|
+
for i, p in enumerate(self._P):
|
|
299
|
+
col = cell_colors[i]
|
|
300
|
+
S += (self.regions()[p]).render_solid(color=col, zorder=1)
|
|
301
|
+
S += point(p, color=col, pointsize=10, zorder=3)
|
|
302
|
+
S += point(p, color='black', pointsize=20, zorder=2)
|
|
303
|
+
return plot(S, **kwds)
|
|
304
|
+
raise NotImplementedError('Plotting of ' + str(self.ambient_dim()) +
|
|
305
|
+
'-dimensional Voronoi diagrams not' +
|
|
306
|
+
' implemented')
|
|
307
|
+
|
|
308
|
+
def _are_points_in_regions(self):
|
|
309
|
+
"""
|
|
310
|
+
Check if all points are contained in their regions.
|
|
311
|
+
|
|
312
|
+
EXAMPLES::
|
|
313
|
+
|
|
314
|
+
sage: py_trips = [[a, b] for a in range(1, 50) for b in range(1, 50) if ZZ(a^2 + b^2).is_square()]
|
|
315
|
+
sage: v = VoronoiDiagram(py_trips)
|
|
316
|
+
sage: v._are_points_in_regions()
|
|
317
|
+
True
|
|
318
|
+
"""
|
|
319
|
+
return all(self.regions()[p].contains(p) for p in self.points())
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-polyhedra
|