Nested iterations , , , , ...
Here, we will only use the sum symbol, as the index variants are the same for all others.
Nested iterations are just what the name says: You put an iteration into another one. These can all be reduced to handling a single iterations:
So even if you have multiple iterations, you can rewrite them one by one using this rule and apply the previous sections.
These multiple iterations will generally be converted into nested for loops, where leftmost symbol is the outer loop and the rightmost symbol is the inner loop.
ATTENTION: Sometimes, the indices of one iteration symbol are dependent on the previous ones. A symbol on the left is never dependent on the right ones. In code, this makes sense, as the outer loop can't depend on variables of the inner loops. Be careful to check, whether an inner index depends on outer ones.
The code will show the base case of . This kind of loop often comes up in fields such as image processing, where you iterate over a 2D pixel image.
Code:
A commonly found variant of the nested iteration is the one, where the i-th and j-th component are not directly coupled. This allows for a very simple direct optimization.
Code:
Multiple iterations folded into one: , , ...
This is just a shorthand notation, where multiple nested iterations, as seen in a previous section, are combined into one symbol.
This is often combined with things like conditions and other index variants (see other sections), so they can be a bit harder to read.
It is best to remember, that you can write them out and then apply rules from the other sections, so for example:
and