]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/ieee754/dbl-64/mpatan2.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / ieee754 / dbl-64 / mpatan2.c
CommitLineData
e4d82761
UD
1/*
2 * IBM Accurate Mathematical Library
aeb25823 3 * written by International Business Machines Corp.
d614a753 4 * Copyright (C) 2001-2020 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
5a82c748 17 * along with this program; if not, see <https://www.gnu.org/licenses/>.
e4d82761
UD
18 */
19/******************************************************************/
20/* MODULE_NAME: mpatan2.c */
21/* */
22/* FUNCTIONS:mpatan2 */
23/* */
24/* FILES NEEDED: mpa.h */
25/* mpa.c mpatan.c mpsqrt.c */
26/* */
27/* Multi-Precision Atan2(y,x) function subroutine, */
28/* for precision p >= 4. */
29/* y=0 is not permitted if x<=0. No error messages are given. */
30/* The relative error of the result is bounded by 44.84*r**(1-p) */
31/* if x <= 0, y != 0 and by 37.33*r**(1-p) if x>0. here r=2**24. */
32/* */
33/******************************************************************/
34
e4d82761
UD
35#include "mpa.h"
36
31d3cc00
UD
37#ifndef SECTION
38# define SECTION
39#endif
40
a688864e
SP
41/* Multi-Precision Atan2 (y, x) function subroutine, for p >= 4.
42 y = 0 is not permitted if x <= 0. No error messages are given. */
31d3cc00
UD
43void
44SECTION
a688864e
SP
45__mpatan2 (mp_no *y, mp_no *x, mp_no *z, int p)
46{
47 mp_no mpt1, mpt2, mpt3;
e4d82761 48
a64d7e0e 49 if (X[0] <= 0)
a688864e
SP
50 {
51 __dvd (x, y, &mpt1, p);
52 __mul (&mpt1, &mpt1, &mpt2, p);
a64d7e0e 53 if (mpt1.d[0] != 0)
c2d94018 54 mpt1.d[0] = 1;
107a5bf0 55 __add (&mpt2, &__mpone, &mpt3, p);
a688864e
SP
56 __mpsqrt (&mpt3, &mpt2, p);
57 __add (&mpt1, &mpt2, &mpt3, p);
58 mpt3.d[0] = Y[0];
59 __mpatan (&mpt3, &mpt1, p);
60 __add (&mpt1, &mpt1, z, p);
61 }
e4d82761 62 else
a688864e
SP
63 {
64 __dvd (y, x, &mpt1, p);
65 __mpatan (&mpt1, z, p);
66 }
e4d82761 67}