# Differences

This shows you the differences between two versions of the page.

 — documentation:ref:sum [2015/11/21 12:33] (current) Line 1: Line 1: + ====== 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 [[documentation:​guide:​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]]:​ + + <​html>​ + ​ +
<​code>​.select(positions)​ + ​returns a sum of elements at specified positions ​ +
<​code>​.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==== + * Related guides: [[documentation:​guide:​tensors_and_indices]],​ [[documentation:​guide:​tree_traversal]] + * Reference: [[documentation:​ref:​tensor]],​ [[documentation:​ref:​product]],​ [[documentation:​ref:​indices]],​ [[documentation:​ref:​simpletensor]],​ [[documentation:​ref:​tensorfield]] + * JavaDocs: [[http://​api.redberry.cc/​redberry/​1.1.9/​java-api/​cc/​redberry/​core/​tensor/​Sum.html| Sum]] + * Source code: [[https://​bitbucket.org/​redberry/​redberry/​src/​tip/​core/​src/​main/​java/​cc/​redberry/​core/​tensor/​Sum.java|Sum.java]]