intervals 0.3.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.txt +1 -0
- data/ext/crlibm/AUTHORS +2 -0
- data/ext/crlibm/COPYING +504 -0
- data/ext/crlibm/ChangeLog +80 -0
- data/ext/crlibm/INSTALL +182 -0
- data/ext/crlibm/Makefile.am +84 -0
- data/ext/crlibm/Makefile.in +530 -0
- data/ext/crlibm/NEWS +0 -0
- data/ext/crlibm/README +31 -0
- data/ext/crlibm/TODO +47 -0
- data/ext/crlibm/VERSION +1 -0
- data/ext/crlibm/aclocal.m4 +989 -0
- data/ext/crlibm/atan-itanium.c +846 -0
- data/ext/crlibm/atan-pentium.c +261 -0
- data/ext/crlibm/atan_accurate.c +244 -0
- data/ext/crlibm/atan_accurate.h +191 -0
- data/ext/crlibm/atan_fast.c +324 -0
- data/ext/crlibm/atan_fast.h +678 -0
- data/ext/crlibm/config.guess +1461 -0
- data/ext/crlibm/config.sub +1566 -0
- data/ext/crlibm/configure +7517 -0
- data/ext/crlibm/configure.ac +364 -0
- data/ext/crlibm/crlibm.h +125 -0
- data/ext/crlibm/crlibm_config.h +149 -0
- data/ext/crlibm/crlibm_config.h.in +148 -0
- data/ext/crlibm/crlibm_private.c +293 -0
- data/ext/crlibm/crlibm_private.h +658 -0
- data/ext/crlibm/csh_fast.c +631 -0
- data/ext/crlibm/csh_fast.h +771 -0
- data/ext/crlibm/double-extended.h +496 -0
- data/ext/crlibm/exp-td.c +962 -0
- data/ext/crlibm/exp-td.h +685 -0
- data/ext/crlibm/exp_accurate.c +197 -0
- data/ext/crlibm/exp_accurate.h +85 -0
- data/ext/crlibm/gappa/log-de-E0-logir0.gappa +106 -0
- data/ext/crlibm/gappa/log-de-E0.gappa +79 -0
- data/ext/crlibm/gappa/log-de.gappa +81 -0
- data/ext/crlibm/gappa/log-td-E0-logir0.gappa +126 -0
- data/ext/crlibm/gappa/log-td-E0.gappa +143 -0
- data/ext/crlibm/gappa/log-td-accurate-E0-logir0.gappa +230 -0
- data/ext/crlibm/gappa/log-td-accurate-E0.gappa +213 -0
- data/ext/crlibm/gappa/log-td-accurate.gappa +217 -0
- data/ext/crlibm/gappa/log-td.gappa +156 -0
- data/ext/crlibm/gappa/trigoSinCosCase3.gappa +204 -0
- data/ext/crlibm/gappa/trigoTanCase2.gappa +73 -0
- data/ext/crlibm/install-sh +269 -0
- data/ext/crlibm/log-de.c +431 -0
- data/ext/crlibm/log-de.h +732 -0
- data/ext/crlibm/log-td.c +852 -0
- data/ext/crlibm/log-td.h +819 -0
- data/ext/crlibm/log10-td.c +906 -0
- data/ext/crlibm/log10-td.h +823 -0
- data/ext/crlibm/log2-td.c +935 -0
- data/ext/crlibm/log2-td.h +821 -0
- data/ext/crlibm/maple/atan.mpl +359 -0
- data/ext/crlibm/maple/common-procedures.mpl +997 -0
- data/ext/crlibm/maple/csh.mpl +446 -0
- data/ext/crlibm/maple/double-extended.mpl +151 -0
- data/ext/crlibm/maple/exp-td.mpl +195 -0
- data/ext/crlibm/maple/log-de.mpl +243 -0
- data/ext/crlibm/maple/log-td.mpl +316 -0
- data/ext/crlibm/maple/log10-td.mpl +345 -0
- data/ext/crlibm/maple/log2-td.mpl +334 -0
- data/ext/crlibm/maple/trigo.mpl +728 -0
- data/ext/crlibm/maple/triple-double.mpl +58 -0
- data/ext/crlibm/missing +198 -0
- data/ext/crlibm/mkinstalldirs +40 -0
- data/ext/crlibm/rem_pio2_accurate.c +219 -0
- data/ext/crlibm/rem_pio2_accurate.h +53 -0
- data/ext/crlibm/scs_lib/AUTHORS +3 -0
- data/ext/crlibm/scs_lib/COPYING +504 -0
- data/ext/crlibm/scs_lib/ChangeLog +16 -0
- data/ext/crlibm/scs_lib/INSTALL +215 -0
- data/ext/crlibm/scs_lib/Makefile.am +18 -0
- data/ext/crlibm/scs_lib/Makefile.in +328 -0
- data/ext/crlibm/scs_lib/NEWS +0 -0
- data/ext/crlibm/scs_lib/README +9 -0
- data/ext/crlibm/scs_lib/TODO +4 -0
- data/ext/crlibm/scs_lib/addition_scs.c +623 -0
- data/ext/crlibm/scs_lib/config.guess +1461 -0
- data/ext/crlibm/scs_lib/config.sub +1566 -0
- data/ext/crlibm/scs_lib/configure +6226 -0
- data/ext/crlibm/scs_lib/division_scs.c +110 -0
- data/ext/crlibm/scs_lib/double2scs.c +174 -0
- data/ext/crlibm/scs_lib/install-sh +269 -0
- data/ext/crlibm/scs_lib/missing +198 -0
- data/ext/crlibm/scs_lib/mkinstalldirs +40 -0
- data/ext/crlibm/scs_lib/multiplication_scs.c +456 -0
- data/ext/crlibm/scs_lib/poly_fct.c +112 -0
- data/ext/crlibm/scs_lib/print_scs.c +73 -0
- data/ext/crlibm/scs_lib/rand_scs.c +63 -0
- data/ext/crlibm/scs_lib/scs.h +353 -0
- data/ext/crlibm/scs_lib/scs2double.c +391 -0
- data/ext/crlibm/scs_lib/scs2mpf.c +58 -0
- data/ext/crlibm/scs_lib/scs2mpfr.c +61 -0
- data/ext/crlibm/scs_lib/scs_private.c +23 -0
- data/ext/crlibm/scs_lib/scs_private.h +133 -0
- data/ext/crlibm/scs_lib/tests/tbx_timing.h +102 -0
- data/ext/crlibm/scs_lib/wrapper_scs.h +486 -0
- data/ext/crlibm/scs_lib/zero_scs.c +52 -0
- data/ext/crlibm/stamp-h.in +1 -0
- data/ext/crlibm/tests/Makefile.am +43 -0
- data/ext/crlibm/tests/Makefile.in +396 -0
- data/ext/crlibm/tests/blind_test.c +148 -0
- data/ext/crlibm/tests/generate_test_vectors.c +258 -0
- data/ext/crlibm/tests/soak_test.c +334 -0
- data/ext/crlibm/tests/test_common.c +627 -0
- data/ext/crlibm/tests/test_common.h +28 -0
- data/ext/crlibm/tests/test_perf.c +570 -0
- data/ext/crlibm/tests/test_val.c +249 -0
- data/ext/crlibm/trigo_accurate.c +500 -0
- data/ext/crlibm/trigo_accurate.h +331 -0
- data/ext/crlibm/trigo_fast.c +1219 -0
- data/ext/crlibm/trigo_fast.h +639 -0
- data/ext/crlibm/triple-double.h +878 -0
- data/ext/extconf.rb +31 -0
- data/ext/fpu.c +107 -0
- data/ext/jamis-mod.rb +591 -0
- data/lib/fpu.rb +287 -0
- data/lib/interval.rb +1170 -0
- data/lib/intervals.rb +212 -0
- data/lib/struct_float.rb +133 -0
- data/test/data_atan.txt +360 -0
- data/test/data_cos.txt +346 -0
- data/test/data_cosh.txt +3322 -0
- data/test/data_exp.txt +3322 -0
- data/test/data_log.txt +141 -0
- data/test/data_sin.txt +140 -0
- data/test/data_sinh.txt +3322 -0
- data/test/data_tan.txt +342 -0
- metadata +186 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
#ifndef TBX_TIMING_H
|
2
|
+
#define TBX_TIMING_H
|
3
|
+
|
4
|
+
#include <sys/types.h>
|
5
|
+
#include <sys/time.h>
|
6
|
+
#if defined(CRLIBM_TYPECPU_ITANIUM) && defined(__INTEL_COMPILER)
|
7
|
+
#include<ia64intrin.h>
|
8
|
+
#endif
|
9
|
+
|
10
|
+
/*
|
11
|
+
* For the user interested in High resolution timer, to my knowledge
|
12
|
+
* the best library is "RTAI", unfortunately it works only on Linux OS
|
13
|
+
*/
|
14
|
+
|
15
|
+
|
16
|
+
typedef union u_tbx_tick
|
17
|
+
{
|
18
|
+
unsigned long long tick;
|
19
|
+
|
20
|
+
struct
|
21
|
+
{
|
22
|
+
unsigned long low;
|
23
|
+
unsigned long high;
|
24
|
+
} sub;
|
25
|
+
|
26
|
+
struct timeval timev;
|
27
|
+
} tbx_tick_t, *p_tbx_tick_t;
|
28
|
+
|
29
|
+
|
30
|
+
#if defined(CRLIBM_TYPECPU_ITANIUM) && defined(__GNUC__) && !defined(__INTEL_COMPILER)
|
31
|
+
|
32
|
+
#define TBX_GET_TICK(t) \
|
33
|
+
__asm__ __volatile__("mov %0=ar.itc" : "=r"((t).tick) :: "memory")
|
34
|
+
#define TBX_TICK_RAW_DIFF(t1, t2) ((t2).tick - (t1).tick)
|
35
|
+
|
36
|
+
|
37
|
+
#elif defined(CRLIBM_TYPECPU_ITANIUM) && defined(__HPCC__)
|
38
|
+
/* Never tested, currently nobody defines __HPCC__.
|
39
|
+
It should work on HPUX machines using HP compiler */
|
40
|
+
#include<machine/sys/inline.h>/* to move up of course */
|
41
|
+
#define TBX_GET_TICK(t) \
|
42
|
+
t.tick=_Asm_mov_from_ar(_AREG_ITC)
|
43
|
+
#define TBX_TICK_RAW_DIFF(t1, t2) ((t2).tick - (t1).tick )
|
44
|
+
|
45
|
+
|
46
|
+
#elif defined(CRLIBM_TYPECPU_ITANIUM) && defined(__INTEL_COMPILER)
|
47
|
+
#define TBX_GET_TICK(t) t.tick=__getReg(_IA64_REG_AR_ITC)
|
48
|
+
#define TBX_TICK_RAW_DIFF(t1, t2) ((t2).tick - (t1).tick)
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
#elif (defined(CRLIBM_TYPECPU_AMD64) || defined(CRLIBM_TYPECPU_X86)) \
|
53
|
+
&& defined(__GNUC__) && !defined(__INTEL_COMPILER)
|
54
|
+
#define TBX_GET_TICK(time) \
|
55
|
+
__asm__ __volatile__( \
|
56
|
+
"xorl %%eax,%%eax\n\t" \
|
57
|
+
"cpuid\n\t" \
|
58
|
+
"rdtsc\n\t" \
|
59
|
+
"movl %%eax,(%0)\n\t" \
|
60
|
+
"movl %%edx,4(%0)\n\t" \
|
61
|
+
"xorl %%eax,%%eax\n\t" \
|
62
|
+
"cpuid\n\t" \
|
63
|
+
: /* no output */ \
|
64
|
+
: "S"(&time.tick) \
|
65
|
+
: "eax", "ebx", "ecx", "edx", "memory")
|
66
|
+
#define TBX_TICK_RAW_DIFF(t1, t2) ((t2).tick - (t1).tick)
|
67
|
+
|
68
|
+
|
69
|
+
#elif defined(CRLIBM_TYPECPU_ALPHA) && defined(__GNUC__)
|
70
|
+
#define TBX_GET_TICK(t) \
|
71
|
+
__asm__ volatile("rpcc %0\n\t" : "=r"((t).tick))
|
72
|
+
#define TBX_TICK_RAW_DIFF(t1, t2) \
|
73
|
+
(((t2).tick & 0xFFFFFFFF) - ((t1).tick & 0xFFFFFFFF))
|
74
|
+
|
75
|
+
|
76
|
+
#elif defined(CRLIBM_TYPECPU_SPARC) && defined(__GNUC__)
|
77
|
+
#define TBX_GET_TICK(t) \
|
78
|
+
(t).tick = gethrtime()
|
79
|
+
#define TBX_TICK_RAW_DIFF(t1, t2) \
|
80
|
+
((t2).tick - (t1).tick)
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
#else /* generic case */
|
85
|
+
|
86
|
+
#define TIMING_USES_GETTIMEOFDAY 1 /* inform the test functions that timings are inaccurate */
|
87
|
+
#define TBX_GET_TICK(t) \
|
88
|
+
gettimeofday(&(t).timev, 0)
|
89
|
+
#define TBX_TICK_RAW_DIFF(t1, t2) \
|
90
|
+
((t2.timev.tv_sec * 1000000L + t2.timev.tv_usec) - \
|
91
|
+
(t1.timev.tv_sec * 1000000L + t1.timev.tv_usec))
|
92
|
+
|
93
|
+
#endif
|
94
|
+
|
95
|
+
#define TBX_TICK_DIFF(t1, t2) (TBX_TICK_RAW_DIFF(t1, t2) - tbx_residual + 1)
|
96
|
+
#define TBX_TIMING_DELAY(t1, t2) tbx_tick2usec(TBX_TICK_DIFF(t1, t2))
|
97
|
+
|
98
|
+
extern unsigned long long tbx_residual;
|
99
|
+
extern tbx_tick_t tbx_new_event;
|
100
|
+
extern tbx_tick_t tbx_last_event;
|
101
|
+
|
102
|
+
#endif /* TBX_TIMING_H */
|
@@ -0,0 +1,486 @@
|
|
1
|
+
extern "C"
|
2
|
+
{
|
3
|
+
#include "scs.h"
|
4
|
+
}
|
5
|
+
#include <stdlib.h>
|
6
|
+
#include <stdio.h>
|
7
|
+
#include <math.h>
|
8
|
+
#include <iostream.h>
|
9
|
+
|
10
|
+
#ifndef SCS_WRAPPER_CPP
|
11
|
+
#define SCS_WRAPPER_CPP 1
|
12
|
+
|
13
|
+
extern "C" int scs_cmp_mant(scs_ptr , scs_ptr);
|
14
|
+
|
15
|
+
class Scs{
|
16
|
+
private:
|
17
|
+
scs scsnb;
|
18
|
+
|
19
|
+
public:
|
20
|
+
/* Constructors */
|
21
|
+
Scs(){}
|
22
|
+
Scs(double &d){scs_set_d(&scsnb, d);}
|
23
|
+
Scs(int &i){scs_set_si(&scsnb, i);}
|
24
|
+
Scs(const Scs& nb);
|
25
|
+
~Scs(){};
|
26
|
+
|
27
|
+
/* Mutators */
|
28
|
+
void scs_set_sign (int i) {this->scsnb.sign = i;}
|
29
|
+
void scs_set_index(int i) {this->scsnb.index = i;}
|
30
|
+
void scs_set_excep(double d) {this->scsnb.exception.d = d;}
|
31
|
+
void scs_set_words(unsigned int word[SCS_NB_WORDS]){for(int i=0; i<SCS_NB_WORDS; i++) this->scsnb.h_word[i] = word[i];}
|
32
|
+
|
33
|
+
/* Cast */
|
34
|
+
operator double();
|
35
|
+
operator int();
|
36
|
+
|
37
|
+
|
38
|
+
/* Negation */
|
39
|
+
Scs operator-() const;
|
40
|
+
friend Scs fabs(const Scs &a);
|
41
|
+
|
42
|
+
/* Assignment */
|
43
|
+
Scs &operator=(const Scs &nb1);
|
44
|
+
Scs &operator=(const double nb1);
|
45
|
+
Scs &operator=(const int i){scs_set_si(&scsnb, i);}
|
46
|
+
|
47
|
+
/* Addition */
|
48
|
+
friend Scs operator+(Scs &nb1,Scs &nb2);
|
49
|
+
friend Scs operator+(Scs &nb1, const double &nb2);
|
50
|
+
friend Scs operator+(const double &nb1,Scs &nb2);
|
51
|
+
void operator+=(Scs &nb);
|
52
|
+
void operator+=(const double nb);
|
53
|
+
|
54
|
+
/* Subtraction */
|
55
|
+
friend Scs operator-(Scs &nb1,Scs &nb2);
|
56
|
+
friend Scs operator-(Scs &nb1, const double &nb2);
|
57
|
+
friend Scs operator-(const double &nb1,Scs &nb2);
|
58
|
+
void operator-=(Scs &nb);
|
59
|
+
void operator-=(const double nb);
|
60
|
+
|
61
|
+
/* Multiplication */
|
62
|
+
friend Scs operator*(Scs &nb1,Scs &nb2);
|
63
|
+
friend Scs operator*(Scs &nb1, const double &nb2);
|
64
|
+
friend Scs operator*(const double &nb1,Scs &nb2);
|
65
|
+
friend Scs operator*(Scs &nb1, const int &nb2);
|
66
|
+
friend Scs operator*(const int &nb1,Scs &nb2);
|
67
|
+
void operator*=(Scs &nb);
|
68
|
+
void operator*=(const double nb);
|
69
|
+
void operator*=(const int nb);
|
70
|
+
|
71
|
+
/* Multiplication */
|
72
|
+
friend Scs operator/(Scs &nb1,Scs &nb2);
|
73
|
+
friend Scs operator/(Scs &nb1, const double &nb2);
|
74
|
+
friend Scs operator/(const double &nb1,Scs &nb2);
|
75
|
+
void operator/=(Scs &nb);
|
76
|
+
void operator/=(const double nb);
|
77
|
+
|
78
|
+
/* Comparisons */
|
79
|
+
friend bool operator==(Scs &nb1,Scs &nb2);
|
80
|
+
friend bool operator!=(Scs &nb1,Scs &nb2);
|
81
|
+
friend bool operator<=(Scs &nb1,Scs &nb2);
|
82
|
+
friend bool operator>=(Scs &nb1,Scs &nb2);
|
83
|
+
friend bool operator<(Scs &nb1,Scs &nb2);
|
84
|
+
friend bool operator>(Scs &nb1,Scs &nb2);
|
85
|
+
|
86
|
+
/* Random Number */
|
87
|
+
Scs rand(void);
|
88
|
+
|
89
|
+
/* Input/Output */
|
90
|
+
friend ostream& operator<<(ostream &s, const Scs &a);
|
91
|
+
friend istream& operator>>(istream &s, Scs &a);
|
92
|
+
|
93
|
+
};
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
/**************
|
99
|
+
* CONSTRUCTOR
|
100
|
+
**************/
|
101
|
+
Scs::Scs(const Scs& nb){
|
102
|
+
unsigned int i;
|
103
|
+
|
104
|
+
for(i=0; i<SCS_NB_WORDS; i++)
|
105
|
+
this->scsnb.h_word[i] = nb.scsnb.h_word[i];
|
106
|
+
|
107
|
+
this->scsnb.exception.d = nb.scsnb.exception.d;
|
108
|
+
this->scsnb.index = nb.scsnb.index;
|
109
|
+
this->scsnb.sign = nb.scsnb.sign;
|
110
|
+
}
|
111
|
+
|
112
|
+
/**************
|
113
|
+
* CAST
|
114
|
+
**************/
|
115
|
+
inline Scs::operator double() {
|
116
|
+
double d;
|
117
|
+
scs_get_d(&d, &(this->scsnb));
|
118
|
+
return d;
|
119
|
+
}
|
120
|
+
inline Scs::operator int() {
|
121
|
+
double d;
|
122
|
+
scs_get_d(&d, &(this->scsnb));
|
123
|
+
return ((int)d);
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
/**************
|
129
|
+
* ASSIGNATION
|
130
|
+
**************/
|
131
|
+
inline Scs &Scs::operator=(const Scs& nb){
|
132
|
+
unsigned int i;
|
133
|
+
|
134
|
+
for(i=0; i<SCS_NB_WORDS; i++)
|
135
|
+
scsnb.h_word[i] = nb.scsnb.h_word[i];
|
136
|
+
|
137
|
+
scsnb.exception.d = nb.scsnb.exception.d;
|
138
|
+
scsnb.index = nb.scsnb.index;
|
139
|
+
scsnb.sign = nb.scsnb.sign;
|
140
|
+
|
141
|
+
return *this;
|
142
|
+
}
|
143
|
+
inline Scs &Scs::operator=(const double nb){
|
144
|
+
scs_set_d(&(this->scsnb), nb);
|
145
|
+
return *this;
|
146
|
+
}
|
147
|
+
inline Scs fabs(const Scs &a){
|
148
|
+
Scs res(a);
|
149
|
+
res.scsnb.sign = 1;
|
150
|
+
return res;
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
/************
|
155
|
+
* ADDITION
|
156
|
+
************/
|
157
|
+
inline Scs operator+(Scs &nb1,Scs &nb2){
|
158
|
+
Scs res; scs_add(&(res.scsnb), &(nb1.scsnb), &(nb2.scsnb));
|
159
|
+
return res;
|
160
|
+
}
|
161
|
+
inline Scs operator+(Scs &nb1,const double &nb2){
|
162
|
+
Scs res, op;
|
163
|
+
scs_set_d(&(op.scsnb), nb2);
|
164
|
+
scs_add(&(res.scsnb), &(nb1.scsnb), &(op.scsnb));
|
165
|
+
return res;
|
166
|
+
}
|
167
|
+
inline Scs operator+(const double &nb1, Scs &nb2){
|
168
|
+
Scs res, op;
|
169
|
+
scs_set_d(&(op.scsnb), nb1);
|
170
|
+
scs_add(&(res.scsnb), &(nb2.scsnb), &(op.scsnb));
|
171
|
+
return res;
|
172
|
+
}
|
173
|
+
void inline Scs::operator+=(Scs &nb) {
|
174
|
+
scs_add(&(this->scsnb), &(this->scsnb), &(nb.scsnb));
|
175
|
+
}
|
176
|
+
void inline Scs::operator+=(const double nb) {
|
177
|
+
Scs op;
|
178
|
+
scs_set_d(&(op.scsnb), nb);
|
179
|
+
scs_add(&(this->scsnb), &(this->scsnb), &(op.scsnb));
|
180
|
+
}
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
/**************
|
186
|
+
* SUBTRACTION
|
187
|
+
**************/
|
188
|
+
inline Scs operator-(Scs &nb1,Scs &nb2){
|
189
|
+
Scs res; scs_sub(&(res.scsnb), &(nb1.scsnb), &(nb2.scsnb));
|
190
|
+
return res;
|
191
|
+
}
|
192
|
+
inline Scs operator-(Scs &nb1,const double &nb2){
|
193
|
+
Scs res, op;
|
194
|
+
scs_set_d(&(op.scsnb), nb2);
|
195
|
+
scs_sub(&(res.scsnb), &(nb1.scsnb), &(op.scsnb));
|
196
|
+
return res;
|
197
|
+
}
|
198
|
+
inline Scs operator-(const double &nb1, Scs &nb2){
|
199
|
+
Scs res, op;
|
200
|
+
scs_set_d(&(op.scsnb), nb1);
|
201
|
+
scs_sub(&(res.scsnb), &(nb2.scsnb), &(op.scsnb));
|
202
|
+
return res;
|
203
|
+
}
|
204
|
+
void inline Scs::operator-=(Scs &nb) {
|
205
|
+
scs_sub(&(this->scsnb), &(this->scsnb), &(nb.scsnb));
|
206
|
+
}
|
207
|
+
void inline Scs::operator-=(const double nb) {
|
208
|
+
Scs op;
|
209
|
+
scs_set_d(&(op.scsnb), nb);
|
210
|
+
scs_sub(&(this->scsnb), &(this->scsnb), &(op.scsnb));
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
/*****************
|
216
|
+
* MULTIPLICATION
|
217
|
+
*****************/
|
218
|
+
inline Scs operator*(Scs &nb1,Scs &nb2){
|
219
|
+
Scs res; scs_mul(&(res.scsnb), &(nb1.scsnb), &(nb2.scsnb));
|
220
|
+
return res;
|
221
|
+
}
|
222
|
+
inline Scs operator*(Scs &nb1,const double &nb2){
|
223
|
+
Scs res, op;
|
224
|
+
scs_set_d(&(op.scsnb), nb2);
|
225
|
+
scs_mul(&(res.scsnb), &(nb1.scsnb), &(op.scsnb));
|
226
|
+
return res;
|
227
|
+
}
|
228
|
+
inline Scs operator*(const double &nb1, Scs &nb2){
|
229
|
+
Scs res, op;
|
230
|
+
scs_set_d(&(op.scsnb), nb1);
|
231
|
+
scs_mul(&(res.scsnb), &(nb2.scsnb), &(op.scsnb));
|
232
|
+
return res;
|
233
|
+
}
|
234
|
+
inline Scs operator*(Scs &nb1, const int &nb2){
|
235
|
+
Scs res;
|
236
|
+
scs_set(&(res.scsnb), &(nb1.scsnb));
|
237
|
+
scs_mul_ui(&(res.scsnb), nb2);
|
238
|
+
return res;
|
239
|
+
}
|
240
|
+
inline Scs operator*(const int &nb1, Scs &nb2){
|
241
|
+
Scs res;
|
242
|
+
scs_set(&(res.scsnb), &(nb2.scsnb));
|
243
|
+
scs_mul_ui(&(res.scsnb), nb1);
|
244
|
+
return res;
|
245
|
+
}
|
246
|
+
void inline Scs::operator*=(Scs &nb) {
|
247
|
+
scs_mul(&(this->scsnb), &(this->scsnb), &(nb.scsnb));
|
248
|
+
}
|
249
|
+
void inline Scs::operator*=(const double nb) {
|
250
|
+
Scs op;
|
251
|
+
scs_set_d(&(op.scsnb), nb);
|
252
|
+
scs_mul(&(this->scsnb), &(this->scsnb), &(op.scsnb));
|
253
|
+
}
|
254
|
+
void inline Scs::operator*=(const int nb) {
|
255
|
+
scs_mul_ui(&(this->scsnb), nb);
|
256
|
+
}
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
/*****************
|
261
|
+
* DIVISION
|
262
|
+
*****************/
|
263
|
+
inline Scs operator/(Scs &nb1,Scs &nb2){
|
264
|
+
Scs res; scs_div(&(res.scsnb), &(nb1.scsnb), &(nb2.scsnb));
|
265
|
+
return res;
|
266
|
+
}
|
267
|
+
inline Scs operator/(Scs &nb1, const double &nb2){
|
268
|
+
Scs res, op;
|
269
|
+
scs_set_d(&(op.scsnb), nb2);
|
270
|
+
scs_div(&(res.scsnb), &(nb1.scsnb), &(op.scsnb));
|
271
|
+
return res;
|
272
|
+
}
|
273
|
+
inline Scs operator/(const double &nb1, Scs &nb2){
|
274
|
+
Scs res, op;
|
275
|
+
scs_set_d(&(op.scsnb), nb1);
|
276
|
+
scs_div(&(res.scsnb), &(nb2.scsnb), &(op.scsnb));
|
277
|
+
return res;
|
278
|
+
}
|
279
|
+
void inline Scs::operator/=(Scs &nb) {
|
280
|
+
scs_div(&(this->scsnb), &(this->scsnb), &(nb.scsnb));
|
281
|
+
}
|
282
|
+
void inline Scs::operator/=(const double nb) {
|
283
|
+
Scs op;
|
284
|
+
scs_set_d(&(op.scsnb), nb);
|
285
|
+
scs_div(&(this->scsnb), &(this->scsnb), &(op.scsnb));
|
286
|
+
}
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
/*************
|
291
|
+
* COMPARISON
|
292
|
+
*************/
|
293
|
+
inline bool operator==(Scs &nb1, Scs &nb2){
|
294
|
+
unsigned int i;
|
295
|
+
bool b=1;
|
296
|
+
|
297
|
+
for(i=0; i<SCS_NB_WORDS; i++)
|
298
|
+
if (nb1.scsnb.h_word[i] == nb2.scsnb.h_word[i]) b=0;
|
299
|
+
|
300
|
+
return ((nb1.scsnb.exception.d == nb2.scsnb.exception.d)&&
|
301
|
+
(nb1.scsnb.index == nb2.scsnb.index)&&
|
302
|
+
(nb1.scsnb.sign == nb2.scsnb.sign)&& b);
|
303
|
+
}
|
304
|
+
inline bool operator!=(Scs &nb1, Scs &nb2){
|
305
|
+
return !(nb1==nb2);
|
306
|
+
}
|
307
|
+
inline bool operator<=(Scs &nb1, Scs &nb2){
|
308
|
+
return ((nb1.scsnb.exception.d <= nb2.scsnb.exception.d)&&
|
309
|
+
(nb1.scsnb.sign <= nb2.scsnb.sign)&&
|
310
|
+
((nb1.scsnb.index < nb2.scsnb.index)||
|
311
|
+
((nb1.scsnb.index == nb2.scsnb.index)&&
|
312
|
+
(scs_cmp_mant(&(nb1.scsnb), &(nb2.scsnb))<=0))));
|
313
|
+
}
|
314
|
+
inline bool operator>=(Scs &nb1, Scs &nb2){
|
315
|
+
return ((nb1.scsnb.exception.d >= nb2.scsnb.exception.d)&&
|
316
|
+
(nb1.scsnb.sign >= nb2.scsnb.sign)&&
|
317
|
+
((nb1.scsnb.index > nb2.scsnb.index)||
|
318
|
+
((nb1.scsnb.index == nb2.scsnb.index)&&
|
319
|
+
(scs_cmp_mant(&(nb1.scsnb), &(nb2.scsnb))>=0))));
|
320
|
+
}
|
321
|
+
inline bool operator<(Scs &nb1, Scs &nb2){
|
322
|
+
return ((nb1.scsnb.exception.d <= nb2.scsnb.exception.d)&&
|
323
|
+
(nb1.scsnb.sign <= nb2.scsnb.sign)&&
|
324
|
+
((nb1.scsnb.index < nb2.scsnb.index)||
|
325
|
+
((nb1.scsnb.index == nb2.scsnb.index)&&
|
326
|
+
(scs_cmp_mant(&(nb1.scsnb), &(nb2.scsnb))<0))));
|
327
|
+
}
|
328
|
+
inline bool operator>(Scs &nb1, Scs &nb2){
|
329
|
+
return ((nb1.scsnb.exception.d >= nb2.scsnb.exception.d)&&
|
330
|
+
(nb1.scsnb.sign >= nb2.scsnb.sign)&&
|
331
|
+
((nb1.scsnb.index > nb2.scsnb.index)||
|
332
|
+
((nb1.scsnb.index == nb2.scsnb.index)&&
|
333
|
+
(scs_cmp_mant(&(nb1.scsnb), &(nb2.scsnb))>0))));
|
334
|
+
}
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
/****************
|
340
|
+
* RANDOM NUMBER
|
341
|
+
****************/
|
342
|
+
inline Scs Scs::rand(void){
|
343
|
+
scs_rand(&(this->scsnb), 200);
|
344
|
+
return *this;
|
345
|
+
}
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
/***************
|
351
|
+
* OUTPUT (in hexadecimal)
|
352
|
+
***************/
|
353
|
+
ostream &operator<<(ostream &os, const Scs &a){
|
354
|
+
Scs aa, p, zer;
|
355
|
+
double d;
|
356
|
+
char buffer[10];
|
357
|
+
int e, exposant;
|
358
|
+
bool bb;
|
359
|
+
|
360
|
+
if (a.scsnb.exception.d != 1.){
|
361
|
+
os << (double)a.scsnb.exception.d;
|
362
|
+
}else {
|
363
|
+
if (a.scsnb.sign == -1)
|
364
|
+
os << '-';
|
365
|
+
|
366
|
+
aa = fabs(a);
|
367
|
+
|
368
|
+
/* Compute the exposant in radix 16 */
|
369
|
+
d = ((a.scsnb.index)*SCS_NB_BITS)/4;
|
370
|
+
e = 4*(int)floor(d);
|
371
|
+
|
372
|
+
p = 1;
|
373
|
+
p.scsnb.index = (int)floor(((double)e)/SCS_NB_BITS);
|
374
|
+
p.scsnb.h_word[0] = 1 << e - p.scsnb.index*SCS_NB_BITS;
|
375
|
+
exposant = (int)floor(d);
|
376
|
+
p /= 16;
|
377
|
+
exposant--;
|
378
|
+
while(p <= aa){
|
379
|
+
p *= 16;
|
380
|
+
exposant++;
|
381
|
+
}
|
382
|
+
p /= 16;
|
383
|
+
exposant--;
|
384
|
+
|
385
|
+
/* Extract digits */
|
386
|
+
aa = aa / p;
|
387
|
+
sprintf(buffer,"%x", aa.scsnb.h_word[0]);
|
388
|
+
os << buffer << ".";
|
389
|
+
aa.scsnb.h_word[0] = 0;
|
390
|
+
aa *= 16;
|
391
|
+
|
392
|
+
bb = 1;
|
393
|
+
while(bb){
|
394
|
+
sprintf(buffer,"%x", aa.scsnb.h_word[0]);
|
395
|
+
os << buffer;
|
396
|
+
aa.scsnb.h_word[0] = 0;
|
397
|
+
aa *= 16;
|
398
|
+
|
399
|
+
bb = 0;
|
400
|
+
for(int i=0; i<SCS_NB_WORDS; i++)
|
401
|
+
if (aa.scsnb.h_word[i] != 0) bb=1;
|
402
|
+
}
|
403
|
+
|
404
|
+
/* Write the exponent */
|
405
|
+
os << " x16^(" << exposant <<")";
|
406
|
+
}
|
407
|
+
|
408
|
+
return os;
|
409
|
+
}
|
410
|
+
|
411
|
+
|
412
|
+
/***************
|
413
|
+
* INPUT (in decimal)
|
414
|
+
***************/
|
415
|
+
istream& operator>>(istream &is, Scs &a){
|
416
|
+
char c;
|
417
|
+
int nd = 0;
|
418
|
+
int point = -1;
|
419
|
+
int ex;
|
420
|
+
bool done = false;
|
421
|
+
Scs r;
|
422
|
+
|
423
|
+
r = 0;
|
424
|
+
|
425
|
+
/* Skip any leading spaces */
|
426
|
+
do{
|
427
|
+
is>>c;
|
428
|
+
}while (c == ' ');
|
429
|
+
|
430
|
+
/* Read sign, digits, and exponent */
|
431
|
+
while (!done && (c != '\0')) {
|
432
|
+
if (c >= '0' && c <= '9') {
|
433
|
+
int d = c - '0';
|
434
|
+
r *= 10.0;
|
435
|
+
r += d;
|
436
|
+
nd++;
|
437
|
+
} else {
|
438
|
+
switch (c) {
|
439
|
+
case '.':
|
440
|
+
point = nd;
|
441
|
+
break;
|
442
|
+
case '-':
|
443
|
+
case '+':
|
444
|
+
if (nd > 0){
|
445
|
+
a = 0;
|
446
|
+
done = true;
|
447
|
+
point = -1;
|
448
|
+
ex = 0;
|
449
|
+
}
|
450
|
+
a.scsnb.sign = (c == '-') ? -1 : 1;
|
451
|
+
break;
|
452
|
+
case 'E':
|
453
|
+
case 'e':
|
454
|
+
is >> ex;
|
455
|
+
done = true;
|
456
|
+
break;
|
457
|
+
default:
|
458
|
+
a = 0;
|
459
|
+
done = true;
|
460
|
+
point = -1;
|
461
|
+
ex = 0;
|
462
|
+
}
|
463
|
+
}
|
464
|
+
is>>c;
|
465
|
+
}
|
466
|
+
|
467
|
+
if (point >= 0)
|
468
|
+
ex -= (nd - point);
|
469
|
+
|
470
|
+
|
471
|
+
if (ex != 0) {
|
472
|
+
if (ex > 0)
|
473
|
+
for(int i=0; i<ex; i++)
|
474
|
+
r *= 10;
|
475
|
+
if (ex < 0){
|
476
|
+
Scs inv_ten, ten;
|
477
|
+
ten = 10;
|
478
|
+
scs_inv(&(inv_ten.scsnb), &(ten.scsnb) );
|
479
|
+
for(int i=0; i>ex; i--)
|
480
|
+
r *= inv_ten;
|
481
|
+
}
|
482
|
+
}
|
483
|
+
}
|
484
|
+
#endif
|
485
|
+
|
486
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/** Function for setting an SCS number to zero
|
2
|
+
@file zero_scs.c
|
3
|
+
|
4
|
+
@author Defour David David.Defour@ens-lyon.fr
|
5
|
+
@author Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr
|
6
|
+
|
7
|
+
This file is part of the SCS library.
|
8
|
+
*/
|
9
|
+
|
10
|
+
/*
|
11
|
+
Copyright (C) 2002 David Defour and Florent de Dinechin
|
12
|
+
|
13
|
+
This library is free software; you can redistribute it and/or
|
14
|
+
modify it under the terms of the GNU Lesser General Public
|
15
|
+
License as published by the Free Software Foundation; either
|
16
|
+
version 2.1 of the License, or (at your option) any later version.
|
17
|
+
|
18
|
+
This library is distributed in the hope that it will be useful,
|
19
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
21
|
+
Lesser General Public License for more details.
|
22
|
+
|
23
|
+
You should have received a copy of the GNU Lesser General Public
|
24
|
+
License along with this library; if not, write to the Free Software
|
25
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
26
|
+
|
27
|
+
*/
|
28
|
+
|
29
|
+
|
30
|
+
#include "scs.h"
|
31
|
+
#include "scs_private.h"
|
32
|
+
|
33
|
+
|
34
|
+
/** Set a SCS number to zero.
|
35
|
+
There should be a few simple functions in this library.
|
36
|
+
*/
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
void inline scs_zero(scs_ptr result) {
|
41
|
+
int i;
|
42
|
+
|
43
|
+
for(i=0; i<SCS_NB_WORDS; i++)
|
44
|
+
R_HW[i] = 0;
|
45
|
+
|
46
|
+
R_EXP = 0;
|
47
|
+
R_IND = 0;
|
48
|
+
R_SGN = 1;
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
timestamp
|
@@ -0,0 +1,43 @@
|
|
1
|
+
## Process this file with automake to produce Makefile.in
|
2
|
+
|
3
|
+
bin_PROGRAMS = crlibm_testval crlibm_soaktest crlibm_testperf crlibm_blindtest crlibm_generate_test_vectors
|
4
|
+
|
5
|
+
LDADD= $(top_builddir)/libcrlibm.a
|
6
|
+
INCLUDES=-I$(top_srcdir)
|
7
|
+
AM_CFLAGS = -g -O0 -std=c99
|
8
|
+
../libcrlibm.a:
|
9
|
+
cd $(top_srcdir); make libcrlibm.a
|
10
|
+
|
11
|
+
crlibm_testval_SOURCES = test_val.c test_common.c test_common.h
|
12
|
+
crlibm_soaktest_SOURCES = soak_test.c test_common.c test_common.h
|
13
|
+
crlibm_testperf_SOURCES = test_perf.c test_common.c test_common.h
|
14
|
+
crlibm_blindtest_SOURCES = blind_test.c test_common.c test_common.h
|
15
|
+
crlibm_generate_test_vectors_SOURCES = generate_test_vectors.c test_common.c test_common.h
|
16
|
+
|
17
|
+
check_exp: crlibm_blindtest
|
18
|
+
echo ./crlibm_blindtest exp.testdata>check_exp; chmod a+rx check_exp
|
19
|
+
check_log: crlibm_blindtest
|
20
|
+
echo ./crlibm_blindtest log.testdata>check_log; chmod a+rx check_log
|
21
|
+
check_log2: crlibm_blindtest
|
22
|
+
echo ./crlibm_blindtest log2.testdata>check_log2; chmod a+rx check_log2
|
23
|
+
check_log10: crlibm_blindtest
|
24
|
+
echo ./crlibm_blindtest log10.testdata>check_log10; chmod a+rx check_log10
|
25
|
+
check_sin: crlibm_blindtest
|
26
|
+
echo ./crlibm_blindtest sin.testdata>check_sin; chmod a+rx check_sin
|
27
|
+
check_cos: crlibm_blindtest
|
28
|
+
echo ./crlibm_blindtest cos.testdata>check_cos; chmod a+rx check_cos
|
29
|
+
check_tan: crlibm_blindtest
|
30
|
+
echo ./crlibm_blindtest tan.testdata>check_tan; chmod a+rx check_tan
|
31
|
+
check_atan: crlibm_blindtest
|
32
|
+
echo ./crlibm_blindtest atan.testdata>check_atan; chmod a+rx check_atan
|
33
|
+
check_sinh: crlibm_blindtest
|
34
|
+
echo ./crlibm_blindtest sinh.testdata>check_sinh; chmod a+rx check_sinh
|
35
|
+
check_cosh: crlibm_blindtest
|
36
|
+
echo ./crlibm_blindtest cosh.testdata>check_cosh; chmod a+rx check_cosh
|
37
|
+
|
38
|
+
CRLIBM_CHECKLIST = check_exp check_log check_log2 check_log10 check_sin check_cos check_tan check_atan check_sinh check_cosh
|
39
|
+
TESTS = $(CRLIBM_CHECKLIST)
|
40
|
+
|
41
|
+
EXTRA_DIST = exp.testdata log.testdata log2.testdata log10.testdata sin.testdata cos.testdata tan.testdata atan.testdata sinh.testdata cosh.testdata
|
42
|
+
|
43
|
+
CLEANFILES = $(CRLIBM_CHECKLIST)
|