1997-04-15 09:38:39 +08:00
|
|
|
/* Compute sine and cosine of argument.
|
1999-07-14 08:54:57 +08:00
|
|
|
Copyright (C) 1997, 1999 Free Software Foundation, Inc.
|
1997-04-15 09:38:39 +08:00
|
|
|
This file is part of the GNU C Library.
|
1999-07-14 08:54:57 +08:00
|
|
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
|
|
|
|
Jakub Jelinek <jj@ultra.linux.cz>.
|
1997-04-15 09:38:39 +08:00
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 12:58:11 +08:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1997-04-15 09:38:39 +08:00
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 12:58:11 +08:00
|
|
|
Lesser General Public License for more details.
|
1997-04-15 09:38:39 +08:00
|
|
|
|
2001-07-06 12:58:11 +08:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-10 07:18:22 +08:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1997-04-15 09:38:39 +08:00
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
2012-03-10 03:29:16 +08:00
|
|
|
#include <math_private.h>
|
1997-04-15 09:38:39 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
__sincosl (long double x, long double *sinx, long double *cosx)
|
|
|
|
{
|
1999-07-14 08:54:57 +08:00
|
|
|
int64_t ix;
|
1997-04-15 09:38:39 +08:00
|
|
|
|
|
|
|
/* High word of x. */
|
1999-07-14 08:54:57 +08:00
|
|
|
GET_LDOUBLE_MSW64 (ix, x);
|
1997-04-15 09:38:39 +08:00
|
|
|
|
|
|
|
/* |x| ~< pi/4 */
|
1999-07-14 08:54:57 +08:00
|
|
|
ix &= 0x7fffffffffffffffLL;
|
|
|
|
if (ix <= 0x3ffe921fb54442d1LL)
|
1999-07-16 02:26:25 +08:00
|
|
|
__kernel_sincosl (x, 0.0L, sinx, cosx, 0);
|
1999-07-14 08:54:57 +08:00
|
|
|
else if (ix >= 0x7fff000000000000LL)
|
1997-04-15 09:38:39 +08:00
|
|
|
{
|
|
|
|
/* sin(Inf or NaN) is NaN */
|
|
|
|
*sinx = *cosx = x - x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Argument reduction needed. */
|
|
|
|
long double y[2];
|
|
|
|
int n;
|
|
|
|
|
|
|
|
n = __ieee754_rem_pio2l (x, y);
|
|
|
|
switch (n & 3)
|
|
|
|
{
|
|
|
|
case 0:
|
1999-07-16 02:26:25 +08:00
|
|
|
__kernel_sincosl (y[0], y[1], sinx, cosx, 1);
|
1997-04-15 09:38:39 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
1999-07-16 02:26:25 +08:00
|
|
|
__kernel_sincosl (y[0], y[1], cosx, sinx, 1);
|
|
|
|
*cosx = -*cosx;
|
1997-04-15 09:38:39 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
1999-07-16 02:26:25 +08:00
|
|
|
__kernel_sincosl (y[0], y[1], sinx, cosx, 1);
|
|
|
|
*sinx = -*sinx;
|
|
|
|
*cosx = -*cosx;
|
1997-04-15 09:38:39 +08:00
|
|
|
break;
|
|
|
|
default:
|
1999-07-16 02:26:25 +08:00
|
|
|
__kernel_sincosl (y[0], y[1], cosx, sinx, 1);
|
|
|
|
*sinx = -*sinx;
|
1997-04-15 09:38:39 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
weak_alias (__sincosl, sincosl)
|