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

Commit

Permalink
Merge #30241
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Sep 6, 2022
2 parents cae9ee5 + 84d7b5e commit b5c666c
Show file tree
Hide file tree
Showing 3 changed files with 334 additions and 138 deletions.
116 changes: 17 additions & 99 deletions src/sage/tensor/modules/ext_pow_free_module.py
Expand Up @@ -253,6 +253,10 @@ def __init__(self, fmodule, degree, name=None, latex_name=None):

def construction(self):
r"""
Return the functorial construction of ``self``.
This implementation just returns ``None``, as no functorial construction is implemented.
TESTS::
sage: from sage.tensor.modules.ext_pow_free_module import ExtPowerFreeModule
Expand Down Expand Up @@ -573,21 +577,12 @@ class ExtPowerDualFreeModule(FiniteRankFreeModule_abstract):
sage: latex(M.dual())
M^*
Since any tensor of type (0,1) is a linear form, there is a coercion map
from the set `T^{(0,1)}(M)` of such tensors to `M^*`::
It also coincides with the module of type-`(0,1)` tensors::
sage: T01 = M.tensor_module(0,1) ; T01
Free module of type-(0,1) tensors on the Rank-3 free module M over the
Integer Ring
sage: M.dual().has_coerce_map_from(T01)
sage: M.dual_exterior_power(1) is M.tensor_module(0,1)
True
There is also a coercion map in the reverse direction::
sage: T01.has_coerce_map_from(M.dual())
True
For a degree `p\geq 2`, the coercion holds only in the direction
For a degree `p\geq 2`, there is a coercion map
`\Lambda^p(M^*)\rightarrow T^{(0,p)}(M)`::
sage: T02 = M.tensor_module(0,2) ; T02
Expand All @@ -598,24 +593,6 @@ class ExtPowerDualFreeModule(FiniteRankFreeModule_abstract):
sage: A.has_coerce_map_from(T02)
False
The coercion map `T^{(0,1)}(M) \rightarrow M^*` in action::
sage: b = T01([-2,1,4], basis=e, name='b') ; b
Type-(0,1) tensor b on the Rank-3 free module M over the Integer Ring
sage: b.display(e)
b = -2 e^0 + e^1 + 4 e^2
sage: lb = M.dual()(b) ; lb
Linear form b on the Rank-3 free module M over the Integer Ring
sage: lb.display(e)
b = -2 e^0 + e^1 + 4 e^2
The coercion map `M^* \rightarrow T^{(0,1)}(M)` in action::
sage: tlb = T01(lb) ; tlb
Type-(0,1) tensor b on the Rank-3 free module M over the Integer Ring
sage: tlb == b
True
The coercion map `\Lambda^2(M^*)\rightarrow T^{(0,2)}(M)` in action::
sage: ta = T02(a) ; ta
Expand Down Expand Up @@ -649,24 +626,22 @@ def __init__(self, fmodule, degree, name=None, latex_name=None):
self._fmodule = fmodule
self._degree = ZZ(degree)
rank = binomial(fmodule._rank, degree)
if degree == 1: # case of the dual
if name is None and fmodule._name is not None:
name = fmodule._name + '*'
if latex_name is None and fmodule._latex_name is not None:
latex_name = fmodule._latex_name + r'^*'
else:
if name is None and fmodule._name is not None:
name = unicode_bigwedge + r'^{}('.format(degree) \
+ fmodule._name + '*)'
if latex_name is None and fmodule._latex_name is not None:
latex_name = r'\Lambda^{' + str(degree) + r'}\left(' \
+ fmodule._latex_name + r'^*\right)'
if name is None and fmodule._name is not None:
name = unicode_bigwedge + r'^{}('.format(degree) \
+ fmodule._name + '*)'
if latex_name is None and fmodule._latex_name is not None:
latex_name = r'\Lambda^{' + str(degree) + r'}\left(' \
+ fmodule._latex_name + r'^*\right)'
super().__init__(fmodule._ring, rank, name=name,
latex_name=latex_name)
fmodule._all_modules.add(self)

def construction(self):
r"""
Return the functorial construction of ``self``.
This implementation just returns ``None``, as no functorial construction is implemented.
TESTS::
sage: from sage.tensor.modules.ext_pow_free_module import ExtPowerDualFreeModule
Expand All @@ -691,13 +666,6 @@ def _element_constructor_(self, comp=[], basis=None, name=None,
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: e = M.basis('e')
sage: A = M.dual_exterior_power(1)
sage: a = A._element_constructor_(0) ; a
Linear form zero on the Rank-3 free module M over the Integer Ring
sage: a = A._element_constructor_([2,0,-1], name='a') ; a
Linear form a on the Rank-3 free module M over the Integer Ring
sage: a.display()
a = 2 e^0 - e^2
sage: A = M.dual_exterior_power(2)
sage: a = A._element_constructor_(0) ; a
Alternating form zero of degree 2 on the Rank-3 free module M over
Expand Down Expand Up @@ -740,11 +708,6 @@ def _an_element_(self):
sage: M = FiniteRankFreeModule(QQ, 4, name='M')
sage: e = M.basis('e')
sage: a = M.dual_exterior_power(1)._an_element_() ; a
Linear form on the 4-dimensional vector space M over the Rational
Field
sage: a.display()
1/2 e^0
sage: a = M.dual_exterior_power(2)._an_element_() ; a
Alternating form of degree 2 on the 4-dimensional vector space M
over the Rational Field
Expand Down Expand Up @@ -783,47 +746,6 @@ def _an_element_(self):
resu.set_comp()[ind] = self._fmodule._ring.an_element()
return resu

def _coerce_map_from_(self, other):
r"""
Determine whether coercion to ``self`` exists from other parent.
EXAMPLES:
Sets of type-`(0,1)` tensors coerce to ``self`` if the degree is 1::
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: L1 = M.dual_exterior_power(1) ; L1
Dual of the Rank-3 free module M over the Integer Ring
sage: T01 = M.tensor_module(0,1) ; T01
Free module of type-(0,1) tensors on the Rank-3 free module M over
the Integer Ring
sage: L1._coerce_map_from_(T01)
True
Of course, coercions from other tensor types are meaningless::
sage: L1._coerce_map_from_(M.tensor_module(1,0))
False
sage: L1._coerce_map_from_(M.tensor_module(0,2))
False
If the degree is larger than 1, there is no coercion::
sage: L2 = M.dual_exterior_power(2) ; L2
2nd exterior power of the dual of the Rank-3 free module M over
the Integer Ring
sage: L2._coerce_map_from_(M.tensor_module(0,2))
False
"""
from sage.tensor.modules.tensor_free_module import TensorFreeModule
if isinstance(other, TensorFreeModule):
# coercion of a type-(0,1) tensor to a linear form
if self._fmodule is other._fmodule and self._degree == 1 and \
other.tensor_type() == (0,1):
return True
return False

#### End of parent methods

@cached_method
Expand Down Expand Up @@ -858,8 +780,6 @@ def _repr_(self):
EXAMPLES::
sage: M = FiniteRankFreeModule(ZZ, 5, name='M')
sage: M.dual_exterior_power(1)._repr_()
'Dual of the Rank-5 free module M over the Integer Ring'
sage: M.dual_exterior_power(2)._repr_()
'2nd exterior power of the dual of the Rank-5 free module M over the Integer Ring'
sage: M.dual_exterior_power(3)._repr_()
Expand All @@ -872,8 +792,6 @@ def _repr_(self):
'21st exterior power of the dual of the Rank-5 free module M over the Integer Ring'
"""
if self._degree == 1:
return "Dual of the {}".format(self._fmodule)
description = "{}".format(self._degree.ordinal_str())
description += " exterior power of the dual of the {}".format(
self._fmodule)
Expand Down

0 comments on commit b5c666c

Please sign in to comment.