I can't tell what this is doing. I need a for loop that sums up the product of several arrays. I am just going to post what I have and then explain.
1 2 3 4 5 6 7 8
|
int total = 0;
for (int i=0; index < (columns - 2); index++)
for(int indexFF = 0; indexFF < CG[index + 2] - 1; index++)
for (int indexIN = 0; indexIN < CG[index + 1] - 1; indexIN++, total++)
NRN[CG[index + 1]+indexFF] += FF[total] * NRN[indexIN + CG[index]];
|
right now "columns" is set to 3
CG[] is an array of 10 integers for "column groups"
for now they are set to:
CG[0] = 0
CG[1] = 3
CG[2] = 4
CG[3] = 3
NRN[] is an array of floating points
NRN uses CG to map its indexes out
0 3 7
1 4 8
2 5 9
_6
FF[] is an array of random numbers basically constants
I need the for loops to sum:
NRN[0] = 0.5
NRN[1] = 0.75
NRN[2] = -1
NRN[3] = NRN[0]*FF[0] + NRN[1]*FF[1] + NRN[2]*FF[2]
NRN[4] = NRN[0]*FF[3] + NRN[1]*FF[4] + NRN[2]*FF[5]
NRN[5] = NRN[0]*FF[6] + NRN[1]*FF[7] + NRN[2]*FF[8]
NRN[6] = -1
NRN[7] = NRN[3]*FF[9] + NRN[4]*FF[10] + NRN[5]*FF[11] + NRN[6]*FF[12]
NRN[8] = NRN[3]*FF[13] + NRN[4]*FF[14] + NRN[5]*FF[16] + NRN[6]*FF[17]
NRN[9] = -1
NRN, FF and CG are the only things in other code that I can't change in the loops
when I debug it index goes to 3 and overflows its memory.
which it shouldn't because columns = 3 so "index < (columns - 2)" should stop at 1