home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 247_01 / bnflsh4.c < prev    next >
Text File  |  1989-04-19  |  2KB  |  120 lines

  1. /*
  2.  *  MIRACL flash hyperbolic trig.
  3.  *  bnflsh4.c
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include "miracl.h"
  8.  
  9. /* Access Global variables */
  10.  
  11. extern int  depth;    /* error tracing... */
  12. extern int  trace[];  /* .. mechanism     */
  13.  
  14. extern big  w11,w12;  /* workspace variables */
  15.  
  16. void ftanh(x,y)
  17. flash x,y;
  18. { /* calculates y=tanh(x) */
  19.     int op[5];
  20.     copy(x,y);
  21.     if (ERNUM || size(y)==0) return;
  22.     depth++;
  23.     trace[depth]=63;
  24.     if (TRACER) track();
  25.     fexp(y,y);
  26.     op[0]=0x33;
  27.     op[1]=op[3]=op[4]=1;
  28.     op[2]=(-1);
  29.     flop(y,y,op,y);
  30.     depth--;
  31. }
  32.  
  33. void fatanh(x,y)
  34. flash x,y;
  35. { /* calculate y=atanh(x) */
  36.     int op[5];
  37.     copy(x,y);
  38.     if (ERNUM || size(y)==0) return;
  39.     depth++;
  40.     trace[depth]=64;
  41.     if (TRACER) track();
  42.     fconv(1,1,w11);
  43.     op[0]=0x66;
  44.     op[1]=op[2]=op[3]=1;
  45.     op[4]=(-1);
  46.     flop(w11,y,op,y);
  47.     flog(y,y);
  48.     fpmul(y,1,2,y);
  49.     depth--;
  50. }
  51.  
  52. void fsinh(x,y)
  53. flash x,y;
  54. { /*  calculate y=sinh(x) */
  55.     int op[5];
  56.     copy(x,y);
  57.     if (ERNUM || size(y)==0) return;
  58.     depth++;
  59.     trace[depth]=65;
  60.     if (TRACER) track();
  61.     fexp(y,y);
  62.     op[0]=0xC6;
  63.     op[2]=op[3]=op[4]=1;
  64.     op[1]=(-1);
  65.     flop(y,y,op,y);
  66.     depth--;
  67. }
  68.  
  69. void fasinh(x,y)
  70. flash x,y;
  71. { /* calculate y=asinh(x) */
  72.     copy(x,y);
  73.     if (ERNUM || size(y)==0) return;
  74.     depth++;
  75.     trace[depth]=66;
  76.     if (TRACER) track();
  77.     fmul(y,y,w11);
  78.     fincr(w11,1,1,w11);
  79.     froot(w11,2,w11);
  80.     fadd(y,w11,y);
  81.     flog(y,y);
  82.     depth--;
  83. }
  84.  
  85. void fcosh(x,y)
  86. flash x,y;
  87. { /* calculate y=cosh(x) */
  88.     int op[5];
  89.     copy(x,y);
  90.     if (ERNUM || size(y)==0)
  91.     {
  92.         convert(1,y);
  93.         return;
  94.     }
  95.     depth++;
  96.     trace[depth]=67;
  97.     if (TRACER) track();
  98.     fexp(y,y);
  99.     op[0]=0xC6;
  100.     op[1]=op[2]=op[3]=op[4]=1;
  101.     flop(y,y,op,y);
  102.     depth--;
  103. }
  104.  
  105. void facosh(x,y)
  106. flash x,y;
  107. { /* calculate y=acosh(x) */
  108.     copy(x,y);
  109.     if (ERNUM) return;
  110.     depth++;
  111.     trace[depth]=62;
  112.     if (TRACER) track();
  113.     fmul(y,y,w11);
  114.     fincr(w11,(-1),1,w11);
  115.     froot(w11,2,w11);
  116.     fadd(y,w11,y);
  117.     flog(y,y);
  118.     depth--;
  119. }
  120.