]>
gitweb.michael.orlitzky.com - sage.d.git/blob - cone/permutation_invariant.py
3 def random_permutation_invariant_cone(lattice
=None,
11 Return a random permutation-invariant cone.
13 A cone ``K`` is said to be permutation-invariant if ``P(K) == K``
14 for all permutation matrices ``P``. To generate one, we can begin
15 with any cone, and construct the set of all permutations of its
16 generators. The resulting set will generate a permutation-invariant
19 All of this function's parameters are passed to ``random_cone()``
20 function used to generate the initial cone whose generators we will
23 K
= random_cone(lattice
=lattice
,
24 min_ambient_dim
=min_ambient_dim
,
25 max_ambient_dim
=max_ambient_dim
,
28 strictly_convex
=strictly_convex
,
31 # We'll need this to turn rays into vectors so that we can permute
32 # them with permutation matrices.
33 V
= K
.lattice().vector_space()
35 # The set of all permutatin matrices on ``V``.
36 Sn
= [ p
.matrix() for p
in SymmetricGroup(V
.dimension()) ]
38 # Set of permuted generators
42 for permutation
in Sn
:
43 pgens
.append(permutation
* V(g
))
45 L
= ToricLattice(V
.dimension())
46 return Cone(pgens
, lattice
=L
)
49 def is_permutation_invariant(K
):
51 Determine if ``K`` is permutation-invariant.
53 A cone is said to be permutation-invariant if ``P(K)`` is a subset
54 of ``K`` for every permutation matrix ``P``.
58 sage: from mjo.cone.rearrangement import rearrangement_cone
59 sage: from mjo.cone.permutation_invariant import is_permutation_invariant
63 sage: all([ is_permutation_invariant(rearrangement_cone(p,n))
64 ....: for n in range(3, 6)
65 ....: for p in range(1, n) ])
69 # We'll need this to turn rays into vectors so that we can permute
70 # them with permutation matrices.
71 V
= K
.lattice().vector_space()
73 # The set of all permutation matrices on ``V``.
74 Sn
= [ p
.matrix() for p
in SymmetricGroup(V
.dimension()) ]
76 for permutation
in Sn
:
77 L
= ToricLattice(V
.dimension())
78 permuted_gens
= [ permutation
* V(g
) for g
in K
.rays() ]
79 for g
in permuted_gens
: