# HG changeset patch
# User Christian Stump <christian.stump at gmail.com>
# Date 1353406852 3600
# Node ID 492f622bb6de5436e02144cf4696ae98f8e6c0f4
# Parent e9f529e33ab1e30f376c5c8e452c03d2ce0d11f4
implements some basic methods for fields
diff git a/sage/categories/fields.py b/sage/categories/fields.py
a

b

class Fields(Category_singleton): 
211  211  except NotImplementedError: 
212  212  return 
213  213  
 214  def is_integral_domain(self): 
 215  r""" 
 216  
 217  Returns ``True``, as fields are integral domains. 
 218  
 219  EXAMPLES:: 
 220  
 221  sage: QQ.is_integral_domain() 
 222  True 
 223  """ 
 224  return True 
 225  
 226  def is_field( self, proof=True ): 
 227  r""" 
 228  Returns True as ``self`` is a field. 
 229  
 230  EXAMPLES:: 
 231  
 232  sage: QQ.is_field() 
 233  True 
 234  """ 
 235  return True 
 236  
 237  def fraction_field(self): 
 238  r""" 
 239  Returns the *fraction field* of ``self``, which is ``self``. 
 240  
 241  EXAMPLES:: 
 242  
 243  sage: QQ.fraction_field() is QQ 
 244  True 
 245  """ 
 246  return self 
 247  
 248  def __pow__(self, n): 
 249  r""" 
 250  Returns the vector space of dimension `n` over ``self``. 
 251  
 252  EXAMPLES:: 
 253  
 254  sage: QQ^4 
 255  Vector space of dimension 4 over Rational Field 
 256  """ 
 257  from sage.modules.all import FreeModule 
 258  return FreeModule(self, n) 
 259  
214  260  class ElementMethods: 
 261  
 262  def is_unit( self ): 
 263  r""" 
 264  Returns True if ``self`` has a multiplicative inverse. 
 265  
 266  EXAMPLES:: 
 267  
 268  sage: QQ(2).is_unit() 
 269  True 
 270  sage: QQ(0).is_unit() 
 271  False 
 272  """ 
 273  return not self.is_zero() 
 274  
215  275  # Fields are unique factorization domains, so, there is gcd and lcm 
216  276  # Of course, in general gcd and lcm in a field are not very interesting. 
217  277  # However, they should be implemented! 
diff git a/sage/rings/polynomial/polynomial_quotient_ring.py b/sage/rings/polynomial/polynomial_quotient_ring.py
a

b

class PolynomialQuotientRing_generic(sag 
260  260  sage: first_class == Q.__class__ 
261  261  False 
262  262  sage: [s for s in dir(Q.category().element_class) if not s.startswith('_')] 
263   ['cartesian_product', 'gcd', 'is_idempotent', 'is_one', 'lcm', 'lift'] 
 263  ['cartesian_product', 'gcd', 'is_idempotent', 'is_one', 'is_unit', 'lcm', 'lift'] 
264  264  
265  265  As one can see, the elements are now inheriting additional methods: lcm and gcd. Even though 
266  266  ``Q.an_element()`` belongs to the old and not to the new element class, it still inherits 