# HG changeset patch
# User Simon King <simon.king@nuigalway.ie>
# Date 1279373034 3600
# Node ID ef2105b3be9a022dfac0dda1f2101175c5bcff27
# Parent 5e9277b8e2ec15c4daae0d1e00c48276dab75540
#4513: Implement proper left and right action of matrix groups on polynomials, rather than doing skalar multiplication
diff r 5e9277b8e2ec r ef2105b3be9a sage/groups/matrix_gps/matrix_group_element.py
a

b


250  250  
251  251  def _act_on_(self, x, self_on_left): 
252  252  """ 
253   EXAMPLES:: 
 253  EXAMPLES: 
254  254  
 255  Left and right action on a vector space:: 
 256  
255  257  sage: G = GL(4,7) 
256  258  sage: G.0 * vector([1,2,3,4]) 
257  259  (3, 2, 3, 4) 
… 
… 

259  261  sage: g = G.1 
260  262  sage: v * g == v * g.matrix() # indirect doctest 
261  263  True 
 264  sage: (G.0*G.1)*v == G.0*(G.1*v) 
 265  True 
 266  sage: v*(G.0*G.1) == (v*G.0)*G.1 
 267  True 
 268  
 269  Left and right action on a polynomial ring:: 
 270  
 271  sage: R.<a,b,c,d> = GF(7)[] 
 272  sage: G.1 
 273  [6 0 0 1] 
 274  [6 0 0 0] 
 275  [0 6 0 0] 
 276  [0 0 6 0] 
 277  sage: G.1*a 
 278  a  b 
 279  sage: a*G.1 
 280  a + d 
 281  sage: G.0*(G.1*a) == (G.0*G.1)*a 
 282  True 
 283  
 284  AUTHOR: 
 285  
 286   Simon King (201007): Action on polynomial rings. 
262  287  """ 
 288  # if it is a matrix group element or is in the base ring, 
 289  # then multiplication should be implemented in _mul_ 
263  290  if not is_MatrixGroupElement(x) and x not in self.parent().base_ring(): 
 291  from sage.rings.polynomial.polynomial_element import is_Polynomial 
 292  from sage.rings.polynomial.multi_polynomial import is_MPolynomial 
 293  if is_Polynomial(x) or is_MPolynomial(x): 
 294  try: 
 295  R = x.parent() 
 296  try: 
 297  D = self.__action_cache_ 
 298  except AttributeError: 
 299  try: 
 300  D = self.__action_cache_ = {} 
 301  except AttributeError: 
 302  D = {} 
 303  f = D.get((R,self,self_on_left)) 
 304  if f is None: 
 305  from sage.all import add 
 306  if self_on_left: 
 307  f = R.hom([add([a*b for a,b in zip(L,R.gens())]) for L in self.__mat.transpose().rows()]) 
 308  else: 
 309  f = R.hom([add([a*b for a,b in zip(L,R.gens())]) for L in self.__mat.rows()]) 
 310  D[R,self,self_on_left] = f 
 311  return f(x) 
 312  except (AttributeError, ValueError, TypeError): 
 313  pass 
264  314  try: 
265  315  if self_on_left: 
266  316  return self.matrix() * x 