1997-04-15 01:38:39 +00:00
|
|
|
/* Compute sine and cosine of argument.
|
2014-01-01 11:03:15 +00:00
|
|
|
Copyright (C) 1997-2014 Free Software Foundation, Inc.
|
1997-04-15 01:38:39 +00:00
|
|
|
This file is part of the GNU C Library.
|
1999-07-14 00:54:57 +00:00
|
|
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
|
|
|
|
Jakub Jelinek <jj@ultra.linux.cz>.
|
1997-04-15 01:38:39 +00:00
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00: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 01:38:39 +00: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 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1997-04-15 01:38:39 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1997-04-15 01:38:39 +00:00
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
2012-03-09 19:29:16 +00:00
|
|
|
#include <math_private.h>
|
1997-04-15 01:38:39 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
__sincosl (long double x, long double *sinx, long double *cosx)
|
|
|
|
{
|
1999-07-14 00:54:57 +00:00
|
|
|
int64_t ix;
|
1997-04-15 01:38:39 +00:00
|
|
|
|
|
|
|
/* High word of x. */
|
1999-07-14 00:54:57 +00:00
|
|
|
GET_LDOUBLE_MSW64 (ix, x);
|
1997-04-15 01:38:39 +00:00
|
|
|
|
|
|
|
/* |x| ~< pi/4 */
|
1999-07-14 00:54:57 +00:00
|
|
|
ix &= 0x7fffffffffffffffLL;
|
|
|
|
if (ix <= 0x3ffe921fb54442d1LL)
|
1999-07-15 18:26:25 +00:00
|
|
|
__kernel_sincosl (x, 0.0L, sinx, cosx, 0);
|
1999-07-14 00:54:57 +00:00
|
|
|
else if (ix >= 0x7fff000000000000LL)
|
1997-04-15 01:38:39 +00: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-15 18:26:25 +00:00
|
|
|
__kernel_sincosl (y[0], y[1], sinx, cosx, 1);
|
1997-04-15 01:38:39 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
1999-07-15 18:26:25 +00:00
|
|
|
__kernel_sincosl (y[0], y[1], cosx, sinx, 1);
|
|
|
|
*cosx = -*cosx;
|
1997-04-15 01:38:39 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
1999-07-15 18:26:25 +00:00
|
|
|
__kernel_sincosl (y[0], y[1], sinx, cosx, 1);
|
|
|
|
*sinx = -*sinx;
|
|
|
|
*cosx = -*cosx;
|
1997-04-15 01:38:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
1999-07-15 18:26:25 +00:00
|
|
|
__kernel_sincosl (y[0], y[1], cosx, sinx, 1);
|
|
|
|
*sinx = -*sinx;
|
1997-04-15 01:38:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
weak_alias (__sincosl, sincosl)
|