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

  1.  
  2. Listing 1:
  3.  
  4. /* complex hyperbolic sine routine intended to test
  5.    argument passing and function returns only.  This
  6.    version passes a structure containing two doubles
  7.    and returns a structure of the same type.  */
  8.  
  9. #include <dos.h>
  10. #include <math.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <time.h>
  14.  
  15. #define BIOS_DATA_SEG   0x40
  16. #define TIMER_DATA      0x6c
  17. #define TICKS_PER_DAY   0x01800B0L
  18.  
  19. struct cmplx_nmbr
  20.  
  21. {
  22.    double real;
  23.    double imag;
  24. };
  25.  
  26. long getticks(void);
  27. struct cmplx_nmbr csinh(struct cmplx_nmbr);
  28.  
  29. main()
  30.  
  31. {
  32.    int ctr;
  33.    long start, end;
  34.    struct cmplx_nmbr arg, rtrn;
  35.    start = getticks();
  36.    printf("\n  BEGIN AT CLOCK = %ld", start);
  37.    arg.real = 3.0;
  38.    arg.imag = -2.0;
  39.    for(ctr = 1; ctr <= 5000; ++ctr)
  40.       rtrn = csinh(arg);
  41.  
  42.    printf("\n\n        REAL RESULT = %lG", rtrn.real);
  43.    printf("        IMAG RESULT = %lG", rtrn.imag);
  44.    end = getticks();
  45.    printf("\n    END AT CLOCK = %ld", end);
  46.    printf("\n\n   ELAPSED TICKS = %ld", end - start);
  47. }
  48.  
  49. struct cmplx_nmbr csinh(struct cmplx_nmbr param)
  50.  
  51. {
  52.    struct cmplx_nmbr rslt;
  53.    rslt.real = cos(param.imag) * sinh(param.real);
  54.    rslt.imag = sin(param.imag) * cosh(param.real);
  55.    return rslt;
  56. }
  57.  
  58.