Back to index

glibc  2.9
mpa.h
Go to the documentation of this file.
00001 
00002 /*
00003  * IBM Accurate Mathematical Library
00004  * Written by International Business Machines Corp.
00005  * Copyright (C) 2001 Free Software Foundation, Inc.
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 02111-1307, USA.
00020  */
00021 
00022 /************************************************************************/
00023 /*  MODULE_NAME: mpa.h                                                  */
00024 /*                                                                      */
00025 /*  FUNCTIONS:                                                          */
00026 /*               mcr                                                    */
00027 /*               acr                                                    */
00028 /*               cr                                                     */
00029 /*               cpy                                                    */
00030 /*               cpymn                                                  */
00031 /*               mp_dbl                                                 */
00032 /*               dbl_mp                                                 */
00033 /*               add                                                    */
00034 /*               sub                                                    */
00035 /*               mul                                                    */
00036 /*               inv                                                    */
00037 /*               dvd                                                    */
00038 /*                                                                      */
00039 /* Arithmetic functions for multiple precision numbers.                 */
00040 /* Common types and definition                                          */
00041 /************************************************************************/
00042 
00043 
00044 typedef struct {/* This structure holds the details of a multi-precision     */
00045   int e;        /* floating point number, x: d[0] holds its sign (-1,0 or 1) */
00046   double d[40]; /* e holds its exponent (...,-2,-1,0,1,2,...) and            */
00047 } mp_no;        /* d[1]...d[p] hold its mantissa digits. The value of x is,  */
00048                 /* x = d[1]*r**(e-1) + d[2]*r**(e-2) + ... + d[p]*r**(e-p).  */
00049                 /* Here   r = 2**24,   0 <= d[i] < r  and  1 <= p <= 32.     */
00050                 /* p is a global variable. A multi-precision number is       */
00051                 /* always normalized. Namely, d[1] > 0. An exception is      */
00052                 /* a zero which is characterized by d[0] = 0. The terms      */
00053                 /* d[p+1], d[p+2], ... of a none zero number have no         */
00054                 /* significance and so are the terms e, d[1],d[2],...        */
00055                 /* of a zero.                                                */
00056 
00057 typedef union { int i[2]; double d; } number;
00058 
00059 #define  X   x->d
00060 #define  Y   y->d
00061 #define  Z   z->d
00062 #define  EX  x->e
00063 #define  EY  y->e
00064 #define  EZ  z->e
00065 
00066 #define ABS(x)   ((x) <  0  ? -(x) : (x))
00067 
00068 int __acr(const mp_no *, const mp_no *, int);
00069 int  __cr(const mp_no *, const mp_no *, int);
00070 void __cpy(const mp_no *, mp_no *, int);
00071 void __cpymn(const mp_no *, int, mp_no *, int);
00072 void __mp_dbl(const mp_no *, double *, int);
00073 void __dbl_mp(double, mp_no *, int);
00074 void __add(const mp_no *, const mp_no *, mp_no *, int);
00075 void __sub(const mp_no *, const mp_no *, mp_no *, int);
00076 void __mul(const mp_no *, const mp_no *, mp_no *, int);
00077 void __inv(const mp_no *, mp_no *, int);
00078 void __dvd(const mp_no *, const mp_no *, mp_no *, int);
00079 
00080 extern void __mpatan (mp_no *, mp_no *, int);
00081 extern void __mpatan2 (mp_no *, mp_no *, mp_no *, int);
00082 extern void __mpsqrt (mp_no *, mp_no *, int);
00083 extern void __mpexp (mp_no *, mp_no *__y, int);
00084 extern void __c32 (mp_no *, mp_no *, mp_no *, int);
00085 extern int __mpranred (double, mp_no *, int);