cabs

Computes the absolute value of the complex number value by a square root calculation

Local Servers:nonblocking
Remote Servers:N/A
Classification:Other
Service:Mathematical Computation

Syntax

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

Parameters

value
(IN) Specifies the value of the complex number.

Return Values

The absolute value is returned.

Remarks

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))
  

Example

  #include <math.h>  
  #include <stdio.h>  
   
  main ()  
  {  
     struct complex c = {-3.0, 4.0};  
     printf ("%f\n", cabs (c) );  
  }
  

produces the following:

  5.000000