Ticket #5345: trac-5345-transpose-optimize.patch

File trac-5345-transpose-optimize.patch, 960 bytes (added by rbeezer, 13 years ago)
  • sage/matrix/matrix_dense.pyx

    # HG changeset patch
    # User Rob Beezer <beezer@ups.edu>
    # Date 1235353152 28800
    # Node ID a69ace1e965afd5bacfa9d1ebe1e73b5c3929db7
    # Parent  05d19caf606f595a943b624b985424424bfce294
    Optimize transpose
    
    diff -r 05d19caf606f -r a69ace1e965a sage/matrix/matrix_dense.pyx
    a b  
    177177            [2 4]
    178178        """
    179179        f = []
    180         e = self.list()
     180        e = self._list()
    181181        (nc, nr) = (self.ncols(), self.nrows())
    182         for j in xrange(nc):       
     182        for j in xrange(nc):
     183            loc = j
    183184            for i in xrange(nr):
    184                 f.append(e[i*nc + j])
     185                f.append(e[loc])
     186                loc = loc + nc
    185187        trans = self.new_matrix(nrows = nc, ncols = nr,
    186188                                entries = f, copy=False,
    187189                                coerce=False)