Opened 4 months ago

Last modified 4 months ago

#30229 new defect

Submodules of TensorFreeModule defined by the symmetries of a Components object

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-9.3
Component: linear algebra Keywords:
Cc: egourgoulhon, tscrim, gh-mjungmath, slelievre Merged in:
Authors: Matthias Koeppe Reviewers:
Report Upstream: N/A Work issues:
Branch: u/mkoeppe/extpowerfreemodule__extpowerdualfreemodule__tensorfreemodule_cannot_create_a_basis (Commits) Commit: 19915c1a8b547069a5afc7e4f65c8f3700615ef2
Dependencies: #30254, #30250 Stopgaps:

Description (last modified by mkoeppe)

Currently, TensorFreeModule does not have an interface to the bases that it uses implicitly, nor is it possible to create new bases for it.

sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: e = M.basis('e')
sage: T = M.tensor_module(1, 2); T
Free module of type-(1,2) tensors on the Rank-3 free module M over the Integer Ring
sage: T.default_basis()
No default basis has been defined on the Free module of type-(1,2) tensors on the Rank-3 free module M over the Integer Ring
sage: T.basis('q')
TypeError: __init__() missing 1 required positional argument: 'tensor_type'

On this ticket, we add a subclass TensorFreeSubmodule_comp of TensorFreeModule that implements subspaces spanned by the tensors with prescribed symmetries.

It provides a basis method that returns an instance of the new class TensorFreeSubmoduleBasis_comp, which represents the standard basis corresponding to a given Components object.

Also any TensorFreeModule provides a basis method that returns such a basis object.

Change History (30)

comment:1 Changed 4 months ago by mkoeppe

  • Summary changed from ExtPowerFreeModule and TensorFreeModule cannot create a basis to ExtPowerFreeModule, ExtPowerDualFreeModule, TensorFreeModule cannot create a basis

comment:2 follow-up: Changed 4 months ago by egourgoulhon

The current design of ExtPowerFreeModule, ExtPowerDualFreeModule and TensorFreeModule is such that they cannot have their own bases, although they are mathematically free modules and they inherit from FiniteRankFreeModule. This is because all the basis management is performed at the level of the base module. Indeed, any choice of basis in the base module gives birth uniquely to a basis in each of the tensor modules and exterior power modules. For instance:

sage: M = FiniteRankFreeModule(ZZ, 2, name='M')
sage: e = M.basis('e')
sage: t = M.tensor((1, 1), name='t'); t
Type-(1,1) tensor t on the Rank-2 free module M over the Integer Ring

The components are set and displayed with respect to the basis e = (e_0, e_1) of the base module M and its dual basis (e^0, e^1):

sage: t[e, :] = [[1, 0], [-2, 0]]
sage: t.display(e)  # equivalent to t.display()
t = e_0*e^0 - 2 e_1*e^0
sage: t.components(e)
2-indices components w.r.t. Basis (e_0,e_1) on the Rank-2 free module M 
 over the Integer Ring

The same feature holds for ExtPowerDualFreeModule elements:

sage: a = M.alternating_form(2, name='a')
sage: a.parent()
2nd exterior power of the dual of the Rank-2 free module M over the Integer Ring
sage: a[e, 0, 1] = 3
sage: a.display(e)  # equivalent to a.display()
a = 3 e^0/\e^1
sage: a.components(e)
Fully antisymmetric 2-indices components w.r.t. Basis (e_0,e_1) on the Rank-2 
 free module M over the Integer Ring

If we introduce proper bases for the derived modules ExtPowerFreeModule, ExtPowerDualFreeModule and TensorFreeModule, then t.display() would become ambiguous: shall we want a display w.r.t. to the default basis of M or to the default basis of t.parent()? Moreover, the storage of components is currently performed with respect to bases of the base module. Introducing bases in the tensor modules shall of course not lead to duplicate storage.

If we keep this design (which I would favor at this stage), then, for the sake of clarity,

sage: A = M.exterior_power(2)
sage: A.basis('w')

shall return a NotImplementedError and not a TypeError, with a message like only bases on the base module are implemented.

Last edited 4 months ago by egourgoulhon (previous) (diff)

comment:3 Changed 4 months ago by slelievre

  • Cc slelievre added
  • Description modified (diff)

comment:4 follow-up: Changed 4 months ago by mkoeppe

Thanks a lot for the explanation.

Yes, a NotImplementedError with a clear message would be an improvement.

