# Ticket #10772: trac_10772-0pow0.patch

File trac_10772-0pow0.patch, 4.4 KB (added by mstreng, 11 years ago)
• ## sage/matrix/matrix0.pyx

```# HG changeset patch
# User Marco Streng <marco.streng@gmail.com>
# Date 1297424101 0
# Node ID e73c3a56dfc7e8b926b914e6289c8d8f6d00756f
# Parent  b995f0056e8f09421b141a642b0ef312807befd1
Trac 10772: 0**0 = 1 for number fields, matrices, and more

diff -r b995f0056e8f -r e73c3a56dfc7 sage/matrix/matrix0.pyx```
 a [      -3/11     -13/121   1436/1331] [    127/121   -337/1331 -4445/14641] [    -13/121   1436/1331 -8015/14641] Sage follows Python's convention 0^0 = 1, as each of the following examples show:: sage: a = Matrix([[1,0],[0,0]]); a [1 0] [0 0] sage: a^0 # lower right entry is 0^0 [1 0] [0 1] sage: Matrix([])^0  sage: 0^0 1 """ if not self.is_square(): raise ArithmeticError("self must be a square matrix")
• ## sage/rings/number_field/number_field.py

`diff -r b995f0056e8f -r e73c3a56dfc7 sage/rings/number_field/number_field.py`
 a sage: L.base_field().base_field() Rational Field sage: L = K.relativize(K(0), 'a'); L Number Field in a0 with defining polynomial x^4 + 2*x^2 + 2 over its base field sage: L.base_field() Number Field in a1 with defining polynomial x sage: L.base_field().base_field() Rational Field We can relativize over morphisms returned by self.subfields():: sage: L = NumberField(x^4 + 1, 'a') sage: [L.relativize(h, 'c') for (f,h,i) in L.subfields()] [Number Field in c0 with defining polynomial x^4 + 1 over its base field, Number Field in c0 with defining polynomial x^2 - 1/2*a1 over its base field, Number Field in c0 with defining polynomial x^2 - a2*x - 1 over its base field, Number Field in c0 with defining polynomial x^2 - a3*x + 1 over its base field, Number Field in c0 with defining polynomial x - a4 over its base field] We can relativize over a relative field:: sage: K. = CyclotomicField(16)
• ## sage/rings/number_field/number_field_element.pyx

`diff -r b995f0056e8f -r e73c3a56dfc7 sage/rings/number_field/number_field_element.pyx`
 a sage: sqrt2^sqrt2 2^(1/2*sqrt(2)) Sage follows Python's convention 0^0 = 1:: sage: a = K(0)^0; a 1 sage: a.parent() Number Field in sqrt2 with defining polynomial x^2 - 2 TESTS:: sage: 2^I
• ## sage/rings/polynomial/polydict.pyx

`diff -r b995f0056e8f -r e73c3a56dfc7 sage/rings/polynomial/polydict.pyx`
 a sage: f**0 PolyDict with representation {(0, 0): 1} sage: (f-f)**0 Traceback (most recent call last): ... ArithmeticError: 0^0 is undefined. PolyDict with representation {0: 1} """ return generic_power(self, n, self.__one())
• ## sage/structure/element.pyx

`diff -r b995f0056e8f -r e73c3a56dfc7 sage/structure/element.pyx`
 a except TypeError: raise NotImplementedError, "non-integral exponents not supported" # It's better to test first the equality to zero of the exponent. Indeed, # the following tests tree allows us be sure that "non a" is never called # if n is not 0, so that we can deals with this particular case before # calling generic_power. It is needed to handle the case of semi-groups # (without unit) where "not a" does not makes sense and there is no one to # return when n is 0. if not n: if not a: raise ArithmeticError, "0^0 is undefined." if one is None: if PY_TYPE_CHECK(a, Element): return (a)._parent(1)