- sage: e1 = (1,0,0,0,0)
- sage: neg_e1 = (-1,0,0,0,0)
- sage: e2 = (0,1,0,0,0)
- sage: neg_e2 = (0,-1,0,0,0)
- sage: z = (0,0,0,0,0)
- sage: K = Cone([e1, neg_e1, e2, neg_e2, z, z, z])
- sage: lyapunov_rank(K)
- 19
- sage: K.lattice_dim()**2 - K.dim()*codim(K)
- 19
-
- The Lyapunov rank should be additive on a product of proper cones
- [Rudolf et al.]_::
-
- sage: L31 = Cone([(1,0,1), (0,-1,1), (-1,0,1), (0,1,1)])
- sage: octant = Cone([(1,0,0), (0,1,0), (0,0,1)])
- sage: K = L31.cartesian_product(octant)
- sage: lyapunov_rank(K) == lyapunov_rank(L31) + lyapunov_rank(octant)
- True
-
- Two isomorphic cones should have the same Lyapunov rank [Rudolf et al.]_.
- The cone ``K`` in the following example is isomorphic to the nonnegative
- octant in `\mathbb{R}^{3}`::
-
- sage: K = Cone([(1,2,3), (-1,1,0), (1,0,6)])
- sage: lyapunov_rank(K)
- 3
-
- The dual cone `K^{*}` of ``K`` should have the same Lyapunov rank as ``K``
- itself [Rudolf et al.]_::
-
- sage: K = Cone([(2,2,4), (-1,9,0), (2,0,6)])
- sage: lyapunov_rank(K) == lyapunov_rank(K.dual())
- True
-
- TESTS:
-
- The Lyapunov rank should be additive on a product of proper cones
- [Rudolf et al.]_::
-
- sage: set_random_seed()
- sage: K1 = random_cone(max_dim=8, strictly_convex=True, solid=True)
- sage: K2 = random_cone(max_dim=8, strictly_convex=True, solid=True)
- sage: K = K1.cartesian_product(K2)
- sage: lyapunov_rank(K) == lyapunov_rank(K1) + lyapunov_rank(K2)
- True
-
- The dual cone `K^{*}` of ``K`` should have the same Lyapunov rank as ``K``
- itself [Rudolf et al.]_::
-
- sage: set_random_seed()
- sage: K = random_cone(max_dim=8)
- sage: lyapunov_rank(K) == lyapunov_rank(K.dual())
- True
-
- Make sure we exercise the non-strictly-convex/non-solid case::
-
- sage: set_random_seed()
- sage: K = random_cone(max_dim=8, strictly_convex=False, solid=False)
- sage: lyapunov_rank(K) == lyapunov_rank(K.dual())
- True
-
- Let's check the other permutations as well, just to be sure::
-
- sage: set_random_seed()
- sage: K = random_cone(max_dim=8, strictly_convex=False, solid=True)
- sage: lyapunov_rank(K) == lyapunov_rank(K.dual())
- True
-
- ::
-
- sage: set_random_seed()
- sage: K = random_cone(max_dim=8, strictly_convex=True, solid=False)
- sage: lyapunov_rank(K) == lyapunov_rank(K.dual())
- True
-
- ::
-
- sage: set_random_seed()
- sage: K = random_cone(max_dim=8, strictly_convex=True, solid=True)
- sage: lyapunov_rank(K) == lyapunov_rank(K.dual())
- True
-
- The Lyapunov rank of a proper polyhedral cone in `n` dimensions can
- be any number between `1` and `n` inclusive, excluding `n-1`
- [Gowda/Tao]_. By accident, the `n-1` restriction will hold for the
- trivial cone in a trivial space as well. However, in zero dimensions,
- the Lyapunov rank of the trivial cone will be zero::
-
- sage: set_random_seed()
- sage: K = random_cone(max_dim=8, strictly_convex=True, solid=True)
- sage: b = lyapunov_rank(K)
- sage: n = K.lattice_dim()
- sage: (n == 0 or 1 <= b) and b <= n
+ sage: K = Cone([(1,0),(0,1)])
+ sage: Z_transformations(K)
+ [
+ [ 0 -1] [ 0 0] [-1 0] [1 0] [ 0 0] [0 0]
+ [ 0 0], [-1 0], [ 0 0], [0 0], [ 0 -1], [0 1]
+ ]
+ sage: K = Cone([(1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1)])
+ sage: all([ z[i][j] <= 0 for z in Z_transformations(K)
+ ....: for i in range(z.nrows())
+ ....: for j in range(z.ncols())
+ ....: if i != j ])