2 * IBM Accurate Mathematical Library
3 * written by International Business Machines Corp.
4 * Copyright (C) 2001-2016 Free Software Foundation, Inc.
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
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
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
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 /******************************************************************/
20 /* MODULE_NAME: mpatan2.c */
22 /* FUNCTIONS:mpatan2 */
24 /* FILES NEEDED: mpa.h */
25 /* mpa.c mpatan.c mpsqrt.c */
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. */
33 /******************************************************************/
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. */
45 __mpatan2 (mp_no
*y
, mp_no
*x
, mp_no
*z
, int p
)
47 mp_no mpt1
, mpt2
, mpt3
;
51 __dvd (x
, y
, &mpt1
, p
);
52 __mul (&mpt1
, &mpt1
, &mpt2
, p
);
55 __add (&mpt2
, &__mpone
, &mpt3
, p
);
56 __mpsqrt (&mpt3
, &mpt2
, p
);
57 __add (&mpt1
, &mpt2
, &mpt3
, p
);
59 __mpatan (&mpt3
, &mpt1
, p
);
60 __add (&mpt1
, &mpt1
, z
, p
);
64 __dvd (y
, x
, &mpt1
, p
);
65 __mpatan (&mpt1
, z
, p
);