summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTravis Scrimshaw <tscrimsh at umn.edu>2016-04-28 08:44:41 -0500
committerTravis Scrimshaw <tscrimsh at umn.edu>2016-04-28 08:44:41 -0500
commit3b92a85394e8fc6f7572c58d0a6ce8b1bebacce2 (patch)
tree25ff22e3b7da1f29151e4774ed6c45c61058ad1a
parentMerge branch 'public/manifolds/top_manif_scalar_fields' of trac.sagemath.org:... (diff)
Some formatting and small reviewer changes.
-rw-r--r--src/sage/manifolds/coord_func.py366
-rw-r--r--src/sage/manifolds/coord_func_symb.py204
-rw-r--r--src/sage/manifolds/manifold.py49
-rw-r--r--src/sage/manifolds/scalarfield.py183
-rw-r--r--src/sage/manifolds/scalarfield_algebra.py164
-rw-r--r--src/sage/manifolds/utilities.py90
6 files changed, 499 insertions, 557 deletions
diff --git a/src/sage/manifolds/coord_func.py b/src/sage/manifolds/coord_func.py
index 9ae3324..84a65ca 100644
--- a/src/sage/manifolds/coord_func.py
+++ b/src/sage/manifolds/coord_func.py
@@ -6,23 +6,23 @@ a *coordinate function* is a function from a chart codomain
to `K`. In other words, a coordinate function is a `K`-valued function of
the coordinates associated to some chart.
-More precisely, let `(U,\varphi)` be a chart on `M`, i.e. `U` is an open
-subset of `M` and `\varphi: U \rightarrow V \subset K^n` is a homeomorphism
+More precisely, let `(U, \varphi)` be a chart on `M`, i.e. `U` is an open
+subset of `M` and `\varphi: U \to V \subset K^n` is a homeomorphism
from `U` to an open subset `V` of `K^n`. A *coordinate function associated
-to the chart* `(U,\varphi)` is a function
+to the chart* `(U, \varphi)` is a function
.. MATH::
\begin{array}{cccc}
f:& V\subset K^n & \longrightarrow & K \\
- & (x^1,\ldots, x^n) & \longmapsto & f(x^1,\ldots, x^n)
+ & (x^1, \ldots, x^n) & \longmapsto & f(x^1, \ldots, x^n)
\end{array}
Coordinate functions are implemented by derived classes of the abstract base
class :class:`CoordFunction`.
-The class :class:`MultiCoordFunction` implements `K^m`-valued functions of the
-coordinates of a chart, with $m$ a positive integer.
+The class :class:`MultiCoordFunction` implements `K^m`-valued functions of
+the coordinates of a chart, with `m` a positive integer.
AUTHORS:
@@ -39,6 +39,7 @@ AUTHORS:
# http://www.gnu.org/licenses/
#*****************************************************************************
+from sage.misc.abstract_method import abstract_method
from sage.structure.sage_object import SageObject
from sage.misc.latex import latex
@@ -46,21 +47,21 @@ class CoordFunction(SageObject):
r"""
Abstract base class for coordinate functions.
- If `(U,\varphi)` is a chart on a topological manifold `M` of dimension `n`
- over a topological field `K`, a *coordinate function* associated to
- `(U,\varphi)` is a map `f: V\subset K^n \rightarrow K`, where `V` is the
- codomain of `\varphi`. In other words, `f` is a `K`-valued function of the
- coordinates associated to the chart `(U,\varphi)`.
+ If `(U, \varphi)` is a chart on a topological manifold `M` of
+ dimension `n` over a topological field `K`, a *coordinate function*
+ associated to `(U, \varphi)` is a map `f: V\subset K^n \to K`, where
+ `V` is the codomain of `\varphi`. In other words, `f` is a `K`-valued
+ function of the coordinates associated to the chart `(U, \varphi)`.
- The class :class:`CoordFunction` is an abstract one. Specific coordinate
- functions must be implemented by derived classes, like
+ The class :class:`CoordFunction` is an abstract one. Specific
+ coordinate functions must be implemented by derived classes, like
:class:`~sage.manifolds.coord_func_symb.CoordFunctionSymb` for
symbolic coordinate functions.
INPUT:
- - ``chart`` -- the chart `(U, \varphi)`, as an instance of class
- :class:`~sage.manifolds.chart.Chart`
+ - ``chart`` -- :class:`~sage.manifolds.chart.Chart`;
+ the chart `(U, \varphi)`
"""
def __init__(self, chart):
@@ -84,11 +85,12 @@ class CoordFunction(SageObject):
def chart(self):
r"""
- Return the chart w.r.t. which the coordinate function is defined.
+ Return the chart with respect to which the coordinate function
+ is defined.
OUTPUT:
- - an instance of :class:`~sage.manifolds.chart.Chart`
+ - a :class:`~sage.manifolds.chart.Chart`
EXAMPLE::
@@ -108,19 +110,18 @@ class CoordFunction(SageObject):
Construct the scalar field that has the coordinate function as
coordinate expression.
- The domain of the scalar field is the open subset covered by the chart
- on which the coordinate function is defined
+ The domain of the scalar field is the open subset covered by the
+ chart on which the coordinate function is defined.
INPUT:
- ``name`` -- (default: ``None``) name given to the scalar field
- ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the
- scalar field; if none is provided, the LaTeX symbol is set to ``name``
+ scalar field; if ``None``, the LaTeX symbol is set to ``name``
OUTPUT:
- - instance of class
- :class:`~sage.manifolds.scalarfield.ScalarField`
+ - a :class:`~sage.manifolds.scalarfield.ScalarField`
EXAMPLES:
@@ -148,7 +149,7 @@ class CoordFunction(SageObject):
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
@@ -176,7 +177,7 @@ class CoordFunction(SageObject):
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
@@ -205,7 +206,7 @@ class CoordFunction(SageObject):
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
@@ -234,12 +235,12 @@ class CoordFunction(SageObject):
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
- - coordinate function resulting from the subtraction of ``self`` from
- ``other``
+ - coordinate function resulting from the subtraction of ``self``
+ from ``other``
TESTS::
@@ -263,12 +264,12 @@ class CoordFunction(SageObject):
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
- - coordinate function resulting from the subtraction of ``other`` from
- ``self``
+ - coordinate function resulting from the subtraction of ``other``
+ from ``self``
TESTS::
@@ -292,7 +293,7 @@ class CoordFunction(SageObject):
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
@@ -323,7 +324,7 @@ class CoordFunction(SageObject):
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
@@ -352,12 +353,12 @@ class CoordFunction(SageObject):
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
- - coordinate function resulting from the division of ``other`` by
- ``self``
+ - coordinate function resulting from the division of ``other``
+ by ``self``
TESTS::
@@ -381,7 +382,7 @@ class CoordFunction(SageObject):
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
@@ -408,11 +409,12 @@ class CoordFunction(SageObject):
# Methods to be implemented by derived classes
# --------------------------------------------
+ @abstract_method
def _repr_(self):
r"""
String representation of the object.
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -425,15 +427,14 @@ class CoordFunction(SageObject):
Traceback (most recent call last):
...
NotImplementedError: CoordFunction._repr_ not implemented
-
"""
- raise NotImplementedError("CoordFunction._repr_ not implemented")
+ @abstract_method
def _latex_(self):
r"""
LaTeX representation of the object.
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -446,15 +447,14 @@ class CoordFunction(SageObject):
Traceback (most recent call last):
...
NotImplementedError: CoordFunction._latex_ not implemented
-
"""
- raise NotImplementedError("CoordFunction._latex_ not implemented")
+ @abstract_method
def display(self):
r"""
Display the function in arrow notation.
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -467,23 +467,21 @@ class CoordFunction(SageObject):
Traceback (most recent call last):
...
NotImplementedError: CoordFunction.display not implemented
-
"""
- raise NotImplementedError("CoordFunction.display not implemented")
disp = display
+ @abstract_method
def expr(self):
r"""
Return some data that, along with the chart, is sufficient to
reconstruct the object.
For a symbolic coordinate function, this returns the symbol
- expression representing the function
- (see
+ expression representing the function (see
:meth:`sage.manifolds.coord_func_symb.CoordFunctionSymb.expr`)
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -498,25 +496,25 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.expr not implemented
"""
- raise NotImplementedError("CoordFunction.expr not implemented")
+ @abstract_method
def __call__(self, *coords, **options):
r"""
Compute the value of the function at specified coordinates.
INPUT:
- - ``*coords`` -- list of coordinates `(x^1,...,x^n)` where the
- function `f` is to be evaluated
+ - ``*coords`` -- list of coordinates `(x^1, \ldots ,x^n)`,
+ where the function `f` is to be evaluated
- ``**options`` -- options to control the computation (e.g.
simplification options)
OUTPUT:
- - the value `f(x^1,...,x^n)`, where `f` is the current coordinate
- function.
+ - the value `f(x^1, \ldots, x^n)`, where `f` is the current
+ coordinate function
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -531,13 +529,13 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.__call__ not implemented
"""
- raise NotImplementedError("CoordFunction.__call__ not implemented")
+ @abstract_method
def is_zero(self):
r"""
Return ``True`` if the function is zero and ``False`` otherwise.
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -552,8 +550,8 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.is_zero not implemented
"""
- raise NotImplementedError("CoordFunction.is_zero not implemented")
+ @abstract_method
def copy(self):
r"""
Return an exact copy of the object.
@@ -562,7 +560,7 @@ class CoordFunction(SageObject):
- an instance of :class:`CoordFunction`
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -577,8 +575,8 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.copy not implemented
"""
- raise NotImplementedError("CoordFunction.copy not implemented")
+ @abstract_method
def diff(self, coord):
r"""
Partial derivative with respect to a coordinate.
@@ -596,7 +594,7 @@ class CoordFunction(SageObject):
- instance of :class:`CoordFunction` representing the partial
derivative `\frac{\partial f}{\partial x^i}`
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -611,21 +609,21 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.diff not implemented
"""
- raise NotImplementedError("CoordFunction.diff not implemented")
+ @abstract_method
def __eq__(self, other):
r"""
Comparison (equality) operator.
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
- ``True`` if ``self`` is equal to ``other``, or ``False`` otherwise
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -641,7 +639,6 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.__eq__ not implemented
"""
- raise NotImplementedError("CoordFunction.__eq__ not implemented")
def __pos__(self):
r"""
@@ -649,25 +646,28 @@ class CoordFunction(SageObject):
OUTPUT:
- - an exact copy of ``self``
+ - ``self``
- TEST:
+ TESTS:
- This method must be implemented by derived classes; it is not
- implemented here::
+ Coordinate functions associated to a 2-dimensional chart::
sage: M = Manifold(2, 'M', structure='topological')
sage: X.<x,y> = M.chart()
- sage: from sage.manifolds.coord_func import CoordFunction
- sage: f = CoordFunction(X)
- sage: f.__pos__()
- Traceback (most recent call last):
- ...
- NotImplementedError: CoordFunction.__pos__ not implemented
+ sage: f = X.function(x+y^2)
+ sage: g = +f; g
+ y^2 + x
+ sage: type(g)
+ <class 'sage.manifolds.coord_func_symb.CoordFunctionSymb'>
+ sage: g == f
+ True
+ sage: g is f
+ True
"""
- raise NotImplementedError("CoordFunction.__pos__ not implemented")
+ return self
+ @abstract_method
def __neg__(self):
r"""
Unary minus operator.
@@ -676,7 +676,7 @@ class CoordFunction(SageObject):
- the opposite of the coordinate function ``self``
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -691,22 +691,22 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.__neg__ not implemented
"""
- raise NotImplementedError("CoordFunction.__neg__ not implemented")
+ @abstract_method
def __invert__(self):
r"""
Inverse operator.
If `f` denotes the current coordinate function and `K` the topological
field over which the manifold is defined, the *inverse* of `f` is the
- coordinate function `1/f`, where `1` of the multiplicative identity
+ coordinate function `1 / f`, where `1` of the multiplicative identity
of `K`.
OUTPUT:
- the inverse of the coordinate function ``self``
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -721,22 +721,22 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.__invert__ not implemented
"""
- raise NotImplementedError("CoordFunction.__invert__ not implemented")
+ @abstract_method
def __add__(self, other):
r"""
Addition operator.
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
- coordinate function resulting from the addition of ``self`` and
``other``
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -751,22 +751,22 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.__add__ not implemented
"""
- raise NotImplementedError("CoordFunction.__add__ not implemented")
+ @abstract_method
def __sub__(self, other):
r"""
Subtraction operator.
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
- coordinate function resulting from the subtraction of ``other`` from
``self``
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -781,22 +781,22 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.__sub__ not implemented
"""
- raise NotImplementedError("CoordFunction.__sub__ not implemented")
+ @abstract_method
def __mul__(self, other):
r"""
Multiplication operator.
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
- coordinate function resulting from the multiplication of ``self`` by
``other``
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -811,22 +811,22 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.__mul__ not implemented
"""
- raise NotImplementedError("CoordFunction.__mul__ not implemented")
+ @abstract_method
def __div__(self, other):
r"""
Division operator.
INPUT:
- - ``other`` -- another instance of :class:`CoordFunction` or a value
+ - ``other`` -- a :class:`CoordFunction` or a value
OUTPUT:
- coordinate function resulting from the division of ``self`` by
``other``
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -841,8 +841,8 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.__div__ not implemented
"""
- raise NotImplementedError("CoordFunction.__div__ not implemented")
+ @abstract_method
def exp(self):
r"""
Exponential of the coordinate function.
@@ -852,7 +852,7 @@ class CoordFunction(SageObject):
- coordinate function `\exp(f)`, where `f` is the current coordinate
function.
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -867,9 +867,8 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.exp not implemented
"""
- raise NotImplementedError("CoordFunction.exp not implemented")
-
+ @abstract_method
def log(self, base=None):
r"""
Logarithm of the coordinate function.
@@ -884,7 +883,7 @@ class CoordFunction(SageObject):
- coordinate function `\log_a(f)`, where `f` is the current coordinate
function and `a` is the base
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -899,9 +898,8 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.log not implemented
"""
- raise NotImplementedError("CoordFunction.log not implemented")
-
+ @abstract_method
def __pow__(self, exponent):
r"""
Power of the coordinate function.
@@ -915,7 +913,7 @@ class CoordFunction(SageObject):
- coordinate function `f^a`, where `f` is the current coordinate
function and `a` is the exponent
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -930,9 +928,8 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.__pow__ not implemented
"""
- raise NotImplementedError("CoordFunction.__pow__ not implemented")
-
+ @abstract_method
def sqrt(self):
r"""
Square root of the coordinate function.
@@ -940,9 +937,9 @@ class CoordFunction(SageObject):
OUTPUT:
- coordinate function `\sqrt{f}`, where `f` is the current coordinate
- function.
+ function
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -957,8 +954,8 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.sqrt not implemented
"""
- raise NotImplementedError("CoordFunction.sqrt not implemented")
+ @abstract_method
def cos(self):
r"""
Cosine of the coordinate function.
@@ -966,9 +963,9 @@ class CoordFunction(SageObject):
OUTPUT:
- coordinate function `\cos(f)`, where `f` is the current coordinate
- function.
+ function
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -983,8 +980,8 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.cos not implemented
"""
- raise NotImplementedError("CoordFunction.cos not implemented")
+ @abstract_method
def sin(self):
r"""
Sine of the coordinate function.
@@ -992,9 +989,9 @@ class CoordFunction(SageObject):
OUTPUT:
- coordinate function `\sin(f)`, where `f` is the current coordinate
- function.
+ function
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -1009,8 +1006,8 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.sin not implemented
"""
- raise NotImplementedError("CoordFunction.sin not implemented")
+ @abstract_method
def tan(self):
r"""
Tangent of the coordinate function.
@@ -1018,9 +1015,9 @@ class CoordFunction(SageObject):
OUTPUT:
- coordinate function `\tan(f)`, where `f` is the current coordinate
- function.
+ function
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -1035,8 +1032,8 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.tan not implemented
"""
- raise NotImplementedError("CoordFunction.tan not implemented")
+ @abstract_method
def arccos(self):
r"""
Arc cosine of the coordinate function.
@@ -1044,9 +1041,9 @@ class CoordFunction(SageObject):
OUTPUT:
- coordinate function `\arccos(f)`, where `f` is the current coordinate
- function.
+ function
- TEST:
+ TESTS:
This method must be implemented by derived classes; it is not
implemented here::
@@ -1061,8 +1058,8 @@ class CoordFunction(SageObject):
NotImplementedError: CoordFunction.arccos not implemented
"""
- raise NotImplementedError("CoordFunction.arccos not implemented")
+ @abstract_method
def arcsin(self):