]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/ieee754/dbl-64/mptan.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / ieee754 / dbl-64 / mptan.c
CommitLineData
e4d82761
UD
1/*
2 * IBM Accurate Mathematical Library
aeb25823 3 * written by International Business Machines Corp.
b168057a 4 * Copyright (C) 2001-2015 Free Software Foundation, Inc.
e4d82761
UD
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
cc7375ce 8 * the Free Software Foundation; either version 2.1 of the License, or
e4d82761 9 * (at your option) any later version.
50944bca 10 *
e4d82761
UD
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c6c6dd48 14 * GNU Lesser General Public License for more details.
e4d82761
UD
15 *
16 * You should have received a copy of the GNU Lesser General Public License
59ba27a6 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
e4d82761
UD
18 */
19/**********************************************************************/
20/* MODULE_NAME:mptan.c */
21/* */
22/* FUNCTION: mptan */
23/* */
24/* FILES NEEDED: endian.h mpa.h */
25/* mpa.c sincos32.c branred.c */
26/* */
27/* Multi-Precision tan() function subroutine, for p=32. It is based */
28/* on the routines mpranred() and c32(). mpranred() performs range */
29/* reduction of a double number x into a multiple precision number */
30/* y, such that y=x-n*pi/2, abs(y)<pi/4, n=0,+-1,+-2,.... c32() */
31/* computes both sin(y), cos(y). tan(x) is either sin(y)/cos(y) */
32/* or -cos(y)/sin(y). The precision of the result is of about 559 */
33/* significant bits. */
34/* */
35/**********************************************************************/
36#include "endian.h"
37#include "mpa.h"
38
31d3cc00
UD
39#ifndef SECTION
40# define SECTION
41#endif
42
31d3cc00
UD
43void
44SECTION
b8de2202
SP
45__mptan (double x, mp_no *mpy, int p)
46{
e4d82761
UD
47 int n;
48 mp_no mpw, mpc, mps;
49
b8de2202
SP
50 /* Negative or positive result. */
51 n = __mpranred (x, &mpw, p) & 0x00000001;
52 /* Computing sin(x) and cos(x). */
53 __c32 (&mpw, &mpc, &mps, p);
54 /* Second or fourth quarter of unit circle. */
55 if (n)
56 {
57 __dvd (&mpc, &mps, mpy, p);
c2d94018 58 mpy->d[0] *= -1;
b8de2202
SP
59 }
60 /* tan is negative in this area. */
61 else
62 __dvd (&mps, &mpc, mpy, p);
e4d82761 63}