]>
Commit | Line | Data |
---|---|---|
e4d82761 UD |
1 | /* |
2 | * IBM Accurate Mathematical Library | |
c6c6dd48 | 3 | * Written by International Business Machines Corp. |
568035b7 | 4 | * Copyright (C) 2001-2013 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 | |
59ba27a6 | 17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
e4d82761 | 18 | */ |
c6c6dd48 | 19 | |
e4d82761 UD |
20 | /************************************************************************/ |
21 | /* MODULE_NAME: mpa.h */ | |
22 | /* */ | |
23 | /* FUNCTIONS: */ | |
24 | /* mcr */ | |
25 | /* acr */ | |
26 | /* cr */ | |
27 | /* cpy */ | |
28 | /* cpymn */ | |
29 | /* mp_dbl */ | |
30 | /* dbl_mp */ | |
31 | /* add */ | |
32 | /* sub */ | |
33 | /* mul */ | |
34 | /* inv */ | |
35 | /* dvd */ | |
36 | /* */ | |
37 | /* Arithmetic functions for multiple precision numbers. */ | |
38 | /* Common types and definition */ | |
39 | /************************************************************************/ | |
40 | ||
41 | ||
42 | typedef struct {/* This structure holds the details of a multi-precision */ | |
43 | int e; /* floating point number, x: d[0] holds its sign (-1,0 or 1) */ | |
44 | double d[40]; /* e holds its exponent (...,-2,-1,0,1,2,...) and */ | |
45 | } mp_no; /* d[1]...d[p] hold its mantissa digits. The value of x is, */ | |
af968f62 UD |
46 | /* x = d[1]*r**(e-1) + d[2]*r**(e-2) + ... + d[p]*r**(e-p). */ |
47 | /* Here r = 2**24, 0 <= d[i] < r and 1 <= p <= 32. */ | |
48 | /* p is a global variable. A multi-precision number is */ | |
49 | /* always normalized. Namely, d[1] > 0. An exception is */ | |
50 | /* a zero which is characterized by d[0] = 0. The terms */ | |
51 | /* d[p+1], d[p+2], ... of a none zero number have no */ | |
52 | /* significance and so are the terms e, d[1],d[2],... */ | |
53 | /* of a zero. */ | |
e4d82761 UD |
54 | |
55 | typedef union { int i[2]; double d; } number; | |
56 | ||
b76eb5f0 | 57 | extern const mp_no mpone; |
da08f647 | 58 | extern const mp_no mptwo; |
b76eb5f0 | 59 | |
e4d82761 UD |
60 | #define X x->d |
61 | #define Y y->d | |
62 | #define Z z->d | |
63 | #define EX x->e | |
64 | #define EY y->e | |
65 | #define EZ z->e | |
66 | ||
e4d82761 UD |
67 | #define ABS(x) ((x) < 0 ? -(x) : (x)) |
68 | ||
31d3cc00 | 69 | int __acr(const mp_no *, const mp_no *, int); |
af968f62 | 70 | // int __cr(const mp_no *, const mp_no *, int); |
ca58f1db | 71 | void __cpy(const mp_no *, mp_no *, int); |
af968f62 | 72 | // void __cpymn(const mp_no *, int, mp_no *, int); |
50944bca | 73 | void __mp_dbl(const mp_no *, double *, int); |
ca58f1db UD |
74 | void __dbl_mp(double, mp_no *, int); |
75 | void __add(const mp_no *, const mp_no *, mp_no *, int); | |
76 | void __sub(const mp_no *, const mp_no *, mp_no *, int); | |
77 | void __mul(const mp_no *, const mp_no *, mp_no *, int); | |
af968f62 | 78 | // void __inv(const mp_no *, mp_no *, int); |
ca58f1db | 79 | void __dvd(const mp_no *, const mp_no *, mp_no *, int); |
1d052247 AJ |
80 | |
81 | extern void __mpatan (mp_no *, mp_no *, int); | |
82 | extern void __mpatan2 (mp_no *, mp_no *, mp_no *, int); | |
83 | extern void __mpsqrt (mp_no *, mp_no *, int); | |
302913e1 | 84 | extern void __mpexp (mp_no *, mp_no *, int); |
1d052247 AJ |
85 | extern void __c32 (mp_no *, mp_no *, mp_no *, int); |
86 | extern int __mpranred (double, mp_no *, int); |