cabs

compute the absolute value of a complex number

Synopsis:

#include <math.h>
double cabs( struct complex value );

struct _complex {
    double  x;	/* real part */
    double  y;	/* imaginary part */
};

Description:

The cabs() function computes the absolute value of the complex number value, by a calculation that is equivalent to

sqrt( (value.x*value.x) + (value.y*value.y) )

In certain cases, overflow errors may occur, which will cause the matherr() routine to be invoked.

Returns:

the absolute value

See also:

matherr()

Examples:

#include <stdio.h>
#include <math.h>

struct _complex c = { -3.0, 4.0 };

void main()
  {
    printf( "%f\n", cabs( c ) );
  }

produces the output:

5.000000

Classification:

WATCOM

Systems:

Math