Home > Mobile >  How to find absolute value in matrix in C?
How to find absolute value in matrix in C?

Time:12-06

I'm doing a C program to solve a system of linear equations by fixed point iteration method. And I have to check if the main matrix is diagonally dominant. But when I enter abs and element of the matrix, it says

Error (active) E0308 more than one instance of overloaded function "abs" matches the argument list.

  • How can I fix this?
//for every row
            for (i = 0; i < size; i  )
            {
    //for every column finds the sum of the row
                double sum = 0;
                for (j = 0; j < size; j  )
                    sum  = abs(k[i][j]);
                sum -= abs(k[i][i]);
    //check
                if (abs(k[i][i]) < sum) {
                    printf("The matrix is not diagonally dominant.");
                }
            }

CodePudding user response:

int abs(int) is for int.

Use double fabs(double) with doubles.

  • Related