00001
00003 #ifndef _CONFIG_H
00004 #define _CONFIG_H
00005
00006 #include <iostream>
00007 #include <assert.h>
00008
00009 #include <inttypes.h>
00010 #include <vector>
00011 #include <cmath>
00012 #include "defs.h"
00013
00017 namespace mp {
00018
00019 #ifdef GXX
00020 #define MIN(x, y) ((x) <? (y))
00021 #define MAX(x, y) ((x) >? (y))
00022 #else
00023 #define MIN(x, y) ((x) < (y) ? (x) : (y))
00024 #define MAX(x, y) ((x) > (y) ? (x) : (y))
00025 #endif
00026
00027 #define INVERT(x, y) (((y) - ((x) % (y))) % (y))
00028
00029 #define BITS_TO_LIMBS(x) ((mp::size_type) std::ceil((double) (x) / \
00030 mp::mpn_::limb_size_bits))
00031 #define LIMBS_TO_BITS(x) ((x) * mp::mpn_::limb_size_bits)
00032
00033 enum capability {
00034 IS_SIGNED = 0x01,
00035 IS_RATIONAL = 0x02,
00036 IS_FLOAT = 0x04,
00037
00038 CAN_INTERRUPT = 0x10,
00039 };
00040
00041 typedef unsigned char byte;
00042
00043
00044
00045
00046
00047 class mpn_;
00048
00050 typedef std::vector<byte> raw_type;
00051
00053 typedef unsigned char radix_type;
00054
00056 typedef intptr_t size_type;
00057
00058 #if _MP_SIZE == 16
00059 typedef uint8_t limb_type;
00060 typedef uint16_t limb_long_type;
00061 #elif _MP_SIZE == 32
00062 typedef uint16_t limb_type;
00063 typedef uint32_t limb_long_type;
00064 #elif _MP_SIZE == 64
00065 typedef uint32_t limb_type;
00066 typedef uint64_t limb_long_type;
00067 #endif
00068
00069
00070
00071
00072
00073 class mpi_;
00074 class mpi;
00075
00077 typedef signed int int_type;
00078
00079
00080
00081
00082
00083 class mpf_;
00084 class mpf;
00085
00087 #ifdef WORDS_BIGENDIAN
00088 union ieee_double_extract {
00089 struct {
00090 unsigned int sign:1;
00091 unsigned int exp:11;
00092 unsigned int manh:20;
00093 unsigned int manl:32;
00094 } s;
00095 double d;
00096 };
00097 #else
00098 union ieee_double_extract {
00099 struct {
00100 unsigned int manl:32;
00101 unsigned int manh:20;
00102 unsigned int exp:11;
00103 unsigned int sign:1;
00104 } s;
00105 double d;
00106 };
00107 #endif
00108
00110 typedef double float_type;
00111
00112 }
00113
00114 #endif