It could also be considered whether these three classes should really be subclasses of FiniteRankFreeModule, or perhaps rather a new common baseclass.

comment:5 Changed 4 months ago by mkoeppe

  • Description modified (diff)

comment:6 in reply to: ↑ 4 Changed 4 months ago by egourgoulhon

  • Description modified (diff)

Replying to mkoeppe:

It could also be considered whether these three classes should really be subclasses of FiniteRankFreeModule, or perhaps rather a new common baseclass.

Yes, indeed!

comment:7 in reply to: ↑ 2 Changed 4 months ago by mkoeppe

Replying to egourgoulhon:

all the basis management is performed at the level of the base module. Indeed, any choice of basis in the base module gives birth uniquely to a basis in each of the tensor modules and exterior power modules.

Given this, I am also wondering whether perhaps there should be a subclass of Basis_abstract that would make these bases explicit.

comment:8 Changed 4 months ago by mkoeppe

  • Branch set to u/mkoeppe/extpowerfreemodule__extpowerdualfreemodule__tensorfreemodule_cannot_create_a_basis

comment:9 Changed 4 months ago by mkoeppe

  • Commit set to 862aca828ac0228f11afee91a4388b54d4834c74
  • Description modified (diff)

Preliminary branch


New commits:

862aca8WIP: Implement TensorFreeModule.basis with new class FreeModuleCompTensorBasis

comment:10 Changed 4 months ago by git

  • Commit changed from 862aca828ac0228f11afee91a4388b54d4834c74 to 3bd0a8a8004df62ad2e332d198e3f0529afe1f9d

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

3bd0a8aTensorFreeSubmodule_comp, TensorFreeSubmoduleBasis_comp: New

comment:11 Changed 4 months ago by mkoeppe

  • Description modified (diff)
  • Summary changed from ExtPowerFreeModule, ExtPowerDualFreeModule, TensorFreeModule cannot create a basis to Submodules of TensorFreeModule defined by the symmetries of a Components object

comment:12 Changed 4 months ago by git

  • Commit changed from 3bd0a8a8004df62ad2e332d198e3f0529afe1f9d to c4d8d07ec2f8846b0607b46d1afd7840bf606c48

Branch pushed to git repo; I updated commit sha1. New commits:

c4d8d07Move basis method to TensorFreeModule

comment:13 follow-up: Changed 4 months ago by mkoeppe

Here's an early draft, comments welcome

comment:14 in reply to: ↑ 13 Changed 4 months ago by egourgoulhon

Replying to mkoeppe:

Here's an early draft, comments welcome

Thanks. It seems that the file tensor_free_submodule_basis.py is missing in the ticket branch.

comment:15 Changed 4 months ago by git

  • Commit changed from c4d8d07ec2f8846b0607b46d1afd7840bf606c48 to 270ebb309defd1ed9c8e701c7b45cfe1d39ed45c

Branch pushed to git repo; I updated commit sha1. New commits:

270ebb3Add missing file

comment:16 follow-up: Changed 4 months ago by mkoeppe

Sorry, here you go.

comment:17 Changed 4 months ago by git

  • Commit changed from 270ebb309defd1ed9c8e701c7b45cfe1d39ed45c to 22bb5ac40338cb028cc14e587ae9a83db14c3deb

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

a734bf8TensorFreeSubmodule_comp, TensorFreeSubmoduleBasis_comp: New
fdd6646Move basis method to TensorFreeModule
a61f8e7Add missing file
c01a5e9FiniteRankFreeModule: Add methods is_submodule, ambient_module
1aedfa4TensorFreeModule: Remove duplicate method 'basis'
22bb5acTensorFreeSubmodule_comp.is_submodule: New

comment:18 Changed 4 months ago by git

  • Commit changed from 22bb5ac40338cb028cc14e587ae9a83db14c3deb to 80af815bffa9f7147adb15b65b14147558d1ea44

Branch pushed to git repo; I updated commit sha1. New commits:

6ed9e40TensorFreeSubmodule_comp.ambient_module: New
80af815Fix doctests

comment:19 Changed 4 months ago by git

  • Commit changed from 80af815bffa9f7147adb15b65b14147558d1ea44 to 8f3e41be3baa80dab17f50b1be54f4dff7904af9

Branch pushed to git repo; I updated commit sha1. New commits:

8f3e41bTensorFreeSubmodule_comp: Add alias ambient = ambient_module

