From a77c200cedbebe92a7cf4b412c0c7e0e405c57af Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 5 Oct 2015 15:30:08 -0400 Subject: [PATCH] Fix Z_transformations() implementation and tests. --- mjo/cone/cone.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/mjo/cone/cone.py b/mjo/cone/cone.py index 7d919e4..6ad7c52 100644 --- a/mjo/cone/cone.py +++ b/mjo/cone/cone.py @@ -686,6 +686,22 @@ def Z_transformations(K): EXAMPLES: + Z-transformations on the nonnegative orthant are just Z-matrices. + That is, matrices whose off-diagonal elements are nonnegative:: + + 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 ]) + True + The trivial cone in a trivial space has no Z-transformations:: sage: K = Cone([], ToricLattice(0)) @@ -706,15 +722,17 @@ def Z_transformations(K): The Z-property is possessed by every Z-transformation:: + sage: set_random_seed() sage: K = random_cone(max_ambient_dim = 6) sage: Z_of_K = Z_transformations(K) sage: dcs = K.discrete_complementarity_set() - sage: all([z(x).inner_product(s) <= 0 for z in Z_of_K - ....: for (x,s) in dcs]) + sage: all([(z*x).inner_product(s) <= 0 for z in Z_of_K + ....: for (x,s) in dcs]) True The lineality space of Z is LL:: + sage: set_random_seed() sage: K = random_cone(min_ambient_dim = 1, max_ambient_dim = 6) sage: llvs = span([ vector(l.list()) for l in K.LL() ]) sage: z_cone = Cone([ z.list() for z in Z_transformations(K) ]) @@ -739,15 +757,17 @@ def Z_transformations(K): # Turn our matrices into long vectors... vectors = [ W(m.list()) for m in tensor_products ] - # Create the *dual* cone of the positive operators, expressed as - # long vectors.. + # Create the *dual* cone of the cross-positive operators, + # expressed as long vectors.. L = ToricLattice(W.dimension()) - Z_dual = Cone(vectors, lattice=L) + Sigma_dual = Cone(vectors, lattice=L) # Now compute the desired cone from its dual... - Z_cone = Z_dual.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(V.base_ring(), V.dimension()) - return [ M(v.list()) for v in Z_cone.rays() ] + return [ -M(v.list()) for v in Sigma_cone.rays() ] -- 2.44.2