This shows you the differences between two versions of the page.
documentation:ref:expandandeliminate [2015/11/21 10:25] poslavskysv [Description] |
documentation:ref:expandandeliminate [2015/11/21 12:33] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== ExpandAndEliminate ====== | ||
- | ---- | ||
- | ====Description==== | ||
- | * ''ExpandAndEliminate'' expands out product of sums and positive integer powers and permanently eliminates metric and Kronecker deltas. | ||
- | |||
- | * ''ExpandAndEliminate'' is equivalent to sequential applying ''Expand & EliminateMetrics'' but works faster since applies ''EliminateMetrics'' at each level of expand procedure. | ||
- | |||
- | |||
- | * ''ExpandAndEliminate'' is equal to ''Expand[EliminateMetrics] & EliminateMetrics''. | ||
- | |||
- | |||
- | * When no metric tensors or Kronecker deltas involved, ''ExpandAndEliminate'' works same as ''Expand''. | ||
- | |||
- | * ''ExpandAndEliminate[simplifications]'' or ''%%ExpandAndEliminate[[Simplifications: simplifications]]%%'' will apply additional simplifications at each level of expand procedure | ||
- | |||
- | ====Examples==== | ||
- | ---- | ||
- | Expand product of sums and eliminate metrics: | ||
- | <sxh groovy; gutter: false> | ||
- | def t = '(A_a*g_mn + A_m*g_an + A_n*g_am)*(A^a*g^mn + A^m*g^an + A^n*g^am)'.t | ||
- | println ExpandAndEliminate >> t | ||
- | </sxh> | ||
- | <sxh plain; gutter: false> | ||
- | > 6*A_{n}*A^{n}+3*d^{n}_{n}*A_{m}*A^{m} | ||
- | </sxh> | ||
- | |||
- | |||
- | ---- | ||
- | When no metric tensors or Kronecker deltas involved, ''ExpandAndEliminate'' works same as ''Expand'': | ||
- | <sxh groovy; gutter: false> | ||
- | println Expand >> '(A_m^m + 1)**3'.t | ||
- | </sxh> | ||
- | <sxh plain; gutter: false> | ||
- | > 3*A_{m}^{m}*A_{a}^{a}+A_{m}^{m}*A_{a}^{a}*A_{b}^{b}+1+3*A_{b}^{b} | ||
- | </sxh> | ||
- | |||
- | |||
- | ---- | ||
- | ====Details==== | ||
- | ''ExpandAndEliminate'' is equivalent to sequential applying ''Expand & EliminateMetrics'' but works faster since it applies ''EliminateMetrics'' at each level of expand procedure. One can check the advantages of ''ExpandAndEliminate'' in the following example with random tensors: | ||
- | <sxh groovy; gutter: false> | ||
- | //create random generator, which generates | ||
- | // random tensors consisting of metric and A_m | ||
- | def randomTensor = new RandomTensor() | ||
- | randomTensor.clearNamespace() | ||
- | randomTensor.addToNamespace('g_mn'.t, 'A_m'.t) | ||
- | |||
- | def a, b | ||
- | //loop to warm up JVM | ||
- | for (def i in 0..1000) { | ||
- | //next random tensor | ||
- | def t = randomTensor.nextTensorTree(4, 3, 8, '_a'.si) | ||
- | |||
- | //this will typically 10 times faster | ||
- | timing { | ||
- | a = ExpandAndEliminate >> t | ||
- | } | ||
- | //than this | ||
- | timing { | ||
- | b = (Expand & EliminateMetrics) >> t | ||
- | } | ||
- | |||
- | assert a == b | ||
- | println '' | ||
- | } | ||
- | </sxh> | ||
- | The sample output will looks like: | ||
- | <sxh plain; gutter: false> | ||
- | Time: 14 ms. | ||
- | Time: 88 ms. | ||
- | |||
- | Time: 52 ms. | ||
- | Time: 553 ms. | ||
- | |||
- | Time: 40 ms. | ||
- | Time: 577 ms. | ||
- | </sxh> | ||
- | |||
- | ====See also==== | ||
- | * Related guides: [[documentation:guide:applying_and_manipulating_transformations]], [[documentation:guide:list_of_transformations]] | ||
- | * Related transformations: [[documentation:ref:expand]], [[documentation:ref:eliminatemetrics]] | ||
- | * JavaDocs: [[http://api.redberry.cc/redberry/1.1.8/java-api/cc/redberry/core/transformations/expand/ExpandTransformation.html|ExpandTransformation]] | ||
- | * Source code: [[https://bitbucket.org/redberry/redberry/src/tip/core/src/main/java/cc/redberry/core/transformations/expand/ExpandTransformation.java|ExpandTransformation.java]] |