Skip to content

Commit aa22b33

Browse files
author
Release Manager
committed
Trac #30229: Submodules of TensorFreeModule defined by the symmetries of a Components object
We generalize `FiniteRankFreeModule.tensor_module` by giving it optional arguments `sym`, `antisym`; if given, a submodule of the tensor module spanned by the tensors with these prescribed symmetries is created. The new methods `symmetric_power` and `dual_symmetric_power` provide two important special cases. The implementation makes the standard bases of tensor modules (and of their new submodules) explicit objects. The `basis` method now works for tensor modules, not just the base module, and returns an instance of the new class `TensorFreeSubmoduleBasis_sym`, which represents the standard basis corresponding to an instance of the `Components` class (or one of its subclasses). Follow-ups: - #34427 `TensorFreeModule.isomorphism_with_fixed_basis` - #30242 Make `ExtPowerFreeModule` a quotient of `TensorFreeModule` - #30307 Refactor `Component`s into parent (a `ModuleWithBasis`) & element URL: https://trac.sagemath.org/30229 Reported by: mkoeppe Ticket author(s): Matthias Koeppe Reviewer(s): Eric Gourgoulhon
2 parents 4db51ba + fc66ad1 commit aa22b33

File tree

7 files changed

+1175
-58
lines changed

7 files changed

+1175
-58
lines changed

src/doc/en/reference/tensor_free_modules/tensors.rst

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Tensors
66

77
sage/tensor/modules/tensor_free_module
88

9+
sage/tensor/modules/tensor_free_submodule
10+
911
sage/tensor/modules/free_module_tensor
1012

1113
sage/tensor/modules/tensor_with_indices
14+
15+
sage/tensor/modules/tensor_free_submodule_basis

src/sage/tensor/modules/comp.py

+57-30
Original file line numberDiff line numberDiff line change
@@ -525,15 +525,48 @@ def _repr_(self):
525525
sage: c._repr_()
526526
'2-indices components w.r.t. [1, 2, 3]'
527527
528+
sage: from sage.tensor.modules.comp import CompWithSym
529+
sage: CompWithSym(ZZ, [1,2,3], 4, sym=(0,1))
530+
4-indices components w.r.t. [1, 2, 3],
531+
with symmetry on the index positions (0, 1)
532+
sage: CompWithSym(ZZ, [1,2,3], 4, sym=(0,1), antisym=(2,3))
533+
4-indices components w.r.t. [1, 2, 3],
534+
with symmetry on the index positions (0, 1),
535+
with antisymmetry on the index positions (2, 3)
536+
537+
sage: from sage.tensor.modules.comp import CompFullySym
538+
sage: CompFullySym(ZZ, (1,2,3), 4)
539+
Fully symmetric 4-indices components w.r.t. (1, 2, 3)
540+
541+
sage: from sage.tensor.modules.comp import CompFullyAntiSym
542+
sage: CompFullyAntiSym(ZZ, (1,2,3), 4)
543+
Fully antisymmetric 4-indices components w.r.t. (1, 2, 3)
528544
"""
529-
description = str(self._nid)
545+
prefix, suffix = self._repr_symmetry()
546+
description = prefix
547+
description += str(self._nid)
530548
if self._nid == 1:
531549
description += "-index"
532550
else:
533551
description += "-indices"
534552
description += " components w.r.t. " + str(self._frame)
553+
description += suffix
535554
return description
536555

556+
def _repr_symmetry(self):
557+
r"""
558+
Return a prefix and a suffix string describing the symmetry of ``self``.
559+
560+
EXAMPLES::
561+
562+
sage: from sage.tensor.modules.comp import Components
563+
sage: c = Components(ZZ, [1,2,3], 2)
564+
sage: c._repr_symmetry()
565+
('', '')
566+
567+
"""
568+
return "", ""
569+
537570
def _new_instance(self):
538571
r"""
539572
Creates a :class:`Components` instance of the same number of indices
@@ -3128,35 +3161,29 @@ def _canonicalize_sym_antisym(nb_indices, sym=None, antisym=None):
31283161
"index position appears more than once")
31293162
return result_sym, result_antisym
31303163

