I am getting an error saying the index is out of bound and I suspect it has to do with a mistake in Formula2 method. The formuala2Matrix(formula2 method) is supposed to be a 20 columns by 5 row matrix and I am not sure if thats what I created in Formula2 method. If yes, then I got get why I have an error in formula3 method. Thank you for ur help!
Asked
Active
Viewed 48 times
1 Answers
0
in Formula2
, the k
has been added to k+2
k++
in thefor
loopk++
inif (k == j)
for (int k = 0; k < Alternatives_Count; k++)
{
if (k == j)
k++;
else
formula2.Add(formula1MatrixResult[i][j] - formula1MatrixResult[i][k]);
}
if you want to add only once, you can write like this:
for (int k = 0; k < Alternatives_Count; k++)
{
if (k != j)
{
formula2.Add(formula1MatrixResult[i][j] - formula1MatrixResult[i][k]);
}
}

cg-zhou
- 528
- 3
- 6
-
thank you so much! that helped – chicacherry Nov 16 '21 at 15:50