• CollectNonScalars collects terms in sums with same tensorial parts. In contrast to standard Redberry behaviour when factored out tersorial parts with nonzero sized idices, CollectNonScalars tries to factor out parts with nonzero sized free indices.


Collect same tensorial parts:

//by default, B_m will not be factored out
def t = 'A_i*A^i*B_m + B_m'.t
println t
   > A_i*A^i*B_m + B_m
//now will
println CollectNonScalars >> t
   > (A_i*A^i + 1)*B_m

Another example:

setSymmetric 'R_mn'
println CollectNonScalars >> 'A_t*A^t*R_mn - B_t*B^t*R_nm'.t
   > (A_{t}*A^{t}-B_{t}*B^{t})*R_{mn}

See also