3131-
def _repr_(self):
3164+
def _repr_symmetry(self):
31323165
r"""
3133-
Return a string representation of ``self``.
3166+
Return a prefix and a suffix string describing the symmetry of ``self``.
31343167
31353168
EXAMPLES::
31363169
31373170
sage: from sage.tensor.modules.comp import CompWithSym
3138-
sage: CompWithSym(ZZ, [1,2,3], 4, sym=(0,1))
3139-
4-indices components w.r.t. [1, 2, 3],
3140-
with symmetry on the index positions (0, 1)
3141-
sage: CompWithSym(ZZ, [1,2,3], 4, sym=(0,1), antisym=(2,3))
3142-
4-indices components w.r.t. [1, 2, 3],
3143-
with symmetry on the index positions (0, 1),
3144-
with antisymmetry on the index positions (2, 3)
3145-
3171+
sage: cp = CompWithSym(QQ, [1,2,3], 4, sym=(0,1))
3172+
sage: cp._repr_symmetry()
3173+
('', ', with symmetry on the index positions (0, 1)')
3174+
sage: cp = CompWithSym(QQ, [1,2,3], 4, sym=((0,1),), antisym=((2,3),))
3175+
sage: cp._repr_symmetry()
3176+
('',
3177+
', with symmetry on the index positions (0, 1), with antisymmetry on the index positions (2, 3)')
31463178
"""
3147-
description = str(self._nid)
3148-
if self._nid == 1:
3149-
description += "-index"
3150-
else:
3151-
description += "-indices"
3152-
description += " components w.r.t. " + str(self._frame)
3179+
description = ""
31533180
for isym in self._sym:
31543181
description += ", with symmetry on the index positions " + \
31553182
str(tuple(isym))
31563183
for isym in self._antisym:
31573184
description += ", with antisymmetry on the index positions " + \
31583185
str(tuple(isym))
3159-
return description
3186+
return "", description
31603187

31613188
def _new_instance(self):
31623189
r"""
@@ -4824,19 +4851,19 @@ def __init__(self, ring, frame, nb_indices, start_index=0,
48244851
CompWithSym.__init__(self, ring, frame, nb_indices, start_index,
48254852
output_formatter, sym=range(nb_indices))
48264853

4827-
def _repr_(self):
4854+
def _repr_symmetry(self):
48284855
r"""
4829-
Return a string representation of ``self``.
4856+
Return a prefix and a suffix string describing the symmetry of ``self``.
48304857
48314858
EXAMPLES::
48324859
48334860
sage: from sage.tensor.modules.comp import CompFullySym
4834-
sage: CompFullySym(ZZ, (1,2,3), 4)
4835-
Fully symmetric 4-indices components w.r.t. (1, 2, 3)
4861+
sage: c = CompFullySym(ZZ, (1,2,3), 4)
4862+
sage: c._repr_symmetry()
4863+
('Fully symmetric ', '')
48364864
48374865
"""
4838-
return "Fully symmetric " + str(self._nid) + "-indices" + \
4839-
" components w.r.t. " + str(self._frame)
4866+
return "Fully symmetric ", ""
48404867

48414868
def _new_instance(self):
48424869
r"""
@@ -5283,19 +5310,19 @@ def __init__(self, ring, frame, nb_indices, start_index=0,
52835310
CompWithSym.__init__(self, ring, frame, nb_indices, start_index,
52845311
output_formatter, antisym=range(nb_indices))
52855312

5286-
def _repr_(self):
5313+
def _repr_symmetry(self):
52875314
r"""
5288-
Return a string representation of ``self``.
5315+
Return a prefix and a suffix string describing the symmetry of ``self``.
52895316
52905317
EXAMPLES::
52915318
52925319
sage: from sage.tensor.modules.comp import CompFullyAntiSym
5293-
sage: CompFullyAntiSym(ZZ, (1,2,3), 4)
5294-
Fully antisymmetric 4-indices components w.r.t. (1, 2, 3)
5320+
sage: c = CompFullyAntiSym(ZZ, (1,2,3), 4)
5321+
sage: c._repr_symmetry()
5322+
('Fully antisymmetric ', '')
52955323
52965324
"""
5297-
return "Fully antisymmetric " + str(self._nid) + "-indices" + \
5298-
" components w.r.t. " + str(self._frame)
5325+
return "Fully antisymmetric ", ""
52995326

53005327
def _new_instance(self):
53015328
r"""

src/sage/tensor/modules/ext_pow_free_module.py

-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ def degree(self):
436436
"""
437437
return self._degree
438438

439-
440439
#***********************************************************************
441440

442441

0 commit comments

Comments
 (0)