Changeset 7754:c3917dbf54c0
- Timestamp:
- 12/10/07 22:27:13 (5 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
sage/rings/rational.pyx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sage/rings/rational.pyx
r7753 r7754 1030 1030 sage: complex(1,2)**(1/2) 1031 1031 (1.272019649514069+0.78615137775742328j) 1032 sage: int(2)^(1/2) 1033 sqrt(2) 1034 sage: a = int(2)^(3/1); a 1035 8 1036 sage: type(a) 1037 <type 'sage.rings.rational.Rational'> 1032 1038 """ 1033 1039 if dummy is not None: 1034 1040 raise ValueError, "__pow__ dummy variable not used" 1035 1036 if not PY_TYPE_CHECK(self, Rational): #this is here for no good reason apparent to me... should be removed in the future. 1037 return self.__pow__(type(self)(n)) 1041 1042 if not PY_TYPE_CHECK(self, Rational): 1043 # If the base is not a rational, e.g., it is an int, complex, float, user-defined type, etc. 1044 try: 1045 self_coerced = Rational(self) 1046 except TypeError: 1047 n_coerced = type(self)(n) 1048 if n != n_coerced: 1049 # dangerous coercion -- don't use -- try symbolic result 1050 from sage.calculus.calculus import SR 1051 return SR(self)**SR(n) 1052 return self.__pow__(n_coerced) 1053 return self_coerced.__pow__(n) 1038 1054 1039 1055 cdef Rational _self = <Rational>self
Note: See TracChangeset
for help on using the changeset viewer.
