home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / complex-lib / cxphas.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-07-14  |  406 b   |  24 lines

  1. /*
  2.     CxPhas -- phase (angle, argument) of a complex
  3.  
  4.     CxPhas( &c )    returns  arg(c)  in radians (-Pi,Pi]
  5.  
  6.     last edit:    86/01/04    D A Gwyn
  7.  
  8.     SCCS ID:    @(#)cxphas.c    1.1 (modified for public version)
  9. */
  10.  
  11. #include    <math.h>
  12.  
  13. #include    <complex.h>
  14.  
  15. double
  16. CxPhas( cp )
  17.     register complex    *cp;
  18.     {
  19.     if ( cp->re == 0.0 && cp->im == 0.0 )
  20.         return 0.0;        /* can't trust atan2() */
  21.     else
  22.         return atan2( cp->im, cp->re );
  23.     }
  24.