Annotation of researchv9/cmd/cfront/libC/complex/sin.c, revision 1.1.1.1

1.1       root        1: 
                      2: #include "complex.h"
                      3: #include "const.h"
                      4: 
                      5: complex        sin(complex z)
                      6: /*
                      7:        sine of z: -i * sinh(i*z)
                      8: */
                      9: {
                     10:        complex y = complex(-z.im, z.re);       /*  i * z */
                     11:        y = sinh(y);                            /*  csinh(y) */
                     12:        return complex(y.im, -y.re);            /*  -i * y */
                     13: }
                     14: 
                     15: complex sinh(complex z)
                     16: /*
                     17:        The hyperbolic sine
                     18: */
                     19: {
                     20:        double cosh_x, sinh_x, cos_y, sin_y;
                     21: 
                     22: #define SINH_GOOD      1e7
                     23: #define SINH_HUGE      1e38
                     24: 
                     25:        if (z.re > MAX_EXPONENT) {
                     26:                complex_error(C_SINH_RE, z.re);
                     27:                cosh_x = sinh_x = SINH_HUGE;
                     28:        }
                     29:        else if (z.re < MIN_EXPONENT) {
                     30:                complex_error(C_SINH_RE, z.re);
                     31:                cosh_x = SINH_HUGE;
                     32:                sinh_x = -SINH_HUGE;
                     33:        }
                     34:        else {
                     35:                double pos_exp = exp(z.re); 
                     36:                double neg_exp = 1/pos_exp;
                     37:                cosh_x = (pos_exp + neg_exp)/2;
                     38:                sinh_x = (pos_exp - neg_exp)/2;
                     39:        }
                     40: 
                     41:        if (ABS(z.im) > SINH_GOOD) { 
                     42:                complex_error(C_SINH_IM, z.im);
                     43:                cos_y = sin_y = 0;
                     44:        }
                     45:        else  {
                     46:                cos_y = cos(z.im);
                     47:                sin_y = sin(z.im);
                     48:        }
                     49: 
                     50:        return complex(cos_y*sinh_x, sin_y*cosh_x);
                     51: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.