cabs
Computes the absolute value of the complex number value by a square root calculation
#include <math.h>
double cabs (
struct complex value);
The absolute value is returned.
The struct complex structure is defined as
struct complex
{
double real;
double imag;
};
where real is the real part and imag is the imaginary part. In certain cases, overflow errors can occur that cause the matherr routine to be invoked.
The cabs function computes the absolute value of the complex number value by a calculation that is equivalent to
sqrt ((value.real * value.real) + (value.imag * value.imag))
#include <math.h>
#include <stdio.h>
main ()
{
struct complex c = {-3.0, 4.0};
printf ("%f\n", cabs (c) );
}
produces the following:
5.000000