Free module bases¶
The class FreeModuleBasis
implements bases on a free module \(M\) of
finite rank over a commutative ring,
while the class FreeModuleCoBasis
implements the dual bases (i.e.
bases of the dual module \(M^*\)).
AUTHORS:
- Eric Gourgoulhon, Michal Bejger (2014-2015): initial version
- Travis Scrimshaw (2016): ABC Basis_abstract and list functionality for bases (trac ticket #20770)
- Eric Gourgoulhon (2018): some refactoring and more functionalities in the choice of symbols for basis elements (trac ticket #24792)
REFERENCES:
-
sage.tensor.modules.free_module_basis.
Basis_abstract
¶ Abstract base class for (dual) bases of free modules.
-
sage.tensor.modules.free_module_basis.
FreeModuleBasis
¶ Basis of a free module over a commutative ring \(R\).
INPUT:
fmodule
– free module \(M\) (as an instance ofFiniteRankFreeModule
)symbol
– either a string, to be used as a common base for the symbols of the elements of the basis, or a tuple of strings, representing the individual symbols of the elements of the basislatex_symbol
– (default:None
) either a string, to be used as a common base for the LaTeX symbols of the elements of the basis, or a tuple of strings, representing the individual LaTeX symbols of the elements of the basis; ifNone
,symbol
is used in place oflatex_symbol
indices
– (default:None
; used only ifsymbol
is a single string) tuple of strings representing the indices labelling the elements of the basis; ifNone
, the indices will be generated as integers within the range declared onfmodule
latex_indices
– (default:None
) tuple of strings representing the indices for the LaTeX symbols of the elements of the basis; ifNone
,indices
is used insteadsymbol_dual
– (default:None
) same assymbol
but for the dual basis; ifNone
,symbol
must be a string and is used for the common base of the symbols of the elements of the dual basislatex_symbol_dual
– (default:None
) same aslatex_symbol
but for the dual basis
EXAMPLES:
A basis on a rank-3 free module over \(\ZZ\):
sage: M0 = FiniteRankFreeModule(ZZ, 3, name='M_0') sage: from sage.tensor.modules.free_module_basis import FreeModuleBasis sage: e = FreeModuleBasis(M0, 'e') ; e Basis (e_0,e_1,e_2) on the Rank-3 free module M_0 over the Integer Ring
Instead of importing
FreeModuleBasis
in the global name space, it is recommended to use the module’s methodbasis()
:sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: e = M.basis('e') ; e Basis (e_0,e_1,e_2) on the Rank-3 free module M over the Integer Ring
The individual elements constituting the basis are accessed via the square bracket operator:
sage: e[0] Element e_0 of the Rank-3 free module M over the Integer Ring sage: e[0] in M True
The slice operator
:
can be used to access to more than one element:sage: e[0:2] (Element e_0 of the Rank-3 free module M over the Integer Ring, Element e_1 of the Rank-3 free module M over the Integer Ring) sage: e[:] (Element e_0 of the Rank-3 free module M over the Integer Ring, Element e_1 of the Rank-3 free module M over the Integer Ring, Element e_2 of the Rank-3 free module M over the Integer Ring)
The LaTeX symbol can be set explicitely:
sage: latex(e) \left(e_{0},e_{1},e_{2}\right) sage: eps = M.basis('eps', latex_symbol=r'\epsilon') ; eps Basis (eps_0,eps_1,eps_2) on the Rank-3 free module M over the Integer Ring sage: latex(eps) \left(\epsilon_{0},\epsilon_{1},\epsilon_{2}\right)
The individual elements of the basis are labelled according the parameter
start_index
provided at the free module construction:sage: M = FiniteRankFreeModule(ZZ, 3, name='M', start_index=1) sage: e = M.basis('e') ; e Basis (e_1,e_2,e_3) on the Rank-3 free module M over the Integer Ring sage: e[1] Element e_1 of the Rank-3 free module M over the Integer Ring
It is also possible to fully customize the labels, via the argument
indices
:sage: f = M.basis('f', indices=('x', 'y', 'z')); f Basis (f_x,f_y,f_z) on the Rank-3 free module M over the Integer Ring sage: f[1] Element f_x of the Rank-3 free module M over the Integer Ring
The symbol of each element of the basis can also be freely chosen, by providing a tuple of symbols as the first argument of
basis
; it is then mandatory to specify some symbols for the dual basis as well:sage: g = M.basis(('a', 'b', 'c'), symbol_dual=('A', 'B', 'C')); g Basis (a,b,c) on the Rank-3 free module M over the Integer Ring sage: g[1] Element a of the Rank-3 free module M over the Integer Ring sage: g.dual_basis()[1] Linear form A on the Rank-3 free module M over the Integer Ring
-
sage.tensor.modules.free_module_basis.
FreeModuleCoBasis
¶ Dual basis of a free module over a commutative ring.
INPUT:
basis
– basis of a free module \(M\) of whichself
is the dual (must be an instance ofFreeModuleBasis
)symbol
– either a string, to be used as a common base for the symbols of the elements of the cobasis, or a tuple of strings, representing the individual symbols of the elements of the cobasislatex_symbol
– (default:None
) either a string, to be used as a common base for the LaTeX symbols of the elements of the cobasis, or a tuple of strings, representing the individual LaTeX symbols of the elements of the cobasis; ifNone
,symbol
is used in place oflatex_symbol
indices
– (default:None
; used only ifsymbol
is a single string) tuple of strings representing the indices labelling the elements of the cobasis; ifNone
, the indices will be generated as integers within the range declared on the free module on which the cobasis is definedlatex_indices
– (default:None
) tuple of strings representing the indices for the LaTeX symbols of the elements of the cobasis; ifNone
,indices
is used instead
EXAMPLES:
Dual basis on a rank-3 free module:
sage: M = FiniteRankFreeModule(ZZ, 3, name='M', start_index=1) sage: e = M.basis('e') ; e Basis (e_1,e_2,e_3) on the Rank-3 free module M over the Integer Ring sage: from sage.tensor.modules.free_module_basis import FreeModuleCoBasis sage: f = FreeModuleCoBasis(e, 'f') ; f Dual basis (f^1,f^2,f^3) on the Rank-3 free module M over the Integer Ring
Instead of importing
FreeModuleCoBasis
in the global name space, it is recommended to use the methoddual_basis()
of the basise
:sage: f = e.dual_basis() ; f Dual basis (e^1,e^2,e^3) on the Rank-3 free module M over the Integer Ring
Let us check that the elements of
f
are in the dual ofM
:sage: f[1] Linear form e^1 on the Rank-3 free module M over the Integer Ring sage: f[1] in M.dual() True
and that
f
is indeed the dual ofe
:sage: f[1](e[1]), f[1](e[2]), f[1](e[3]) (1, 0, 0) sage: f[2](e[1]), f[2](e[2]), f[2](e[3]) (0, 1, 0) sage: f[3](e[1]), f[3](e[2]), f[3](e[3]) (0, 0, 1)