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

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