comment:20 in reply to: ↑ 16 Changed 4 months ago by egourgoulhon

Replying to mkoeppe:

Sorry, here you go.

Thanks. Looks nice!

comment:21 Changed 4 months ago by mkoeppe

  • Authors set to Matthias Koeppe

comment:22 Changed 4 months ago by mkoeppe

  • Dependencies set to #30254, #30250

comment:23 Changed 4 months ago by git

  • Commit changed from 8f3e41be3baa80dab17f50b1be54f4dff7904af9 to ea1bac7b706f90d6aea1b2d568e1da28beb24543

Branch pushed to git repo; I updated commit sha1. New commits:

1da5b3dTensorFreeSubmodule_comp: Add tests
d64c8edExtPowerFreeModule._an_element_: Make sure a default basis is available
d2d7f42ExtPowerDualFreeModule._an_element_: Make sure a default basis is available
9e739e5FreeModuleLinearGroup._an_element_: Make sure a default basis is available
eec19fdTensorFreeModule._an_element_: Make sure a default basis is available
0cf7917Merge branch 't/30254/tensorfreemodule__an_element___create_a_default_basis_in_the_base_module_if_necessary' into t/30229/extpowerfreemodule__extpowerdualfreemodule__tensorfreemodule_cannot_create_a_basis
5a340d9TensorFreeModule.__init__: Remove duplicate registration of self in the base module, uniqueness check
de35db3FreeModuleBasis.__init__: Update all modules in the set fmodule._all_modules
ea1bac7Merge branch 't/30250/finiterankfreemodule__simplify_unique_representation_code_for_dependent_modules' into t/30229/extpowerfreemodule__extpowerdualfreemodule__tensorfreemodule_cannot_create_a_basis

comment:24 Changed 4 months ago by git

  • Commit changed from ea1bac7b706f90d6aea1b2d568e1da28beb24543 to c98bc5db7d4416b0a4510d0a94080aebee78e68e

Branch pushed to git repo; I updated commit sha1. New commits:

27aa573FiniteRankFreeModule: Accept init arg 'ambient'
c98bc5dTensorFreeSubmodule_comp: Factor out _is_symmetry_coarsening_of, add _element_constructor_

comment:25 Changed 4 months ago by git

  • Commit changed from c98bc5db7d4416b0a4510d0a94080aebee78e68e to d3366933fae1f4b618952b54f39952277cb37c26

Branch pushed to git repo; I updated commit sha1. New commits:

d336693Fixup

comment:26 Changed 4 months ago by git

  • Commit changed from d3366933fae1f4b618952b54f39952277cb37c26 to 84387d99ce0ec880d5a9ad07bc4bc01e81a07805

Branch pushed to git repo; I updated commit sha1. New commits:

ad8f6afTensorFreeModule._element_constructor_: Accept FreeModuleTensor of same tensor type and base module as input
84387d9TensorFreeSubmodule_comp: Set ambient correctly

comment:27 Changed 4 months ago by git

  • Commit changed from 84387d99ce0ec880d5a9ad07bc4bc01e81a07805 to b74f562ae9d611abd88221c57eec4d6e5fc2a3a7

Branch pushed to git repo; I updated commit sha1. New commits:

20266b3TensorFreeModule._coerce_map_from_: Add coercion from submodules
ec466e6TensorFreeSubmodule_comp: Fix coerce map tests
b74f562TensorFreeSubmodule_comp.lift: New

comment:28 Changed 4 months ago by git

  • Commit changed from b74f562ae9d611abd88221c57eec4d6e5fc2a3a7 to a5da63b8e6be948b9b5c8deaaa0ecdc6e9566a29

Branch pushed to git repo; I updated commit sha1. New commits:

6078437FiniteRankFreeModule: Add _test_basis method
95713feFiniteRankFreeModule._test_basis: Test indices and containment
a5da63bTensorFreeSubmoduleBasis_comp: Add keys, __getitem__; compute symmetrized elements

comment:29 Changed 4 months ago by git

  • Commit changed from a5da63b8e6be948b9b5c8deaaa0ecdc6e9566a29 to 19915c1a8b547069a5afc7e4f65c8f3700615ef2

Branch pushed to git repo; I updated commit sha1. New commits:

19915c1FiniteRankFreeModule._test_basis: Run the test suite of the basis object

comment:30 Changed 4 months ago by mkoeppe

  • Milestone changed from sage-9.2 to sage-9.3
Note: See TracTickets for help on using tickets.