- sage: n = ZZ.random_element().abs()
- sage: K = Cone([[0] * n], ToricLattice(n))
- sage: K.is_trivial()
- True
- sage: L = ToricLattice(n^2)
- sage: Z_of_K = Z_transformation_gens(K)
- sage: Z_cone = Cone([z.list() for z in Z_of_K],
- ....: lattice=L,
- ....: check=False)
- sage: actual = Z_cone.dim()
- sage: actual == n^2
- True
- sage: K = K.dual()
- sage: K.is_full_space()
- True
- sage: Z_of_K = Z_transformation_gens(K)
- sage: Z_cone = Cone([z.list() for z in Z_of_K],
- ....: lattice=L,
- ....: check=False)
- sage: actual = Z_cone.dim()
- sage: actual == n^2
- True
- sage: K = Cone([(1,0),(0,1),(0,-1)])
- sage: Z_of_K = Z_transformation_gens(K)
- sage: Z_cone = Cone([z.list() for z in Z_of_K], check=False)
- sage: Z_cone.dim() == 3
- True
- """
- # Matrices are not vectors in Sage, so we have to convert them
- # to vectors explicitly before we can find a basis. We need these
- # two values to construct the appropriate "long vector" space.
- F = K.lattice().base_field()
- n = K.lattice_dim()
-
- # These tensor products contain generators for the dual cone of
- # the cross-positive transformations.
- tensor_products = [ s.tensor_product(x)
- for (x,s) in K.discrete_complementarity_set() ]
-
- # Turn our matrices into long vectors...
- W = VectorSpace(F, n**2)
- vectors = [ W(m.list()) for m in tensor_products ]
-
- check = True
- if K.is_solid() or K.is_strictly_convex():
- # The lineality space of either ``K`` or ``K.dual()`` is
- # trivial and it's easy to show that our generating set is
- # minimal. I would love a proof that this works when ``K`` is
- # neither pointed nor solid.
- #
- # Note that in that case we can get *duplicates*, since the
- # tensor product of (x,s) is the same as that of (-x,-s).
- check = False
-
- # Create the dual cone of the cross-positive operators,
- # expressed as long vectors.
- Sigma_dual = Cone(vectors, lattice=ToricLattice(W.dimension()), check=check)
-
- # Now compute the desired cone from its dual...
- Sigma_cone = Sigma_dual.dual()
-
- # And finally convert its rays back to matrix representations.
- # But first, make them negative, so we get Z-transformations and
- # not cross-positive ones.
- M = MatrixSpace(F, n)
- return [ -M(v.list()) for v in Sigma_cone ]