Context:
I was reading a tutorial on polyhedral optimization. But got confused while trying to translate the iteration domain (i.e. loop bound) to set builder notation.
Problem Description:
A code snippet from the article;
for (int i = 0; i <= 2*N; ++i)
S: Z[i] = 0.;
The iteration domain for the statement 'S' is described with the set-builder notation as
{S[i] : 0 ≤ i ≤ N}
. But the code says that i should go up to or equal to 2*N
.
Example Case:
Let’s consider the code given above. And also assume N = 5
Then this loop will iterate from i = 0 to 10 (where, 2xN = 2x5 = 10)
.
But from the set builder notation, we can see that the iteration domain should be in the range of
0 <= i <= N, i.e, 0 <= i <= 5
.
But considering the real code snippet,
for (int i = 0; i <= 2*N; ++i)
S: Z[i] = 0;
i
go up to 10.
So my doubts are…
- Then should I write the set builder as
{S[i] : 0 ≤ i ≤ 2N}
or{S[i] : 0 ≤ i ≤ N}
? - For now, even if both of them are correct; later are there any implications/issues that would arise? That I should be concerned on now? I am asking, because I have seen, that those notations are heavily used in forming systems of equations (To solve what, I don’t know yet )
Screenshots are attached from the tutorial for quick review. Thank you.