/* * IBM Accurate Mathematical Library * written by International Business Machines Corp. * Copyright (C) 2001 Free Software Foundation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /*********************************************************************/ /* MODULE_NAME: utan.c */ /* */ /* FUNCTIONS: utan */ /* tanMp */ /* */ /* FILES NEEDED:dla.h endian.h mpa.h mydefs.h utan.h */ /* branred.c sincos32.c mptan.c */ /* utan.tbl */ /* */ /* An ultimate tan routine. Given an IEEE double machine number x */ /* it computes the correctly rounded (to nearest) value of tan(x). */ /* Assumption: Machine arithmetic operations are performed in */ /* round to nearest mode of IEEE 754 standard. */ /* */ /*********************************************************************/ #include "endian.h" #include "dla.h" #include "mpa.h" #include "MathLib.h" #include "math.h" static double tanMp(double); void __mptan(double, mp_no *, int); double tan(double x) { #include "utan.h" #include "utan.tbl" int ux,i,n; double a,da,a2,b,db,c,dc,c1,cc1,c2,cc2,c3,cc3,fi,ffi,gi,pz,s,sy, t,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,w,x2,xn,xx2,y,ya,yya,z0,z,zz,z2,zz2; int p; number num,v; mp_no mpa,mpt1,mpt2; #if 0 mp_no mpy; #endif int __branred(double, double *, double *); int __mpranred(double, mp_no *, int); /* x=+-INF, x=NaN */ num.d = x; ux = num.i[HIGH_HALF]; if ((ux&0x7ff00000)==0x7ff00000) return x-x; w=(x