-1

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!

1 Answers1

0

in Formula2, the k has been added to k+2

  1. k++ in the for loop
  2. k++ in if (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