# HG changeset patch
# User Maarten Derickx <m.derickx.student@gmail.com>
# Date 1314392754 25200
# Node ID dbd551af997fabb9a4f13efd29449bd23b81bc7f
# Parent d860cb782750ede05ba7cf036809e4de0973a023
11751 make free_module_generic_pid also work for pid's other then integers
diff git a/sage/modules/free_module.py b/sage/modules/free_module.py
a

b


829  829  if isinstance(x, (int, long, sage.rings.integer.Integer)) and x==0: 
830  830  return self.zero_vector() 
831  831  elif isinstance(x, free_module_element.FreeModuleElement): 
832   if x.parent() is self: 
 832  if x.parent() == self: 
833  833  if copy: 
834  834  return x.__copy__() 
835  835  else: 
… 
… 

2497  2497  Traceback (most recent call last): 
2498  2498  ... 
2499  2499  ArithmeticError: Argument gens (= [(0, 1, 0)]) does not generate a submodule of self. 
 2500  sage: V.span([[1,0,0],[1/5,4,0],[6,3/4,0]]) 
 2501  Free module of degree 3 and rank 2 over Integer Ring 
 2502  Echelon basis matrix: 
 2503  [1/5 0 0] 
 2504  [ 0 1/4 0] 
 2505  
 2506  
 2507  Show that it also works with other things than integers 
 2508  
 2509  :: 
 2510  
 2511  sage: R.<x>=QQ[] 
 2512  sage: L=R^1 
 2513  sage: a=L.span([(1/x,)]) 
 2514  sage: a 
 2515  Free module of degree 1 and rank 1 over Univariate Polynomial Ring in x over Rational Field 
 2516  Echelon basis matrix: 
 2517  [1/x] 
 2518  sage: b=L.span([(1/x,)]) 
 2519  sage: a(b.gens()[0]) 
 2520  (1/x) 
 2521  sage: L2 = R^2 
 2522  sage: L2.span([[(x^2+x)/(x^23*x+2),1/5],[(x^2+2*x)/(x^24*x+3),x]]) 
 2523  Free module of degree 2 and rank 2 over Univariate Polynomial Ring in x over Rational Field 
 2524  Echelon basis matrix: 
 2525  [x/(x^3  6*x^2 + 11*x  6) 2/15*x^2  17/75*x  1/75] 
 2526  [ 0 x^3  11/5*x^2  3*x + 4/5] 
 2527  
 2528  Note that the base_ring can make a huge difference. If we just want the answer to be the 
 2529  sub vectorspace over the fraction field of R everything becomes a lot easier. 
 2530  
 2531  :: 
 2532  
 2533  sage: L2.span([[(x^2+x)/(x^23*x+2),1/5],[(x^2+2*x)/(x^24*x+3),x]],base_ring=R.fraction_field()) 
 2534  Vector space of degree 2 and dimension 2 over Fraction Field of Univariate Polynomial Ring in x over Rational Field 
 2535  Basis matrix: 
 2536  [1 0] 
 2537  [0 1] 
 2538  
 2539  
2500  2540  """ 
2501  2541  if is_FreeModule(gens): 
2502  2542  gens = gens.gens() 
… 
… 

5075  5115  """ 
5076  5116  if len(B) == 0: 
5077  5117  return 1 
5078   d = sage.rings.integer.Integer((hasattr(B[0],'denominator') and B[0].denominator()) or 1) 
 5118  d = B[0].denominator() 
5079  5119  for x in B[1:]: 
5080   d = d.lcm((hasattr(x,'denominator') and x.denominator()) or 1) 
 5120  d = d.lcm(x.denominator()) 
5081  5121  return d 
5082  5122  
5083  5123  def _repr_(self): 