1 /*- 2 * ==================================================== 3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 * Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans. 5 * 6 * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 * Permission to use, copy, modify, and distribute this 8 * software is freely granted, provided that this notice 9 * is preserved. 10 * ==================================================== 11 * 12 * k_sinl.c and k_cosl.c merged by Steven G. Kargl 13 */ 14 15 static const long double 16 C1 = 0.04166666666666666666666666666666658424671L, 17 C2 = -0.001388888888888888888888888888863490893732L, 18 C3 = 0.00002480158730158730158730158600795304914210L, 19 C4 = -0.2755731922398589065255474947078934284324e-6L, 20 C5 = 0.2087675698786809897659225313136400793948e-8L, 21 C6 = -0.1147074559772972315817149986812031204775e-10L, 22 C7 = 0.4779477332386808976875457937252120293400e-13L, 23 S1 = -0.16666666666666666666666666666666666606732416116558L, 24 S2 = 0.0083333333333333333333333333333331135404851288270047L, 25 S3 = -0.00019841269841269841269841269839935785325638310428717L, 26 S4 = 0.27557319223985890652557316053039946268333231205686e-5L, 27 S5 = -0.25052108385441718775048214826384312253862930064745e-7L, 28 S6 = 0.16059043836821614596571832194524392581082444805729e-9L, 29 S7 = -0.76471637318198151807063387954939213287488216303768e-12L, 30 S8 = 0.28114572543451292625024967174638477283187397621303e-14L; 31 32 static const double 33 C8 = -0.1561920696721507929516718307820958119868e-15, 34 C9 = 0.4110317413744594971475941557607804508039e-18, 35 C10 = -0.8896592467191938803288521958313920156409e-21, 36 C11 = 0.1601061435794535138244346256065192782581e-23, 37 S9 = -0.82206352458348947812512122163446202498005154296863e-17, 38 S10 = 0.19572940011906109418080609928334380560135358385256e-19, 39 S11 = -0.38680813379701966970673724299207480965452616911420e-22, 40 S12 = 0.64038150078671872796678569586315881020659912139412e-25; 41 42 static inline void 43 __kernel_sincosl(long double x, long double y, int iy, long double *sn, 44 long double *cs) 45 { 46 long double hz, r, v, w, z; 47 48 z = x * x; 49 v = z * x; 50 /* 51 * XXX Replace Horner scheme with an algorithm suitable for CPUs 52 * with more complex pipelines. 53 */ 54 r = S2 + z * (S3 + z * (S4 + z * (S5 + z * (S6 + z * (S7 + z * (S8 + 55 z * (S9 + z * (S10 + z * (S11 + z * S12))))))))); 56 57 if (iy == 0) 58 *sn = x + v * (S1 + z * r); 59 else 60 *cs = x - ((z * (y / 2 - v * r) - y) - v * S1); 61 62 hz = z / 2; 63 w = 1 - hz; 64 r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * (C6 + 65 z * (C7 + z * (C8 + z * (C9 + z * (C10 + z * C11)))))))))); 66 67 *cs = w + (((1 - w) - hz) + (z * r - x * y)); 68 } 69