glibc
2.9

00001 00002 /* 00003 * IBM Accurate Mathematical Library 00004 * written by International Business Machines Corp. 00005 * Copyright (C) 2001 Free Software Foundation 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU Lesser General Public License as published by 00009 * the Free Software Foundation; either version 2.1 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place  Suite 330, Boston, MA 021111307, USA. 00020 */ 00021 /******************************************************************/ 00022 /* MODULE_NAME: mpatan2.c */ 00023 /* */ 00024 /* FUNCTIONS:mpatan2 */ 00025 /* */ 00026 /* FILES NEEDED: mpa.h */ 00027 /* mpa.c mpatan.c mpsqrt.c */ 00028 /* */ 00029 /* MultiPrecision Atan2(y,x) function subroutine, */ 00030 /* for precision p >= 4. */ 00031 /* y=0 is not permitted if x<=0. No error messages are given. */ 00032 /* The relative error of the result is bounded by 44.84*r**(1p) */ 00033 /* if x <= 0, y != 0 and by 37.33*r**(1p) if x>0. here r=2**24. */ 00034 /* */ 00035 /******************************************************************/ 00036 00037 00038 00039 #include "mpa.h" 00040 00041 void __mpsqrt(mp_no *, mp_no *, int); 00042 void __mpatan(mp_no *, mp_no *, int); 00043 00044 /* MultiPrecision Atan2(y,x) function subroutine, for p >= 4. */ 00045 /* y=0 is not permitted if x<=0. No error messages are given. */ 00046 void __mpatan2(mp_no *y, mp_no *x, mp_no *z, int p) { 00047 00048 static const double ZERO = 0.0, ONE = 1.0; 00049 00050 mp_no mpone = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, 00051 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, 00052 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}}; 00053 mp_no mpt1,mpt2,mpt3; 00054 00055 00056 if (X[0] <= ZERO) { 00057 mpone.e = 1; mpone.d[0] = mpone.d[1] = ONE; 00058 __dvd(x,y,&mpt1,p); __mul(&mpt1,&mpt1,&mpt2,p); 00059 if (mpt1.d[0] != ZERO) mpt1.d[0] = ONE; 00060 __add(&mpt2,&mpone,&mpt3,p); __mpsqrt(&mpt3,&mpt2,p); 00061 __add(&mpt1,&mpt2,&mpt3,p); mpt3.d[0]=Y[0]; 00062 __mpatan(&mpt3,&mpt1,p); __add(&mpt1,&mpt1,z,p); 00063 } 00064 else 00065 { __dvd(y,x,&mpt1,p); 00066 __mpatan(&mpt1,z,p); 00067 } 00068 00069 return; 00070 }