From d3dd6210c93ee4ea0fbeb8e643649a0ab958c796 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 5 Oct 2015 01:01:04 -0400 Subject: [PATCH] Simplify implementation of positive_operators(). --- mjo/cone/cone.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mjo/cone/cone.py b/mjo/cone/cone.py index f6f378e..3f915ed 100644 --- a/mjo/cone/cone.py +++ b/mjo/cone/cone.py @@ -637,13 +637,11 @@ def positive_operators(K): A positive operator on a cone should send its generators into the cone:: sage: K = random_cone(max_ambient_dim = 6) - sage: pi_of_k = positive_operators(K) - sage: all([K.contains(p*x) for p in pi_of_k for x in K.rays()]) + sage: pi_of_K = positive_operators(K) + sage: all([K.contains(p*x) for p in pi_of_K for x in K.rays()]) True """ - V = K.lattice().vector_space() - # Sage doesn't think matrices are vectors, so we have to convert # our matrices to vectors explicitly before we can figure out how # many are linearly-indepenedent. @@ -652,12 +650,10 @@ def positive_operators(K): # dim(V)^2. So it has the same dimension as the space of linear # transformations on V. In other words, it's just the right size # to create an isomorphism between it and our matrices. + V = K.lattice().vector_space() W = VectorSpace(V.base_ring(), V.dimension()**2) - G1 = [ V(x) for x in K.rays() ] - G2 = [ V(s) for s in K.dual().rays() ] - - tensor_products = [ s.tensor_product(x) for x in G1 for s in G2 ] + tensor_products = [ s.tensor_product(x) for x in K for s in K.dual() ] # Turn our matrices into long vectors... vectors = [ W(m.list()) for m in tensor_products ] -- 2.44.2