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([ rearrangement_cone(p,n).lyapunov_rank() == n
+ ....: for n in range(2, 10)
+ ....: for p in [1, n-1] ])
+ True
+ sage: all([ rearrangement_cone(p,n).lyapunov_rank() == 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
"""
V = VectorSpace(QQ, n)
G = V.basis() + [ d(j) for j in range(n) ]
return Cone(G)
+
+
+def has_rearrangement_property(v, p):
+ r"""
+ Test if the vector ``v`` has the "rearrangement property."
+
+ The rearrangement cone of order ``p`` in `n` dimensions has its
+ members vectors of length `n`. The "rearrangement property,"
+ satisfied by its elements, is to have its smallest ``p`` components
+ sum to a nonnegative number.
+
+ We believe that we have a description of the extreme vectors of the
+ rearrangement cone: see ``rearrangement_cone()``. This function is
+ used to test that conic combinations of those extreme vectors are in
+ fact elements of the rearrangement cone. We can't test all conic
+ combinations, obviously, but we can test a random one.
+
+ To become more sure of the result, generate a bunch of vectors with
+ ``random_element()`` and test them with this function.
+
+ INPUT:
+
+ - ``v`` -- An element of a cone suspected of being the rearrangement
+ cone of order ``p``.
+
+ - ``p`` -- The suspected order of the rearrangement cone.
+
+ OUTPUT:
+
+ If ``v`` has the rearrangement property (that is, if its smallest ``p``
+ components sum to a nonnegative number), ``True`` is returned. Otherwise
+ ``False`` is returned.
+
+ EXAMPLES:
+
+ Every element of a rearrangement cone should have the property::
+
+ sage: for n in range(2,10):
+ ....: for p in range(1, n-1):
+ ....: K = rearrangement_cone(p,n)
+ ....: v = K.random_element()
+ ....: if not has_rearrangement_property(v,p): print v
+
+ """
+ components = sorted(v)[0:p]
+ return sum(components) >= 0