summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2015-06-26 18:05:26 +0200
committerEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2015-06-26 18:05:26 +0200
commit3f22784304d9cb92f1c86df61ef57398631c8a13 (patch)
tree8ade164bccc9947228208c0cb3987908d0dcce24
parentModifications in CoordChange and TopManifold.__init__ to allow for subclasses. (diff)
Minor modifications in CoordFunctionSymb
-rw-r--r--src/sage/manifolds/chart.py34
-rw-r--r--src/sage/manifolds/coord_func_symb.py22
-rw-r--r--src/sage/manifolds/manifold.py6
3 files changed, 49 insertions, 13 deletions
diff --git a/src/sage/manifolds/chart.py b/src/sage/manifolds/chart.py
index 15d98ef..5e5eab1 100644
--- a/src/sage/manifolds/chart.py
+++ b/src/sage/manifolds/chart.py
@@ -296,10 +296,14 @@ class Chart(UniqueRepresentation, SageObject):
self._dom_restrict = {} # dict. of the restrictions of self to
# subsets of self._domain, with the
# subsets as keys
- # The null function of the coordinates:
- self._zero_function = CoordFunctionSymb(self, 0)
- # The "one" function of the coordinates:
- self._one_function = CoordFunctionSymb(self, 1)
+ # The null and one functions of the coordinates:
+ base_field = self._domain.base_field()
+ if base_field in ['real', 'complex']:
+ self._zero_function = CoordFunctionSymb(self, 0)
+ self._one_function = CoordFunctionSymb(self, 1)
+ else:
+ self._zero_function = CoordFunctionSymb(self, base_field.zero())
+ self._one_function = CoordFunctionSymb(self, base_field.one())
# Expression in self of the zero and one scalar fields of open sets
# containing the domain of self:
for dom in self._domain._supersets:
@@ -912,6 +916,17 @@ class Chart(UniqueRepresentation, SageObject):
sage: X.zero_function() is X.zero_function()
True
+ Zero function on a p-adic manifold::
+
+ sage: M = TopManifold(2, 'M', field=Qp(5)); M
+ 2-dimensional topological manifold M over the 5-adic Field with
+ capped relative precision 20
+ sage: X.<x,y> = M.chart()
+ sage: X.zero_function()
+ 0
+ sage: X.zero_function().display()
+ (x, y) |--> 0
+
"""
return self._zero_function
@@ -955,6 +970,17 @@ class Chart(UniqueRepresentation, SageObject):
sage: X.one_function() is X.one_function()
True
+ One function on a p-adic manifold::
+
+ sage: M = TopManifold(2, 'M', field=Qp(5)); M
+ 2-dimensional topological manifold M over the 5-adic Field with
+ capped relative precision 20
+ sage: X.<x,y> = M.chart()
+ sage: X.one_function()
+ 1 + O(5^20)
+ sage: X.one_function().display()
+ (x, y) |--> 1 + O(5^20)
+
"""
return self._one_function
diff --git a/src/sage/manifolds/coord_func_symb.py b/src/sage/manifolds/coord_func_symb.py
index 9cd7e87..ca7c6fa 100644
--- a/src/sage/manifolds/coord_func_symb.py
+++ b/src/sage/manifolds/coord_func_symb.py
@@ -750,6 +750,9 @@ class CoordFunctionSymb(CoordFunction):
"""
return CoordFunctionSymb(self._chart,
self._simplify(SR(1) / self._express))
+ # NB: self._express.__invert__() would return 1/self._express
+ # (cf. the code of __invert__ in src/sage/symbolic/expression.pyx)
+ # Here we prefer SR(1)/self._express
def __add__(self, other):
r"""
@@ -796,9 +799,9 @@ class CoordFunctionSymb(CoordFunction):
"the same chart cannot be added")
res = self._simplify(self._express + other._express)
elif isinstance(other, (int, RingElement)):
- res = self._simplify(self._express + other)
+ res = self._simplify(self._express + SR(other))
else:
- # addition to a numerical coord. function shall fall in this case
+ # addition to a numerical coord. function shall fall into this case
return other.__radd__(self)
if res == 0:
return self._chart._zero_function
@@ -852,9 +855,10 @@ class CoordFunctionSymb(CoordFunction):
"the same chart cannot be subtracted")
res = self._simplify(self._express - other._express)
elif isinstance(other, (int, RingElement)):
- res = self._simplify(self._express - other)
+ res = self._simplify(self._express - SR(other))
else:
- # subtraction of a numerical coord. function shall fall in this case
+ # subtraction of a numerical coord. function shall fall into this
+ # case
return other.__rsub__(self)
if res == 0:
return self._chart._zero_function
@@ -906,10 +910,10 @@ class CoordFunctionSymb(CoordFunction):
"the same chart cannot be multiplied")
res = self._simplify(self._express * other._express)
elif isinstance(other, (int, RingElement)):
- res = self._simplify(self._express * other)
+ res = self._simplify(self._express * SR(other))
else:
- # multiplication by a numerical coord. function shall fall in this
- # case
+ # multiplication by a numerical coord. function shall fall into
+ # this case
return other.__rmul__(self)
if res == 0:
return self._chart._zero_function
@@ -968,9 +972,9 @@ class CoordFunctionSymb(CoordFunction):
"by zero")
res = self._simplify(self._express / other._express)
elif isinstance(other, (int, RingElement)):
- res = self._simplify(self._express / other)
+ res = self._simplify(self._express / SR(other))
else:
- # division by a numerical coord. function shall fall in this
+ # division by a numerical coord. function shall fall into this
# case
return other.__rdiv__(self)
if res == 0:
diff --git a/src/sage/manifolds/manifold.py b/src/sage/manifolds/manifold.py
index 85f3dc5..930261f 100644
--- a/src/sage/manifolds/manifold.py
+++ b/src/sage/manifolds/manifold.py
@@ -355,6 +355,12 @@ class TopManifold(TopManifoldSubset):
sage: N = TopManifold(6, 'N', field=QQ); N
6-dimensional topological manifold N over the Rational Field
+ A manifold over `\QQ_5`, the field of 5-adic numbers::
+
+ sage: N = TopManifold(2, 'N', field=Qp(5)); N
+ 2-dimensional topological manifold N over the 5-adic Field with capped
+ relative precision 20
+
A manifold is a Sage *parent* object, in the category of sets::
sage: isinstance(M, Parent)