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

  1. /*
  2.     <complex.h> -- definitions for complex arithmetic routines
  3.  
  4.     last edit:    86/01/04    D A Gwyn
  5.  
  6.     SCCS ID:    @(#)complex.h    1.1 (modified for public version)
  7. */
  8.  
  9. /* "complex number" data type: */
  10.  
  11. typedef struct
  12.     {
  13.     double        re;        /* real part */
  14.     double        im;        /* imaginary part */
  15.     }    complex;
  16.  
  17. /* "The future is now": */
  18.  
  19. #ifdef __STDC__    /* X3J11 */
  20. #define    _CxGenPtr    void *        /* generic pointer type */
  21. #else        /* K&R */
  22. #define    _CxGenPtr    char *        /* generic pointer type */
  23. #endif
  24.  
  25. /* functions that are correctly done as macros: */
  26.  
  27. #define    CxAllo()        ((complex *)malloc( sizeof (complex) ))
  28. #define    CxFree( cp )        free( (_CxGenPtr)(cp) )
  29. #define    CxNeg( cp )        CxScal( cp, -1.0 )
  30. #define    CxReal( cp )        (cp)->re
  31. #define    CxImag( cp )        (cp)->im
  32.  
  33. extern void        free();
  34. extern _CxGenPtr    malloc();
  35.  
  36. /* library functions: */
  37.  
  38. extern double    CxAmpl(), CxPhas();
  39. extern complex    *CxAdd(), *CxConj(), *CxCons(), *CxCopy(), *CxDiv(),
  40.         *CxMul(), *CxPhsr(), *CxScal(), *CxSqrt(), *CxSub();
  41.