Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
VectorFieldModule: Add tensor_product, tensor_power
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Nov 12, 2022
1 parent c3028e7 commit 1801f62
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 6 deletions.
28 changes: 28 additions & 0 deletions src/sage/manifolds/differentiable/diff_form_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from sage.manifolds.differentiable.diff_form import DiffForm, DiffFormParal
from sage.manifolds.differentiable.tensorfield import TensorField
from sage.manifolds.differentiable.tensorfield_paral import TensorFieldParal
from sage.manifolds.differentiable.vectorfield_module import VectorFieldModule


class DiffFormModule(UniqueRepresentation, Parent):
Expand Down Expand Up @@ -534,6 +535,33 @@ def base_module(self):
"""
return self._vmodule

def tensor_type(self):
r"""
Return the tensor type of ``self`` if ``self`` is a module of 1-forms.
In this case, the pair `(0, 1)` is returned, indicating that the module
is identified with the dual of the base module.
For differential forms of other degrees, an exception is raised.
EXAMPLES::
sage: M = Manifold(3, 'M')
sage: M.diff_form_module(1).tensor_type()
(0, 1)
sage: M.diff_form_module(2).tensor_type()
Traceback (most recent call last):
...
NotImplementedError
"""
if self._degree == 1:
return (0, 1)
raise NotImplementedError

tensor_power = VectorFieldModule.tensor_power

tensor = tensor_product = VectorFieldModule.tensor_product

def degree(self):
r"""
Return the degree of the differential forms in ``self``.
Expand Down
6 changes: 6 additions & 0 deletions src/sage/manifolds/differentiable/tensorfield_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
MultivectorFieldParal)
from sage.manifolds.differentiable.automorphismfield import (AutomorphismField,
AutomorphismFieldParal)
from sage.manifolds.differentiable.vectorfield_module import VectorFieldModule


class TensorFieldModule(UniqueRepresentation, Parent):
r"""
Expand Down Expand Up @@ -561,6 +563,10 @@ def tensor_type(self):
"""
return self._tensor_type

tensor_power = VectorFieldModule.tensor_power

tensor = tensor_product = VectorFieldModule.tensor_product

@cached_method
def zero(self):
"""
Expand Down
116 changes: 110 additions & 6 deletions src/sage/manifolds/differentiable/vectorfield_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,34 @@ def destination_map(self):
"""
return self._dest_map

def base_module(self):
r"""
Return the module on which ``self`` is constructed, namely ``self`` itself.
EXAMPLES::
sage: M = Manifold(2, 'M')
sage: XM = M.vector_field_module()
sage: XM.base_module() is XM
True
"""
return self

def tensor_type(self):
r"""
Return the tensor type of ``self``, the pair `(1, 0)`.
EXAMPLES::
sage: M = Manifold(2, 'M')
sage: XM = M.vector_field_module()
sage: XM.tensor_type()
(1, 0)
"""
return (1, 0)

def tensor_module(self, k, l, *, sym=None, antisym=None):
r"""
Return the module of type-`(k,l)` tensors on ``self``.
Expand Down Expand Up @@ -731,8 +759,8 @@ def general_linear_group(self):
self._general_linear_group = AutomorphismFieldGroup(self)
return self._general_linear_group

def tensor(self, tensor_type, name=None, latex_name=None, sym=None,
antisym=None, specific_type=None):
def _tensor(self, tensor_type, name=None, latex_name=None, sym=None,
antisym=None, specific_type=None):
r"""
Construct a tensor on ``self``.
Expand Down Expand Up @@ -776,10 +804,6 @@ def tensor(self, tensor_type, name=None, latex_name=None, sym=None,
sage: XM.tensor((1,2), name='t')
Tensor field t of type (1,2) on the 2-dimensional differentiable
manifold M
sage: XM.tensor((1,0), name='a')
Vector field a on the 2-dimensional differentiable manifold M
sage: XM.tensor((0,2), name='a', antisym=(0,1))
2-form a on the 2-dimensional differentiable manifold M
.. SEEALSO::
Expand Down Expand Up @@ -824,6 +848,86 @@ def tensor(self, tensor_type, name=None, latex_name=None, sym=None,
self, tensor_type, name=name, latex_name=latex_name,
sym=sym, antisym=antisym)

tensor_power = FiniteRankFreeModule.tensor_power

tensor_product = FiniteRankFreeModule.tensor_product

def tensor(self, *args, **kwds):
r"""
Construct a tensor field on the domain of ``self`` or a tensor product of ``self`` with other modules.
If ``args`` consist of other parents, just delegate to :meth:`tensor_product`.
Otherwise, construct a tensor (i.e., a tensor field on the domain of
the vector field module) from the following input.
INPUT:
- ``tensor_type`` -- pair (k,l) with k being the contravariant rank
and l the covariant rank
- ``name`` -- (string; default: ``None``) name given to the tensor
- ``latex_name`` -- (string; default: ``None``) LaTeX symbol to denote
the tensor; if none is provided, the LaTeX symbol is set to ``name``
- ``sym`` -- (default: ``None``) a symmetry or a list of symmetries
among the tensor arguments: each symmetry is described by a tuple
containing the positions of the involved arguments, with the
convention position=0 for the first argument; for instance:
* ``sym=(0,1)`` for a symmetry between the 1st and 2nd arguments
* ``sym=[(0,2),(1,3,4)]`` for a symmetry between the 1st and 3rd
arguments and a symmetry between the 2nd, 4th and 5th arguments
- ``antisym`` -- (default: ``None``) antisymmetry or list of
antisymmetries among the arguments, with the same convention
as for ``sym``
- ``specific_type`` -- (default: ``None``) specific subclass of
:class:`~sage.manifolds.differentiable.tensorfield.TensorField` for
the output
OUTPUT:
- instance of
:class:`~sage.manifolds.differentiable.tensorfield.TensorField`
representing the tensor defined on the vector field module with the
provided characteristics
EXAMPLES::
sage: M = Manifold(2, 'M')
sage: XM = M.vector_field_module()
sage: XM.tensor((1,2), name='t')
Tensor field t of type (1,2) on the 2-dimensional differentiable
manifold M
sage: XM.tensor((1,0), name='a')
Vector field a on the 2-dimensional differentiable manifold M
sage: XM.tensor((0,2), name='a', antisym=(0,1))
2-form a on the 2-dimensional differentiable manifold M
Delegation to :meth:`tensor_product`::
sage: M = Manifold(2, 'M')
sage: XM = M.vector_field_module()
sage: XM.tensor(XM)
Module T^(2,0)(M) of type-(2,0) tensors fields on the 2-dimensional differentiable manifold M
sage: XM.tensor(XM, XM.dual(), XM)
Module T^(3,1)(M) of type-(3,1) tensors fields on the 2-dimensional differentiable manifold M
sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
Traceback (most recent call last):
...
AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
.. SEEALSO::
:class:`~sage.manifolds.differentiable.tensorfield.TensorField`
for more examples and documentation.
"""
# Until https://trac.sagemath.org/ticket/30373 is done,
# TensorProductFunctor._functor_name is "tensor", so this method
# also needs to double as the tensor product construction
if isinstance(args[0], Parent):
return self.tensor_product(*args, **kwds)
return self._tensor(*args, **kwds)

def alternating_contravariant_tensor(self, degree, name=None,
latex_name=None):
r"""
Expand Down

0 comments on commit 1801f62

Please sign in to comment.