POK
k_sinf.c
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Sat Jan 31 20:12:07 2009
15  */
16 
17 /* k_sinf.c -- float version of k_sin.c
18  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
19  */
20 
21 /*
22  * ====================================================
23  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
24  *
25  * Developed at SunPro, a Sun Microsystems, Inc. business.
26  * Permission to use, copy, modify, and distribute this
27  * software is freely granted, provided that this notice
28  * is preserved.
29  * ====================================================
30  */
31 
32 #ifdef POK_NEEDS_LIBMATH
33 
34 #include <libm.h>
35 #include "math_private.h"
36 
37 static const float
38 half = 5.0000000000e-01,/* 0x3f000000 */
39 S1 = -1.6666667163e-01, /* 0xbe2aaaab */
40 S2 = 8.3333337680e-03, /* 0x3c088889 */
41 S3 = -1.9841270114e-04, /* 0xb9500d01 */
42 S4 = 2.7557314297e-06, /* 0x3638ef1b */
43 S5 = -2.5050759689e-08, /* 0xb2d72f34 */
44 S6 = 1.5896910177e-10; /* 0x2f2ec9d3 */
45 
46 float
47 __kernel_sinf(float x, float y, int iy)
48 {
49  float z,r,v;
50  int32_t ix;
51  GET_FLOAT_WORD(ix,x);
52  ix &= 0x7fffffff; /* high word of x */
53  if(ix<0x32000000) /* |x| < 2**-27 */
54  {if((int)x==0) return x;} /* generate inexact */
55  z = x*x;
56  v = z*x;
57  r = S2+z*(S3+z*(S4+z*(S5+z*S6)));
58  if(iy==0) return x+v*(S1+z*r);
59  else return x-((z*(half*y-v*r)-y)-v*S1);
60 }
61 
62 #endif