From 3b36f0ddd3099d9da6b9eaaec12f2acc8877dcd7 Mon Sep 17 00:00:00 2001 From: Michael Jung Date: Sat, 25 Apr 2020 00:24:39 +0200 Subject: [PATCH] Trac #29570: alternating_form returns correct element --- .../differentiable/vectorfield_module.py | 45 +++++++++++++++++++ .../tensor/modules/finite_rank_free_module.py | 4 +- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py index a507ab01419..b631876de13 100644 --- a/src/sage/manifolds/differentiable/vectorfield_module.py +++ b/src/sage/manifolds/differentiable/vectorfield_module.py @@ -1762,6 +1762,51 @@ def exterior_power(self, p): self._exterior_powers[p] = MultivectorFreeModule(self, p) return self._exterior_powers[p] + def alternating_form(self, degree, name=None, latex_name=None): + r""" + Construct an alternating form on the free vector field module + ``self``. + + An alternating form on ``self`` is actually a differential form + along the differentiable manifold `U` over which ``self`` is + defined. + + INPUT: + + - ``degree`` -- the degree of the alternating form + (i.e. its tensor rank) + - ``name`` -- (string; optional) name given to the alternating + form + - ``latex_name`` -- (string; optional) LaTeX symbol to denote + the alternating form; if none is provided, the LaTeX symbol is + set to ``name`` + + OUTPUT: + + - instance of + :class:`~sage.manifolds.differentiable.diff_form.DiffFormParal` + + EXAMPLES:: + + sage: M = Manifold(2, 'M') + sage: X. = M.chart() # makes M parallelizable + sage: XM = M.vector_field_module() + sage: XM.alternating_form(2, name='a') + 2-form a on the 2-dimensional differentiable manifold M + sage: XM.alternating_form(1, name='a') + 1-form a on the 2-dimensional differentiable manifold M + + .. SEEALSO:: + + :class:`~sage.manifolds.differentiable.diff_form.DiffFormParal` + for more examples and documentation. + + """ + if degree == 0: + return self._domain.scalar_field(name=name, latex_name=latex_name) + return self.dual_exterior_power(degree).element_class(self, + degree, name=name, latex_name=latex_name) + def dual_exterior_power(self, p): r""" Return the `p`-th exterior power of the dual of ``self``. diff --git a/src/sage/tensor/modules/finite_rank_free_module.py b/src/sage/tensor/modules/finite_rank_free_module.py index b8d048bd3a4..623454ce7a0 100644 --- a/src/sage/tensor/modules/finite_rank_free_module.py +++ b/src/sage/tensor/modules/finite_rank_free_module.py @@ -1084,7 +1084,7 @@ def dual_exterior_power(self, p): See :class:`~sage.tensor.modules.ext_pow_free_module.ExtPowerDualFreeModule` for more documentation. - +def dual_exterior_power """ from sage.tensor.modules.ext_pow_free_module import ExtPowerDualFreeModule if p == 0: @@ -1637,6 +1637,8 @@ def alternating_form(self, degree, name=None, latex_name=None): for more documentation. """ + if degree == 0: + return self._ring() return self.dual_exterior_power(degree).element_class(self, degree, name=name, latex_name=latex_name)