From 6e240259a6453b592c136242b4c1738c24c35aed Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 11 Nov 2018 22:22:06 -0500 Subject: [PATCH] cone/rearrangement.py: simplify the implementation. Use matrix tricks instead of a local function to construct the generators. --- mjo/cone/rearrangement.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mjo/cone/rearrangement.py b/mjo/cone/rearrangement.py index da6c595..3e09c8a 100644 --- a/mjo/cone/rearrangement.py +++ b/mjo/cone/rearrangement.py @@ -169,10 +169,7 @@ def rearrangement_cone(p,n,lattice=None): % (lattice.rank(), n)) - def d(j): - v = [1]*n # Create the list of all ones... - v[j] = 1 - p # Now "fix" the ``j``th entry. - return v - - G = identity_matrix(ZZ,n).rows() + [ d(j) for j in xrange(n) ] + I = identity_matrix(ZZ,n) + M = matrix.ones(ZZ,n) - p*I + G = identity_matrix(ZZ,n).rows() + M.rows() return Cone(G, lattice=lattice) -- 2.43.2