POK
/home/jaouen/pok_official/pok/trunk/libpok/libm/k_sinf.c
00001 /*
00002  *                               POK header
00003  * 
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team 
00013  *
00014  * Created by julien on Sat Jan 31 20:12:07 2009 
00015  */
00016 
00017 /* k_sinf.c -- float version of k_sin.c
00018  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
00019  */
00020 
00021 /*
00022  * ====================================================
00023  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00024  *
00025  * Developed at SunPro, a Sun Microsystems, Inc. business.
00026  * Permission to use, copy, modify, and distribute this
00027  * software is freely granted, provided that this notice
00028  * is preserved.
00029  * ====================================================
00030  */
00031 
00032 #ifdef POK_NEEDS_LIBMATH
00033 
00034 #include <libm.h>
00035 #include "math_private.h"
00036 
00037 static const float
00038 half =  5.0000000000e-01,/* 0x3f000000 */
00039 S1  = -1.6666667163e-01, /* 0xbe2aaaab */
00040 S2  =  8.3333337680e-03, /* 0x3c088889 */
00041 S3  = -1.9841270114e-04, /* 0xb9500d01 */
00042 S4  =  2.7557314297e-06, /* 0x3638ef1b */
00043 S5  = -2.5050759689e-08, /* 0xb2d72f34 */
00044 S6  =  1.5896910177e-10; /* 0x2f2ec9d3 */
00045 
00046 float
00047 __kernel_sinf(float x, float y, int iy)
00048 {
00049         float z,r,v;
00050         int32_t ix;
00051         GET_FLOAT_WORD(ix,x);
00052         ix &= 0x7fffffff;                       /* high word of x */
00053         if(ix<0x32000000)                       /* |x| < 2**-27 */
00054            {if((int)x==0) return x;}            /* generate inexact */
00055         z       =  x*x;
00056         v       =  z*x;
00057         r       =  S2+z*(S3+z*(S4+z*(S5+z*S6)));
00058         if(iy==0) return x+v*(S1+z*r);
00059         else      return x-((z*(half*y-v*r)-y)-v*S1);
00060 }
00061 
00062 #endif