#1020: Reduce WeylScal4 code size ------------------------------------+--------------------------------------- Reporter: eschnett | Owner: Type: enhancement | Status: review Priority: major | Milestone: Component: EinsteinToolkit thorn | Version: Resolution: | Keywords: ------------------------------------+---------------------------------------
Comment (by eschnett):
No, there is no mechanism to give hints to CSE.
Hmm. {{{ gamma[ua,lb,lc] -> gu[ua,ud] (PD[g[ld,lb],lc] + PD[lb,ld],lc] - PD[g[lb,lc],ld]) CSEHint -> {PD[g[ld,lb],lc] + PD[lb,ld],lc] - PD[g[lb,lc],ld]} }}} That doesn't look nicer than my solution: {{{ gammal[ld,lb,lc] -> PD[g[ld,lb],lc] + PD[lb,ld],lc] - PD[g[lb,lc],ld], gamma[ua,lb,lc] -> gu[ua,ud] gammal[ld,lb,lc] }}}
Or maybe: {{{ gamma[ua,lb,lc] -> gu[ua,ud] Save[PD[g[ld,lb],lc] + PD[lb,ld],lc] - PD[g[lb,lc],ld]] }}} where "Save" indicates that the expression should be saved in a temporary variable.
Or maybe Kranc should do this grouping automatically when it expands indices for implicit sums.
Maybe it would suffice to factor out those terms in a produce that are independent of the index that is expanded. That is, a term {{{ A B[ui] C[li] }}} becomes then {{{ A (B1 C1 + B2 C2 + B3 C3) }}} instead of repeating A three times. In long expressions, especially if multiple indices are expanded in the same product, this could be a big winner.
Alternatively, and much more difficult, CSE could be looking for expressions with this pattern: {{{ A X1 + A X2 + A X3 }}} and either transform this to {{{ A (X1 + X2 + X3) }}} or at least identify A as a common subexpression. Of course, A would be a whole expression, and could be "spread out", i.e. wildly intermixed with the Xs.