Ticket #4513: matrixgroupCall.patch

File matrixgroupCall.patch, 3.5 KB (added by SimonKing, 11 years ago)

call method for MatrixGroupelement? (this time with doc test) and left_matrix_action for MPolynomial

  • sage/groups/matrix_gps/matrix_group_element.py

    # HG changeset patch
    # User Simon King <king@mathematik.uni-jena.de>
    # Date 1226647475 -3600
    # Node ID 545b25190c747c7e1d0a143e970c848e6c6483dc
    # Parent  9d1b040aa879d17374faeaf165fdd4d359e12688
    __call__ method for MatrixGroupElement / left_matrix_action method for MPolynomial
    
    diff -r 9d1b040aa879 -r 545b25190c74 sage/groups/matrix_gps/matrix_group_element.py
    a b  
    55   David Joyner -- initial version
    66   David Joyner -- (2006-05) various modifications to address William
    77                   Stein's TODO's.
    8    William Stein (2006-12-09): many revisions.               
     8   William Stein (2006-12-09): many revisions.               
     9   Simon King (2008-11-16): __call__ method
    910
    1011EXAMPLES:
    1112
     
    5657import sage.structure.element as element
    5758from sage.matrix.matrix import Matrix
    5859from sage.structure.factorization import Factorization
     60from sage.all import prod
    5961
    6062def is_MatrixGroupElement(x):
    6163    return isinstance(x, MatrixGroupElement)
     
    196198        have latex and xdvi installed).
    197199        """
    198200        return self.__mat._latex_()
     201
     202    def __call__(self,p):
     203        """
     204        The linear action of self on a polynomial p.
     205        The field over which self is defined should coerce
     206        into the field over which p is defined. Moreover,
     207        the number of variables of the parent of p must fit
     208        to the dimension of self.
     209        EXAMPLE:
     210            sage: M=Matrix(GF(3),[[1,2],[1,1]])
     211            sage: G=MatrixGroup([M])
     212            sage: g=G.0
     213            sage: R.<x,y>=GF(3)[]
     214            sage: p=x*y^2
     215            sage: g(p)
     216            x^3 + x^2*y - x*y^2 - y^3
     217        """
     218        return p.left_matrix_action(self)
    199219
    200220    def _mul_(self,other):
    201221        """
  • sage/rings/polynomial/multi_polynomial.pyx

    diff -r 9d1b040aa879 -r 545b25190c74 sage/rings/polynomial/multi_polynomial.pyx
    a b  
    55
    66from sage.misc.derivative import multi_derivative
    77from sage.rings.infinity import infinity
     8from sage.all import prod
    89
    910def is_MPolynomial(x):
    1011    return isinstance(x, MPolynomial)
     
    367368            z *= var
    368369        return ring(v)
    369370       
     371    def left_matrix_action(self, M):
     372        """
     373        Matrix action on polynomials.
     374
     375        EXAMPLE:
     376            sage: M=Matrix(GF(3),[[1,2],[1,1]])
     377            sage: G=MatrixGroup([M])
     378            sage: g=G.0
     379            sage: R.<x,y>=GF(3)[]
     380            sage: p=x*y^2
     381            sage: p.left_matrix_action(g)
     382            x^3 + x^2*y - x*y^2 - y^3
     383        """
     384        R = self.parent()
     385        cdef tuple Rgens = R.gens()
     386        cdef list Coef = self.coefficients()
     387        cdef list Expo = self.exponents()
     388        cdef int n = len(Rgens)
     389        cdef int l = len(Coef)
     390        cdef int i,k
     391       
     392        cdef list Y
     393        q = R(0)
     394        # 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:
     397            X = Expo[i]
     398            c = Coef[i]
     399            q += c*prod([Im[k]**X[k] for k in xrange(n)])
     400        return q
     401
    370402    def _mpoly_dict_recursive(self, vars=None, base_ring=None):
    371403        """
    372404        Return a dict of coefficent entries suitable for construction of a MPolynomial_polydict