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

Commit

Permalink
Move basis method to TensorFreeModule
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Aug 3, 2020
1 parent a734bf8 commit fdd6646
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 22 deletions.
39 changes: 39 additions & 0 deletions src/sage/tensor/modules/tensor_free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
from sage.tensor.modules.free_module_morphism import \
FiniteRankFreeModuleMorphism
from sage.tensor.modules.free_module_automorphism import FreeModuleAutomorphism
from .tensor_free_submodule_basis import TensorFreeSubmoduleBasis_comp

class TensorFreeModule(FiniteRankFreeModule):
r"""
Expand Down Expand Up @@ -702,3 +703,41 @@ def basis(self, symbol, latex_symbol=None, from_family=None,
indices=indices, latex_indices=latex_indices,
symbol_dual=symbol_dual,
latex_symbol_dual=latex_symbol_dual)


@cached_method
def basis(self, symbol, latex_symbol=None, from_family=None,
indices=None, latex_indices=None, symbol_dual=None,
latex_symbol_dual=None):
r"""
EXAMPLES::
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: T = M.tensor_module(1,1)
sage: e_T = T.basis('e'); e_T
<sage.tensor.modules.tensor_free_submodule_basis.TensorFreeSubmoduleBasis_comp object at 0x7f8190a69150>
sage: for a in e_T: a.display()
e_0*e^0
e_0*e^1
e_0*e^2
e_1*e^0
e_1*e^1
e_1*e^2
e_2*e^0
e_2*e^1
e_2*e^2
sage: from sage.tensor.modules.tensor_free_submodule import TensorFreeSubmodule_comp
sage: Sym2M = TensorFreeSubmodule_comp(M, (2, 0), sym=range(2))
sage: e_Sym2M = Sym2M.basis('e'); e_Sym2M
<sage.tensor.modules.tensor_free_submodule_basis.TensorFreeSubmoduleBasis_comp object at ...>
sage: for a in e_Sym2M: a.display()
e_0*e_0
e_0*e_1
e_0*e_2
e_1*e_1
e_1*e_2
e_2*e_2
"""
return TensorFreeSubmoduleBasis_comp(self, symbol)
22 changes: 0 additions & 22 deletions src/sage/tensor/modules/tensor_free_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from sage.misc.cachefunc import cached_method
from .tensor_free_module import TensorFreeModule
from .finite_rank_free_module import FiniteRankFreeModule
from .tensor_free_submodule_basis import TensorFreeSubmoduleBasis_comp

class TensorFreeSubmodule_comp(TensorFreeModule):
r"""
Expand Down Expand Up @@ -70,24 +69,3 @@ def is_submodule(self, other):
"""
raise NotImplementedError

@cached_method
def basis(self, symbol):
r"""
EXAMPLES::
sage: from sage.tensor.modules.tensor_free_submodule import TensorFreeSubmodule_comp
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: Sym2M = TensorFreeSubmodule_comp(M, (2, 0), sym=range(2))
sage: e_Sym2M = Sym2M.basis('e'); e_Sym2M
<sage.tensor.modules.tensor_free_submodule_basis.TensorFreeSubmoduleBasis_comp object at ...>
sage: for a in e_Sym2M: a.display()
e_0*e_0
e_0*e_1
e_0*e_2
e_1*e_1
e_1*e_2
e_2*e_2
"""
return TensorFreeSubmoduleBasis_comp(self, symbol)

0 comments on commit fdd6646

Please sign in to comment.