# HG changeset patch
# User Rob Beezer <beezer@ups.edu>
# Date 1313770804 25200
# Node ID 0cffd3dde259d32e17b2c0257ca1e80da0822b90
# Parent 38e10ea9217da3c58ad8982db3fba77b67228f03
11556: linear transformations edits
diff r 38e10ea9217d r 0cffd3dde259 sage/modules/free_module_morphism.py
a

b


529  529  else: 
530  530  raise TypeError, "not an endomorphism" 
531  531  
532   minpoly = minimal_polynomial 
533   No newline at end of file 
 532  minpoly = minimal_polynomial 
 533  
 534  No newline at end of file 
diff r 38e10ea9217d r 0cffd3dde259 sage/modules/vector_space_morphism.py
a

b


328  328  import sage.modules.matrix_morphism as matrix_morphism 
329  329  import sage.modules.free_module_morphism as free_module_morphism 
330  330  import vector_space_homspace 
 331  from sage.matrix.matrix import is_Matrix 
331  332  
332  333  def linear_transformation(arg0, arg1=None, arg2=None, side='left'): 
333  334  r""" 
… 
… 

346  347  the vector on the left, or the vector on the right. 
347  348  The default is 'left'. Internally representations are 
348  349  always carried as the 'left' version, and the default 
349   text representation is this version. 
 350  text representation is this version. However, the matrix 
 351  representation may be obtained as either version, no matter 
 352  how it is created. 
350  353  
351  354   ``linear_transformation(A, side='left')`` 
352  355  
… 
… 

392  395  
393  396  EXAMPLES: 
394  397  
395   We can define a linear transformation with just a matrix, acting from 
396   either side of the vector. The field for the vector spaces used as 
397   domain and codomain is obtained from the base ring of the matrix, 
398   possibly promoting to a fraction field. :: 
 398  We can define a linear transformation with just a matrix, understood to 
 399  act on a vector placed on one side or the other. The field for the 
 400  vector spaces used as domain and codomain is obtained from the base 
 401  ring of the matrix, possibly promoting to a fraction field. :: 
399  402  
400  403  sage: A = matrix(ZZ, [[1, 1, 4], [2, 0, 5]]) 
401  404  sage: phi = linear_transformation(A) 
… 
… 

471  474  Functions that act on the domain may be used to compute images of 
472  475  the domain's basis elements, and this mapping can be extended to 
473  476  a unique linear transformation. The function may be a Python 
474   function (via ``def`` or ``lambda``) or a Sage symbolic function. 
475   The ```side`` keyword will determine how the linear transformation 
476   will be printed. :: 
 477  function (via ``def`` or ``lambda``) or a Sage symbolic function. :: 
477  478  
478  479  sage: def g(x): 
479  480  ... return vector(QQ, [2*x[0]+x[2], 5*x[1]]) 
… 
… 

636  637  element (= [1, 2]) is not in free module 
637  638  
638  639  
639   Functions may not apply properly to domain elemnets, 
 640  Functions may not apply properly to domain elements, 
640  641  or return values outside the codomain. :: 
641  642  
642  643  sage: f = lambda x: vector(QQ, [x[0], x[4]]) 
… 
… 

686  687  ArithmeticError: some image of the function is not in the codomain, because 
687  688  element (= [1, 0]) is not in free module 
688  689  """ 
689   from sage.matrix.matrix import is_Matrix 
690  690  from sage.matrix.constructor import matrix 
691  691  from sage.modules.module import is_VectorSpace 
692  692  from sage.modules.free_module import VectorSpace 
693   #from sage.modules.vector_space_homspace import VectorSpaceHomspace 
694  693  from sage.categories.homset import Hom 
695   from sage.modules.vector_space_morphism import VectorSpaceMorphism 
696  694  from sage.symbolic.ring import SymbolicRing 
697  695  from sage.modules.vector_callable_symbolic_dense import Vector_callable_symbolic_dense 
698  696  from inspect import isfunction 
… 
… 

729  727  # arg2 might be a matrix that began in arg0 
730  728  D = arg0 
731  729  C = arg1 
732   # next line must be Hom() to register unique parents? 
733  730  H = Hom(D, C, category=None) 
734  731  
735  732  # Examine arg2 as the "rule" for the linear transformation 
… 
… 

769  766  raise TypeError(msg.format(arg2)) 
770  767  
771  768  # arg2 now compatible with homspace H call method 
772   # class __init__ will check 
773   # matrix sizes versus domain/codomain dimensions 
 769  # __init__ will check matrix sizes versus domain/codomain dimensions 
774  770  return H(arg2) 
775   ## return VectorSpaceMorphism(H, arg2) 
776  771  
777  772  def is_VectorSpaceMorphism(x): 
778  773  r""" 
… 
… 

853  848  sage: type(rho) 
854  849  <class 'sage.modules.vector_space_morphism.VectorSpaceMorphism'> 
855  850  """ 
856   from sage.matrix.matrix import is_Matrix 
857  851  if not vector_space_homspace.is_VectorSpaceHomspace(homspace): 
858  852  raise TypeError, 'homspace must be a vector space hom space, not {0}'.format(homspace) 
859  853  if isinstance(A, matrix_morphism.MatrixMorphism): 