Ticket #4513: matrixgroupCallNew2.patch

File matrixgroupCallNew2.patch, 1.6 KB (added by SimonKing, 10 years ago)

Slight improvement; extended functionality

  • sage/rings/polynomial/multi_polynomial.pyx

    # HG changeset patch
    # User Simon King <king@mathematik.uni-jena.de>
    # Date 1226664836 -3600
    # Node ID 0cb18c96c09fdf35b542c4ec85478cf897810c85
    # Parent  071adc46e263f4972eceed39c9152aec88c6aff3
    Slight improvement of left_matrix_action by reversing the polynomial addition; extended functionality (in view of future applications)
    
    diff -r 071adc46e263 -r 0cb18c96c09f sage/rings/polynomial/multi_polynomial.pyx
    a b  
    380380            sage: p=x*y^2
    381381            sage: p.left_matrix_action(g)
    382382            x^3 + x^2*y - x*y^2 - y^3
     383
     384        To speed up repeated action of one matrix group element g,
     385        one can provide the list of images of the variables under
     386        the action of g, rather than g itself.
     387
     388        EXAMPLE:
     389            sage: L=[X.left_matrix_action(g) for X in R.gens()]
     390            sage: p.left_matrix_action(L)
     391            x^3 + x^2*y - x*y^2 - y^3
    383392        """
    384393        R = self.parent()
    385394        cdef tuple Rgens = R.gens()
     
    392401        cdef list Y
    393402        q = R(0)
    394403        # The images of the ring variables under the action of self
    395         cdef list Im = [sum([Y[i]*Rgens[i] for i in xrange(n)]) for Y in M.list()]
    396         for i from 0<=i<l:
     404        cdef list Im
     405        if isinstance(M,list):
     406            Im = M
     407        else:
     408            Im = [sum([Y[i]*Rgens[i] for i in xrange(n)]) for Y in M.list()]
     409        for i from l>i>=0:
    397410            X = tuple(Expo[i])
    398411            c = Coef[i]
    399412            for k from 0<=k<n: