Annotation of coherent/b/lib/libm/cos.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * libm/cos.c
                      3:  * Evaluate the cosine function.
                      4:  */
                      5: 
                      6: #include <math.h>
                      7: 
                      8: #if    EMU87
                      9: #include "emumath.h"
                     10: #endif
                     11: 
                     12: /*
                     13:  * (Hart 2923, 19.96)
                     14:  */
                     15: static readonly double sintab[] ={
                     16:         0.523598775598298873071308e+00,
                     17:        -0.239245962039350458667960e-01,
                     18:         0.327953194428661969081000e-03,
                     19:        -0.214071976918198811800000e-05,
                     20:         0.815125650404748400000000e-08,
                     21:        -0.203153509377510000000000e-10,
                     22:         0.355397103280000000000000e-13
                     23: };
                     24: 
                     25: /*
                     26:  * (Hart 3824, 19.45)
                     27:  */
                     28: static readonly double costab[] ={
                     29:         0.99999999999999999996415,
                     30:        -0.30842513753404245242414,
                     31:         0.01585434424381541089754,
                     32:        -0.00032599188692668755044,
                     33:         0.00000359086044588581953,
                     34:        -0.00000002461136382637005,
                     35:         0.00000000011500497024263,
                     36:        -0.00000000000038577620372
                     37: };
                     38: 
                     39: double
                     40: cos(x) double x;
                     41: {
                     42:        double r;
                     43:        register int s;
                     44: 
                     45:        if ((x = modf(x/(2.0*PI), &r)) < 0.0) {
                     46:                x += 1.0;
                     47:                r -= 1.0;
                     48:        }
                     49:        s = 0;
                     50:        if (x > 0.5) {
                     51:                s = 1;
                     52:                x -= 0.5;
                     53:        }
                     54:        if (x > 0.25) {
                     55:                s ^= 1;
                     56:                x = 0.5 - x;
                     57:        }
                     58:        if (x > 0.125) {
                     59:                x = 3.0 - 12.0*x;
                     60:                r = x*_pol(x*x, sintab, 7);
                     61:        } else {
                     62:                x *= 8.0;
                     63:                r = _pol(x*x, costab, 8);
                     64:        }
                     65:        return s ? -r : r;
                     66: }
                     67: 
                     68: /* end of libm/cos.c */

unix.superglobalmegacorp.com

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