samedi 19 décembre 2015

My program skips the if statement

Im prigraming a program that would make a power of a matrix. as you see, im trying to ask at the for (int n...) loop (if n==0)? but when Im debugging - I see that the program just skips the condition, and not even entering it and the skips. I mean it doesnt even "ask" the question if n=0... What is the problem?

void Matrix::pow(int power, Matrix & result)
{
    for (int i = 0; i < power-1; i++)
    {
        for (int j = 0; j < rows; j++)
        {
            for (int k = 0; k < cols; k++)
            {
                for (int n = 0; n < cols; n++)
                {
                    if (n==0)
                    {
                        (&result)->_array[i][j] == 0; //Reset result's array.
                    }
                    (&result)->_array[i][j] += this->_array[i][n] * this->_array[n][j];
                }
            }
        }
    }
}

Thx!!

Aucun commentaire:

Enregistrer un commentaire