home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_09 / 8n09053a < prev    next >
Text File  |  1990-07-24  |  1KB  |  53 lines

  1.  
  2.  
  3. Listing 6:
  4.  
  5. /* complex hyperbolic sine routine intended to test
  6.    argument passing and function returns only.  This
  7.    version uses a macro following Louis Baker's method
  8.    covered in "Complex Arithmetic and Matrices in C,"
  9.    the C Users Journal, May, 1990   */
  10.  
  11. #include <dos.h>
  12. #include <math.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <time.h>
  16.  
  17. #define BIOS_DATA_SEG   0x40
  18. #define TIMER_DATA      0x6c
  19. #define TICKS_PER_DAY   0x01800B0L
  20. #define CSINH(y, x) {y.real = cos(x.imag)
  21.    * sinh(x.real);\ y.imag = sin(x.imag)
  22.    * cosh(x.real);}
  23.  
  24. struct cmplx_nmbr
  25.  
  26. {
  27.    double real;
  28.    double imag;
  29. };
  30.  
  31. long getticks(void);
  32.  
  33. main()
  34.  
  35. {
  36.    int ctr;
  37.    long start, end;
  38.    struct cmplx_nmbr arg, rtrn;
  39.    start = getticks();
  40.    printf("\n  BEGIN AT CLOCK = %ld", start);
  41.    arg.real = 3.0;
  42.    arg.imag = -2.0;
  43.    for(ctr = 1; ctr <= 5000; ++ctr)
  44.       CSINH(rtrn, arg);
  45.  
  46.    printf("\n\n        REAL RESULT = %lG", rtrn.real);
  47.    printf("        IMAG RESULT = %lG", rtrn.imag);
  48.    end = getticks();
  49.    printf("\n    END AT CLOCK = %ld", end);
  50.    printf("\n\n   ELAPSED TICKS = %ld", end - start);
  51. }
  52.  
  53.