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

Commit

Permalink
src/sage/tensor/modules/finite_rank_free_module.py: Move ambient_modu…
Browse files Browse the repository at this point in the history
…le, is_submodule to FiniteRankFreeModule_abstract
  • Loading branch information
mkoeppe committed Aug 26, 2022
1 parent 2bcfc21 commit 6e9bec5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 42 deletions.
72 changes: 36 additions & 36 deletions src/sage/tensor/modules/finite_rank_free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,42 @@ def zero(self):
resu.set_immutable()
return resu

def ambient_module(self): # compatible with sage.modules.free_module.FreeModule_generic
"""
Return the ambient module associated to this module.
EXAMPLES::
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: M.ambient_module() is M
True
sage: from sage.tensor.modules.tensor_free_submodule import TensorFreeSubmodule_comp
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: Sym0123x45M = TensorFreeSubmodule_comp(M, (6, 0), sym=((0, 1, 2, 3), (4, 5)))
sage: T60M = M.tensor_module(6, 0)
sage: Sym0123x45M.ambient_module() is T60M
True
"""
return self._ambient_module

ambient = ambient_module # compatible with sage.modules.with_basis.subquotient.SubmoduleWithBasis

def is_submodule(self, other):
"""
Return ``True`` if ``self`` is a submodule of ``other``.
EXAMPLES::
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: N = FiniteRankFreeModule(ZZ, 4, name='M')
sage: M.is_submodule(M)
True
sage: M.is_submodule(N)
False
"""
return self == other or self.ambient_module() == other


class FiniteRankFreeModule(FiniteRankFreeModule_abstract):
r"""
Expand Down Expand Up @@ -2941,39 +2977,3 @@ def identity_map(self, name='Id', latex_name=None):
latex_name = name
self._identity_map.set_name(name=name, latex_name=latex_name)
return self._identity_map

def ambient_module(self): # compatible with sage.modules.free_module.FreeModule_generic
"""
Return the ambient module associated to this module.
EXAMPLES::
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: M.ambient_module() is M
True
sage: from sage.tensor.modules.tensor_free_submodule import TensorFreeSubmodule_comp
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: Sym0123x45M = TensorFreeSubmodule_comp(M, (6, 0), sym=((0, 1, 2, 3), (4, 5)))
sage: T60M = M.tensor_module(6, 0)
sage: Sym0123x45M.ambient_module() is T60M
True
"""
return self._ambient_module

ambient = ambient_module # compatible with sage.modules.with_basis.subquotient.SubmoduleWithBasis

def is_submodule(self, other):
"""
Return ``True`` if ``self`` is a submodule of ``other``.
EXAMPLES::
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: N = FiniteRankFreeModule(ZZ, 4, name='M')
sage: M.is_submodule(M)
True
sage: M.is_submodule(N)
False
"""
return self == other or self.ambient_module() == other
10 changes: 4 additions & 6 deletions src/sage/tensor/modules/tensor_free_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from sage.misc.lazy_attribute import lazy_attribute
from sage.sets.disjoint_set import DisjointSet
from .tensor_free_module import TensorFreeModule
from .finite_rank_free_module import FiniteRankFreeModule
from .finite_rank_free_module import FiniteRankFreeModule_abstract

class TensorFreeSubmodule_comp(TensorFreeModule):
r"""
Expand Down Expand Up @@ -69,11 +69,9 @@ def __init__(self, fmodule, tensor_type, name=None, latex_name=None,
rank = len(list(self.irange()))
category = fmodule.category().TensorProducts().FiniteDimensional().Subobjects().or_subcategory(category)
# Skip TensorFreeModule.__init__
FiniteRankFreeModule.__init__(self, fmodule._ring, rank, name=name,
latex_name=latex_name,
start_index=fmodule._sindex,
output_formatter=fmodule._output_formatter,
category=category, ambient=ambient)
FiniteRankFreeModule_abstract.__init__(self, fmodule._ring, rank, name=name,
latex_name=latex_name,
category=category, ambient=ambient)

@cached_method
def _basis_comp(self):
Expand Down

0 comments on commit 6e9bec5

Please sign in to comment.