Sum


Basics

Sum represents a sum of terms. Like any other expression, it inherits all properties of Tensor. Sum adopts the following convention on its indices: the indices of sum are free sorted indices of its summands:

def t = 'f_ba^c_c + t_ab^d_d'.t
println t.indice
   > _ab

Sum sorts its arguments and reduces any equal terms. Additionally, it reduces terms with same tensorial parts as described in Standard form of mathematical expressions.

Additional features

There are several features in addition to those defined in Tensor that are inherent only in Sum and Product:

.select(positions) returns a sum of elements at specified positions
.remove(positions) returns a sum with removed elements at specified positions

Consider examples:

def s = 'a + b + c + d + e + f'.t
println s.select(2, 3, 5)
   > c+b+a
println s.remove(2, 3, 5)
   > d+e+f

See also