Differences

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

Link to this comparison view

documentation:ref:sum [2015/11/21 12:33]
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:
 +<sxh groovy; gutter: false>
 +def t = '​f_ba^c_c + t_ab^d_d'​.t
 +println t.indice
 +</​sxh>​
 +<sxh plain; gutter: false>
 +   > _ab
 +</​sxh>​
 +
 +''​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>​
 +<table style="​width:​600px;"​ cellpadding="​10">​
 +<tr>
 +  <td valign="​top"​ style="​padding:​ 15px;​margin-top:​ 35px;​border:​ 1px solid gray;"><​code>​.select(positions)</​code></​td>​
 +  <td valign="​top"​ style="​padding:​ 15px;​margin-top:​ 35px;​border:​ 1px solid gray;">​returns a sum of elements at specified positions</​td> ​
 +</tr>
 +<tr>
 +  <td valign="​top"​ style="​padding:​ 15px;​margin-top:​ 35px;​border:​ 1px solid gray;"><​code>​.remove(positions)</​code></​td>​
 +  <td valign="​top"​ style="​padding:​ 15px;​margin-top:​ 35px;​border:​ 1px solid gray;">​returns a sum with removed elements at specified positions</​td> ​
 +</tr>
 +</​table>​
 +</​html>​
 +
 +Consider examples:
 +<sxh groovy; gutter: true>
 +def s = 'a + b + c + d + e + f'.t
 +println s.select(2, 3, 5)
 +</​sxh>​
 +<sxh plain; gutter: false>
 +   > c+b+a
 +</​sxh>​
 +<sxh groovy; gutter: true;​first-line:​ 3>
 +println s.remove(2, 3, 5)
 +</​sxh>​
 +<sxh plain; gutter: false>
 +   > d+e+f
 +</​sxh>​
 +====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]]