This shows you the differences between two versions of the page.
| documentation:ref:simpleindices [2015/11/21 12:33] | documentation:ref:simpleindices [2015/11/21 12:33] (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== SimpleIndices ====== | ||
| + | ---- | ||
| + | |||
| + | ====Basics==== | ||
| + | ''SimpleIndices'' represents indices of [[SimpleTensor]] and [[TensorField]]. It inherits all properties of [[Indices]] but does not sort indices., so indices in ''SimpleIndices''  appear exactly in that order as defined by the user: | ||
| + | <sxh groovy; gutter: false> | ||
| + | def indices = '_pqrs^sp'.si | ||
| + | println indices | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > _pqrs^sp | ||
| + | </sxh> | ||
| + | On the other hand, since indices of different [[IndexType|types]] have different mathematical nature, [[SimpleIndices]] are sorted according to the type (preserving relative ordering of indices of same type): | ||
| + | <sxh groovy; gutter: false> | ||
| + | println '_{mn}^{\\beta\\alpha}_{ba\\alpha}'.si | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > _{mnba}^{\beta\alpha}_{\alpha} | ||
| + | </sxh> | ||
| + | |||
| + | All properties and methods of ''SimpleIndices'' leaves the relative ordering of indices unchanged. | ||
| + | |||
| + | |||
| + | ''SimpleIndices'' has ''.symmetries'' property which allows to define their permutational symmetries. | ||
| + | |||
| + | ====Features==== | ||
| + | Since ''SimpleIndices'' is a subtype of [[Indices]], it inherits all its properties. However,  in contrast to [[Indices]], ''SimpleIndices'' and all its properties and methods preserve the relative ordering of indices. | ||
| + | |||
| + | Consider examples. Parse ''SimpleIndices'' from string: | ||
| + | <sxh groovy; gutter: true> | ||
| + | def indices = '^an_ab^m_pq^b'.si | ||
| + | println indices | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > ^{an}_{ab}^{m}_{pq}^{b} | ||
| + | </sxh> | ||
| + | Get just free indices: | ||
| + | <sxh groovy; gutter: true; first-line: 3> | ||
| + | println indices.free | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > ^{nm}_{pq} | ||
| + | </sxh> | ||
| + | Invert indices: | ||
| + | <sxh groovy; gutter: true; first-line: 4> | ||
| + | println indices.inverted | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > _{an}^{ab}_{m}^{pq}_{b} | ||
| + | </sxh> | ||
| + | Get only contravariant indices: | ||
| + | <sxh groovy; gutter: true; first-line: 5> | ||
| + | println indices.upper | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > ^{anmb} | ||
| + | </sxh> | ||
| + | Get only covariant indices: | ||
| + | <sxh groovy; gutter: true; first-line: 6> | ||
| + | println indices.lower | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > _{abpq} | ||
| + | </sxh> | ||
| + | |||
| + | Parse indices with multiple types: | ||
| + | <sxh groovy; gutter: true> | ||
| + | def indices = '^AB_pqrs^C_A^sp'.si | ||
| + | println indices | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > _{pqrs}^{spABC}_{A} | ||
| + | </sxh> | ||
| + | Get just Latin upper case: | ||
| + | <sxh groovy; gutter: true; first-line: 3> | ||
| + | println indices.getOfType(LatinUpper) | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > ^{ABC}_{A} | ||
| + | </sxh> | ||
| + | Get first index: | ||
| + | <sxh groovy; gutter: true; first-line: 4> | ||
| + | println indices[0].toStringIndex() | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > _{p} | ||
| + | </sxh> | ||
| + | Get first Latin upper index: | ||
| + | <sxh groovy; gutter: true; first-line: 5> | ||
| + | println indices[LatinUpper, 0].toStringIndex() | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > ^{A} | ||
| + | </sxh> | ||
| + | Get several indices at a time: | ||
| + | <sxh groovy; gutter: true; first-line: 6> | ||
| + | println indices[1, 3, 4] | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > _{qs}^{s} | ||
| + | </sxh> | ||
| + | Get range: | ||
| + | <sxh groovy; gutter: true; first-line: 7> | ||
| + | println indices[1..4] | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > _{qrs}^{s} | ||
| + | </sxh> | ||
| + | |||
| + | As one can see, all methods in the above examples return indices which have same relative ordering as in the initial object. | ||
| + | |||
| + | ====Symmetries==== | ||
| + | Symmetries can be attached to a single ''SimpleIndices'' object by using ''.symmetry'' property: | ||
| + | <sxh groovy; gutter: false> | ||
| + | def indices = '_abcdef'.si | ||
| + | indices.symmetries.addSymmetry([[0, 1], [2, 3]].p) | ||
| + | indices.symmetries.addSymmetry([[0, 3, 5]].p) | ||
| + | println indices.symmetries.permutationGroup.order() | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > 60 | ||
| + | </sxh> | ||
| + | Symmetries of simple indices can be used in transformations like [[Symmetrize]] or other methods like [[GenerateTensor]] or [[Reduce]]. | ||
| + | |||
| + | The ''.symmetries'' property return a container of [[documentation:ref:permutation| permutations]] and a corresponding [[PermutationGroup]]. The latter can be accessed by taking ''.permutationGroup'' property. | ||
| + | |||
| + | It should be noted, that when specifying symmetries of simple tensors like | ||
| + | <sxh groovy; gutter: true> | ||
| + | 'f_abc'.t.indices.symmetries.addSymmetry( [1, 0].p ) | ||
| + | </sxh> | ||
| + | these symmetries will be automatically attached to indices of all instances of tensor ''f_abc'', i. e. ''f_pqr'' or ''f_a^a_y'' etc.: | ||
| + | <sxh groovy; gutter: true;first-line: 2> | ||
| + | println 'f_pq^i'.t.indices.symmetries.permutationGroup | ||
| + | </sxh> | ||
| + | <sxh plain; gutter: false> | ||
| + | > Group( +[[0, 1]] ) | ||
| + | </sxh> | ||
| + | |||
| + | On the other hand, when specifying symmetries of "detached" indices: | ||
| + | <sxh groovy; gutter: false> | ||
| + | def ind = '_abc'.si | ||
| + | ind.si.indices.symmetries.addSymmetry( [1, 0].p ) | ||
| + | </sxh> | ||
| + | they will be attached just to the particular object (''ind'' in the above example).  | ||
| + | |||
| + | ====See also==== | ||
| + | * Related guides: [[documentation:guide:tensors_and_indices]], [[documentation:guide:symmetries_of_tensors]] | ||
| + | * Reference material: [[documentation:ref:indices]], [[documentation:ref:indextype]], [[documentation:ref:simpletensor]], [[documentation:ref:tensorfield]], [[documentation:ref:permutation]], [[documentation:ref:symmetrize]], [[documentation:ref:generatetensor]], [[documentation:ref:reduce]], [[documentation:ref:permutationgroup]] | ||
| + | * JavaDocs: [[http://api.redberry.cc/redberry/1.1.9/java-api/cc/redberry/core/indices/SimpleIndices.html| SimpleIndices]] | ||
| + | * Source code: [[https://bitbucket.org/redberry/redberry/src/tip/core/src/main/java/cc/redberry/core/indices/SimpleIndices.java|SimpleIndices.java]] | ||