Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to find absolute value in matrix in C?

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.");
                }
            }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

int abs(int) is for int.

Use double fabs(double) with doubles.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading