sage-main

changeset 936:89479e56e199

[project @ Number field functionality for rational elements]
author craigcitro@gmail.com
date Sun Aug 06 11:06:37 2006 +0000 (3 years ago)
parents 1478e3047ea7
children 9788e4235a28
files sage/ext/rational.pyx
line diff
1.1 --- a/sage/ext/rational.pyx Sun Aug 06 08:31:07 2006 +0000 1.2 +++ b/sage/ext/rational.pyx Sun Aug 06 11:06:37 2006 +0000 1.3 @@ -591,6 +591,68 @@ 1.4 _sig_off 1.5 return (n*d)%other 1.6 1.7 + def norm(self): 1.8 + """ 1.9 + Returns the norm from Q to Q of x (which is just x). This was 1.10 + added for compatibility with NumberFields. 1.11 + 1.12 + EXAMPLES: 1.13 + sage: (1/3).norm() 1.14 + 1/3 1.15 + 1.16 + AUTHOR: 1.17 + -- Craig Citro 1.18 + """ 1.19 + return self 1.20 + 1.21 + def trace(self): 1.22 + """ 1.23 + Returns the trace from Q to Q of x (which is just x). This was 1.24 + added for compatibility with NumberFields. 1.25 + 1.26 + EXAMPLES: 1.27 + sage: (1/3).trace() 1.28 + 1/3 1.29 + 1.30 + AUTHOR: 1.31 + -- Craig Citro 1.32 + """ 1.33 + return self 1.34 + 1.35 + def charpoly(self): 1.36 + """ 1.37 + Return the characteristic polynomial of this rational number. 1.38 + This will always be just x - self; this is really here 1.39 + so that code written for number fields won't crash when 1.40 + applied to rational numbers. 1.41 + 1.42 + EXAMPLES: 1.43 + sage: (1/3).charpoly() 1.44 + x - 1/3 1.45 + 1.46 + AUTHOR: 1.47 + -- Craig Citro 1.48 + """ 1.49 + QQ = self.parent() 1.50 + return QQ['x']([-self,1]) 1.51 + 1.52 + def minpoly(self): 1.53 + """ 1.54 + Return the minimal polynomial of this rational number. 1.55 + This will always be just x - self; this is really here 1.56 + so that code written for number fields won't crash when 1.57 + applied to rational numbers. 1.58 + 1.59 + EXAMPLES: 1.60 + sage: (1/3).minpoly() 1.61 + x - 1/3 1.62 + 1.63 + AUTHOR: 1.64 + -- Craig Citro 1.65 + """ 1.66 + QQ = self.parent() 1.67 + return QQ['x']([-self,1]) 1.68 + 1.69 def numer(self): 1.70 """ 1.71 Return the numerator of this rational number.