- sage: set_random_seed()
- sage: K = random_cone(max_ambient_dim=4)
- sage: F = K.lattice().vector_space().base_field()
- sage: n = K.lattice_dim()
- sage: L = ToricLattice(n**2)
- sage: W = VectorSpace(F, n**2)
- sage: Z_of_K = Z_operator_gens(K)
- sage: Z_of_K_star = Z_operator_gens(K.dual())
- sage: Z_cone = Cone([p.list() for p in Z_of_K],
- ....: lattice=L,
- ....: check=False)
- sage: Z_star = Cone([p.list() for p in Z_of_K_star],
- ....: lattice=L,
- ....: check=False)
- sage: M = MatrixSpace(F, n)
- sage: L = M(Z_cone.random_element(ring=QQ).list())
- sage: Z_star.contains(W(L.transpose().list()))
- True
-
- sage: L = W.random_element()
- sage: L_star = W(M(L.list()).transpose().list())
- sage: Z_cone.contains(L) == Z_star.contains(L_star)
- 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 operators.
- 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_proper():
- # All of the generators involved are extreme vectors and
- # therefore minimal. If this cone is neither solid nor
- # strictly convex, then the tensor product of ``s`` and ``x``
- # is the same as that of ``-s`` and ``-x``. However, as a
- # /set/, ``tensor_products`` may still be minimal.
- 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-operators and
- # not cross-positive ones.
- M = MatrixSpace(F, n)
- return [ -M(v.list()) for v in Sigma_cone ]