addsitedir(abspath('../../'))
from sage.all import *
+from mjo.cone.cone import lyapunov_rank
def rearrangement_cone(p,n):
r"""
sage: rearrangement_cone(5,5).lineality()
4
+ All rearrangement cones are proper::
+
+ sage: all([ rearrangement_cone(p,n).is_proper()
+ ....: for n in range(10)
+ ....: for p in range(n) ])
+ True
+
+ The Lyapunov rank of the rearrangement cone of order ``p`` in ``n``
+ dimensions is ``n`` for ``p == 1`` or ``p == n`` and one otherwise::
+
+ sage: all([ lyapunov_rank(rearrangement_cone(p,n)) == n
+ ....: for n in range(2, 10)
+ ....: for p in [1, n-1] ])
+ True
+ sage: all([ lyapunov_rank(rearrangement_cone(p,n)) == 1
+ ....: for n in range(3, 10)
+ ....: for p in range(2, n-1) ])
+ True
+
TESTS:
- todo.
- should be permutation invariant.
- should have the expected lyapunov rank.
- just loop through them all for n <= 10 and p < n?
+ The rearrangement cone is permutation-invariant::
+
+ sage: n = ZZ.random_element(2,10).abs()
+ sage: p = ZZ.random_element(1,n)
+ sage: K = rearrangement_cone(p,n)
+ sage: P = SymmetricGroup(n).random_element().matrix()
+ sage: all([ K.contains(P*r) for r in K.rays() ])
+ True
"""