switch (m%4)
case 0:
ms = m-1;
ckm(ms+1) = -m;
break;
case 1:
ms = m;
ckm(ms+1) = 1;
break;
case 2:
ms = m-1;
ckm(ms+1) = m;
break;
case 3:
ms = m;
ckm(ms+1) = -1;
break;
or
1 2 3 4
int tmp_0[] = {m-1, m, m-1, m};
int tmp_1[] = {-m, 1, m, -1};
ms = tmp_0[m%4];
ckm[ms] = tmp_1[m%4];
or is there some other, better way, possible a little trick, to do that? what do you think?
Thank you. That is what I also thought.
But I see it as a little algorithmic puzzle, so I was actually looking for some neat trick, like for example writing the tmp_1 as a*{-1 1 1 -1} + b*{-1 -1 1 1}, with a = (m+1)/2, and b = (m-1)/2, but everything I could come up with, appears to be too complicated, at least when expressed in C++. any nice ideas?