Annotation of researchv10dc/libc/math/sin.c, revision 1.1

1.1     ! root        1: /*
        !             2:        C program for floating point sin/cos.
        !             3:        Calls modf.
        !             4:        There are no error exits.
        !             5:        Coefficients are #3370 from Hart & Cheney (18.80D).
        !             6: */
        !             7: 
        !             8: static double twoopi   = 0.63661977236758134308;
        !             9: static double p0       =  .1357884097877375669092680e8;
        !            10: static double p1       = -.4942908100902844161158627e7;
        !            11: static double p2       =  .4401030535375266501944918e6;
        !            12: static double p3       = -.1384727249982452873054457e5;
        !            13: static double p4       =  .1459688406665768722226959e3;
        !            14: static double q0       =  .8644558652922534429915149e7;
        !            15: static double q1       =  .4081792252343299749395779e6;
        !            16: static double q2       =  .9463096101538208180571257e4;
        !            17: static double q3       =  .1326534908786136358911494e3;
        !            18: 
        !            19: double
        !            20: cos(arg)
        !            21: double arg;
        !            22: {
        !            23:        double sinus();
        !            24:        if(arg<0)
        !            25:                arg = -arg;
        !            26:        return(sinus(arg, 1));
        !            27: }
        !            28: 
        !            29: double
        !            30: sin(arg)
        !            31: double arg;
        !            32: {
        !            33:        double sinus();
        !            34:        return(sinus(arg, 0));
        !            35: }
        !            36: 
        !            37: static double
        !            38: sinus(x, quad)
        !            39: double x;
        !            40: int quad;
        !            41: {
        !            42:        double modf();
        !            43:        double e, f;
        !            44:        double xsq;
        !            45:        int k;
        !            46:        double temp1, temp2;
        !            47: 
        !            48:        if(x<0) {
        !            49:                x = -x;
        !            50:                quad = quad + 2;
        !            51:        }
        !            52:        x = x*twoopi;   /*underflow?*/
        !            53:        if(x>32764){
        !            54:                x = modf(x,&e);
        !            55:                e = e + quad;
        !            56:                modf(0.25*e,&f);
        !            57:                quad = e - 4*f;
        !            58:        }else{
        !            59:                k = x;
        !            60:                x -= k;
        !            61:                quad = (quad + k) & 03;
        !            62:        }
        !            63:        if (quad & 01)
        !            64:                x = 1-x;
        !            65:        if(quad > 1)
        !            66:                x = -x;
        !            67: 
        !            68:        xsq = x*x;
        !            69:        temp1 = ((((p4*xsq+p3)*xsq+p2)*xsq+p1)*xsq+p0)*x;
        !            70:        temp2 = ((((xsq+q3)*xsq+q2)*xsq+q1)*xsq+q0);
        !            71:        x = temp1/temp2;
        !            72:        return x>1.0? 1.0: x<-1.0? -1.0: x;
        !            73: }

unix.superglobalmegacorp.com

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