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

Commit bc1dc24

Browse files
author
Matthias Koeppe
committed
Merge #31276
2 parents 134c44f + 3929d2e commit bc1dc24

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

src/sage/tensor/modules/finite_rank_free_module.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,3 +2855,68 @@ def identity_map(self, name='Id', latex_name=None):
28552855
latex_name = name
28562856
self._identity_map.set_name(name=name, latex_name=latex_name)
28572857
return self._identity_map
2858+
2859+
def base_module(self):
2860+
r"""
2861+
Return the free module on which ``self`` is constructed, namely ``self`` itself.
2862+
2863+
EXAMPLES::
2864+
2865+
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
2866+
sage: M.base_module() is M
2867+
True
2868+
2869+
"""
2870+
return self
2871+
2872+
def tensor_type(self):
2873+
r"""
2874+
Return the tensor type of ``self``, the pair `(1, 0)`.
2875+
2876+
EXAMPLES::
2877+
2878+
sage: M = FiniteRankFreeModule(ZZ, 3)
2879+
sage: M.tensor_type()
2880+
(1, 0)
2881+
2882+
"""
2883+
return (1, 0)
2884+
2885+
def tensor_power(self, n):
2886+
r"""
2887+
Return the ``n``-fold tensor product of ``self``.
2888+
2889+
EXAMPLES::
2890+
2891+
sage: M = FiniteRankFreeModule(QQ, 2)
2892+
sage: M.tensor_power(3)
2893+
Free module of type-(3,0) tensors on the 2-dimensional vector space over the Rational Field
2894+
sage: M.tensor_module(1,2).tensor_power(3)
2895+
Free module of type-(3,6) tensors on the 2-dimensional vector space over the Rational Field
2896+
"""
2897+
tensor_type = self.tensor_type()
2898+
return self.base_module().tensor_module(n * tensor_type[0], n * tensor_type[1])
2899+
2900+
def tensor_product(self, *others):
2901+
r"""
2902+
Return the tensor product of ``self`` and ``others``.
2903+
2904+
EXAMPLES::
2905+
2906+
sage: M = FiniteRankFreeModule(QQ, 2)
2907+
sage: M.tensor_product(M)
2908+
Free module of type-(2,0) tensors on the 2-dimensional vector space over the Rational Field
2909+
sage: M.tensor_product(M.tensor_module(1,2))
2910+
Free module of type-(2,2) tensors on the 2-dimensional vector space over the Rational Field
2911+
sage: M.tensor_module(1,2).tensor_product(M)
2912+
Free module of type-(2,2) tensors on the 2-dimensional vector space over the Rational Field
2913+
sage: M.tensor_module(1,1).tensor_product(M.tensor_module(1,2))
2914+
Free module of type-(2,3) tensors on the 2-dimensional vector space over the Rational Field
2915+
2916+
"""
2917+
from sage.modules.free_module_element import vector
2918+
base_module = self.base_module()
2919+
if not all(module.base_module() == base_module for module in others):
2920+
raise NotImplementedError('all factors must be tensor modules over the same base module')
2921+
tensor_type = sum(vector(module.tensor_type()) for module in [self] + list(others))
2922+
return base_module.tensor_module(*tensor_type)

0 commit comments

Comments
 (0)