]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
cone/rearrangement.py: simplify the implementation.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 12 Nov 2018 03:22:06 +0000 (22:22 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 12 Nov 2018 03:22:06 +0000 (22:22 -0500)
Use matrix tricks instead of a local function to construct the
generators.

mjo/cone/rearrangement.py

index da6c595b29a39c79b8c44f90178a9ccf52c0174d..3e09c8ad948a8c70135809b6e3c5e5328babfa36 100644 (file)
@@ -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)