gmp 0.4.1-x86-mingw32 → 0.4.3-x86-mingw32
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/CHANGELOG +14 -0
- data/README.rdoc +49 -17
- data/benchmark/runbench.rb +165 -165
- data/ext/gmp.c +63 -30
- data/ext/gmp.so +0 -0
- data/ext/gmpf.c +207 -3
- data/ext/gmpf.h +0 -132
- data/ext/gmprandstate.c +56 -2
- data/ext/libmpfr-1.dll +0 -0
- data/ext/ruby_gmp.h +39 -0
- data/manual.pdf +0 -0
- data/manual.tex +67 -7
- data/test/mpfr_tsqrt.rb +53 -0
- data/test/tc_f_precision.rb +99 -34
- data/test/tc_mpfr_functions.rb +45 -0
- data/test/tc_mpfr_random.rb +49 -0
- data/test/test_helper.rb +1 -0
- data/test/unit_tests.rb +9 -14
- metadata +8 -3
data/CHANGELOG
CHANGED
@@ -1,6 +1,20 @@
|
|
1
|
+
0.4.3:
|
2
|
+
* Support for MPFR on Windows introduced. gmp-x86-mswin32 gem should be used.
|
3
|
+
* Removed compilation warnings when using MPFR
|
4
|
+
* Added constants GMP::GMP_CC, GMP::GMP_CFLAGS, and GMP::GMP_BITS_PER_LIMB.
|
5
|
+
* Added constant GMP::MPFR_VERSION.
|
6
|
+
* Added MPFR rounding constants. These will be changed soon though.
|
7
|
+
* Added MPFR tests adapted straight from the MPFR library, just tsqrt so far.
|
8
|
+
* Added 3x MPFR functions: sec(), csc(), cot().
|
9
|
+
* Added function existence tests from
|
10
|
+
* Unit test results: 78 tests, 1025 assertions, 0 failures, 0 errors
|
11
|
+
* Unit test results: 72 tests, 593 assertions, 0 failures, 0 errors (w/o MPFR)
|
12
|
+
|
1
13
|
0.4.1:
|
2
14
|
* Fixed some gem dates
|
15
|
+
* Fixed gmp.so in x86-mswin32 gem
|
3
16
|
* Added urandomm(), documentation, and tests.
|
17
|
+
* Unit test results: 70 tests, 577 assertions, 0 failures, 0 errors
|
4
18
|
|
5
19
|
0.4.0:
|
6
20
|
* Support for Windows introduced. gmp-x86-mswin32 gem should be used.
|
data/README.rdoc
CHANGED
@@ -63,7 +63,8 @@ by me: gmp gem 0.4.0 on:
|
|
63
63
|
| | (MRI) Ruby 1.9.1 | |
|
64
64
|
+-------------------------------------+-------------------+-----------+
|
65
65
|
|
66
|
-
<b>Note:</b> To get this running on Mac OS X (32-bit), I compiled GMP 4.3.1
|
66
|
+
<b>Note:</b> To get this running on Mac OS X (32-bit), I compiled GMP 4.3.1
|
67
|
+
with:
|
67
68
|
./configure ABI=32 --disable-dependency-tracking
|
68
69
|
|
69
70
|
=Authors
|
@@ -71,9 +72,25 @@ by me: gmp gem 0.4.0 on:
|
|
71
72
|
* Tomasz Wegrzanowski
|
72
73
|
* srawlins
|
73
74
|
|
75
|
+
=Constants
|
76
|
+
|
77
|
+
The GMP module includes the following constants. Mathematical constants, such
|
78
|
+
as pi, are defined under class methods of GMP::F, listed below.
|
79
|
+
|
80
|
+
GMP::GMP_VERSION #=> A string like "5.0.1"
|
81
|
+
GMP::GMP_CC #=> The compiler used to compile GMP
|
82
|
+
GMP::GMP_CFLAGS #=> The CFLAGS used to compile GMP
|
83
|
+
GMP::GMP_BITS_PER_LIMB #=> The number of bits per limb
|
84
|
+
(if MPFR is available)
|
85
|
+
GMP::MPFR_VERSION #=> A string like "2.4.2"
|
86
|
+
GMP::GMP_RNDN #=> The constant representing "round to nearest"
|
87
|
+
GMP::GMP_RNDZ #=> The constant representing "round toward zero"
|
88
|
+
GMP::GMP_RNDU #=> The constant representing "round toward plus infinity"
|
89
|
+
GMP::GMP_RNDD #=> The constant representing "round toward minus infinity"
|
90
|
+
|
74
91
|
=Classes
|
75
92
|
|
76
|
-
The module
|
93
|
+
The GMP module is provided with following classes:
|
77
94
|
* GMP::Z - infinite precision integer numbers
|
78
95
|
* GMP::Q - infinite precision rational numbers
|
79
96
|
* GMP::F - arbitrary precision floating point numbers
|
@@ -190,19 +207,39 @@ You can also call them as:
|
|
190
207
|
prec get precision
|
191
208
|
floor,ceil,trunc nearest integer, GMP::F is returned, not GMP::Z
|
192
209
|
floor!,ceil!,trunc! in-place nearest integer
|
193
|
-
GMP::
|
194
|
-
|
195
|
-
|
196
|
-
|
210
|
+
GMP::RandState
|
211
|
+
seed(integer) seed the generator with a Fixnum or GMP::Z
|
212
|
+
urandomb(fixnum) get uniformly distributed random number between 0
|
213
|
+
and 2^fixnum-1, inclusive
|
214
|
+
urandomm(integer) get uniformly distributed random number between 0
|
215
|
+
and integer-1, inclusive
|
216
|
+
GMP (timing functions for GMPbench (0.2))
|
217
|
+
cputime milliseconds of cpu time since Ruby start
|
218
|
+
time times the execution of a block
|
219
|
+
|
220
|
+
*only if MPFR is available*
|
221
|
+
class methods of GMP::F
|
222
|
+
const_log2 returns the natural log of 2
|
223
|
+
const_pi returns pi
|
224
|
+
const_euler returns euler
|
225
|
+
const_catalan returns catalan
|
226
|
+
GMP::F
|
227
|
+
sqrt square root of the object
|
228
|
+
** power
|
197
229
|
log natural logarithm of object
|
198
230
|
log2 binary logarithm of object
|
199
231
|
log10 decimal logarithm of object
|
232
|
+
exp e^object
|
200
233
|
log1p the same as (object + 1).log, with better
|
201
234
|
precision
|
202
|
-
|
235
|
+
expm1 the same as (object.exp) - 1, with better
|
236
|
+
precision
|
203
237
|
cos \
|
204
238
|
sin |
|
205
239
|
tan |
|
240
|
+
sec |
|
241
|
+
csc |
|
242
|
+
cot |
|
206
243
|
acos |
|
207
244
|
asin |
|
208
245
|
atan | trigonometric functions
|
@@ -216,14 +253,9 @@ You can also call them as:
|
|
216
253
|
infinite? | type of floating point number
|
217
254
|
finite? |
|
218
255
|
number? /
|
219
|
-
** power
|
220
256
|
GMP::RandState
|
221
|
-
|
222
|
-
|
223
|
-
and 2^fixnum-1, inclusive
|
224
|
-
GMP (timing functions for GMPbench (0.2))
|
225
|
-
cputime milliseconds of cpu time since Ruby start
|
226
|
-
time times the execution of a block
|
257
|
+
mpfr_urandomb(fixnum) get uniformly distributed random floating-point
|
258
|
+
number within 0 <= rop < 1
|
227
259
|
|
228
260
|
|
229
261
|
=Testing
|
@@ -251,8 +283,9 @@ If there is no explicit precision, highest precision of all GMP::F arguments is
|
|
251
283
|
used. That doesn't ensure that result will be exact. For details, consult any
|
252
284
|
paper about floating point arithmetics.
|
253
285
|
|
254
|
-
Default precision can be explicitely set by passing 0
|
255
|
-
particular, you can set precision of copy of GMP::F
|
286
|
+
Default precision can be explicitely set by passing 0 as the second argument
|
287
|
+
for to GMP::F.new(). In particular, you can set precision of copy of GMP::F
|
288
|
+
object by:
|
256
289
|
new_obj = GMP::F.new(old_obj, 0)
|
257
290
|
|
258
291
|
Precision argument, and default_precision will be rounded up to whatever GMP
|
@@ -331,7 +364,6 @@ These are inherited from Tomasz. I will go through these and see which are
|
|
331
364
|
still relevant.
|
332
365
|
|
333
366
|
* mpz_fits_* and 31 vs. 32 integer variables
|
334
|
-
* all appropriate module and class methods if there are any to add
|
335
367
|
* fix all sign issues (don't know what these are)
|
336
368
|
* floats with precision control
|
337
369
|
* to_s vs. inspect
|
data/benchmark/runbench.rb
CHANGED
@@ -1,165 +1,165 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright 2003 Free Software Foundation, Inc.
|
4
|
-
|
5
|
-
# This file is part of the GNU GMPbench.
|
6
|
-
|
7
|
-
# This program is free software; you can redistribute it and/or modify it under
|
8
|
-
# the terms of the GNU General Public License as published by the Free Software
|
9
|
-
# Foundation; either version 2 of the License, or (at your option) any later
|
10
|
-
# version.
|
11
|
-
|
12
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
13
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
14
|
-
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
15
|
-
# details.
|
16
|
-
|
17
|
-
# You should have received a copy of the GNU General Public License along with
|
18
|
-
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
19
|
-
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
20
|
-
|
21
|
-
class String
|
22
|
-
def bs
|
23
|
-
gsub("/", "\\")
|
24
|
-
end
|
25
|
-
|
26
|
-
def sh_interpolate
|
27
|
-
gsub(/\$([A-Z]+)/) { |s| ENV[$1] }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
puts "***** GMPbench version 0.2 *****"
|
32
|
-
|
33
|
-
no_compile = false
|
34
|
-
default = false
|
35
|
-
gnu_bin = "/cygwin/bin/"
|
36
|
-
gnu_bin = "/Ruby19/devkit/msys/1.0.11/bin/"
|
37
|
-
|
38
|
-
while ARGV[0] =~ /^-/
|
39
|
-
case ARGV[0]
|
40
|
-
when "-g" then gnu_bin = ARGV[1]; ARGV.shift; ARGV.shift
|
41
|
-
when "-n" then no_compile = true; ARGV.shift
|
42
|
-
else ARGV.shift
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
if RUBY_VERSION =~ /mingw/ and !( ENV["PATH"] =~ /;\.$|^\.;|;\.;/ )
|
47
|
-
ENV["PATH"] += ";."
|
48
|
-
end
|
49
|
-
|
50
|
-
if no_compile
|
51
|
-
puts "Suppressing compilation"
|
52
|
-
else
|
53
|
-
unless ENV["CFLAGS"]
|
54
|
-
ENV["CFLAGS"] = "-O3 -fomit-frame-pointer"
|
55
|
-
puts "Using default CFLAGS = \"$CFLAGS\"".sh_interpolate
|
56
|
-
default = true
|
57
|
-
else
|
58
|
-
puts "Using CFLAGS = \"$CFLAGS\" from your environment".sh_interpolate
|
59
|
-
end
|
60
|
-
unless ENV["CC"]
|
61
|
-
ENV["CC"] = "gcc"
|
62
|
-
puts "Using default CC = \"$CC\"".sh_interpolate
|
63
|
-
default = true
|
64
|
-
else
|
65
|
-
puts "Using CC = \"$CC\" from your environment".sh_interpolate
|
66
|
-
end
|
67
|
-
unless ENV["LIBS"]
|
68
|
-
ENV["LIBS"] = "-static -lgmp"
|
69
|
-
puts "Using default LIBS = \"$LIBS\"".sh_interpolate
|
70
|
-
default = true
|
71
|
-
else
|
72
|
-
puts "Using LIBS = \"$LIBS\" from your environment".sh_interpolate
|
73
|
-
end
|
74
|
-
|
75
|
-
puts "Using compilation command: $CC $CFLAGS foo.c -o foo $LIBS".sh_interpolate
|
76
|
-
if default
|
77
|
-
puts "You may want to override CC, CFLAGS, and LIBS"
|
78
|
-
end
|
79
|
-
|
80
|
-
`#{"$CC $CFLAGS gmpver.c $LIBS".sh_interpolate}`
|
81
|
-
puts "Using `./a.out`"
|
82
|
-
|
83
|
-
puts "Compiling benchmarks"
|
84
|
-
`#{"$CC $CFLAGS gcd.c -o gcd $LIBS".sh_interpolate}`
|
85
|
-
`#{"$CC $CFLAGS gcdext.c -o gcdext $LIBS".sh_interpolate}`
|
86
|
-
`#{"$CC $CFLAGS multiply.c -o multiply $LIBS".sh_interpolate}`
|
87
|
-
`#{"$CC $CFLAGS divide.c -o divide $LIBS".sh_interpolate}`
|
88
|
-
`#{"$CC $CFLAGS rsa.c -o rsa $LIBS".sh_interpolate}`
|
89
|
-
`#{"$CC $CFLAGS pi.c -o pi $LIBS -lm".sh_interpolate}`
|
90
|
-
end
|
91
|
-
|
92
|
-
multiply_args = "128 512 8192 131072 2097152 128,128 512,512 8192,8192 " +
|
93
|
-
"131072,131072 2097152,2097152 15000,10000 20000,10000 " +
|
94
|
-
"30000,10000 16777216,512 16777216,262144"
|
95
|
-
multiply_weight = 1
|
96
|
-
|
97
|
-
divide_args = "8192,32 8192,64 8192,128 8192,4096 131072,65536 " +
|
98
|
-
"8388608,4194304 8192,8064 16777216,262144"
|
99
|
-
divide_weight = 1
|
100
|
-
|
101
|
-
gcd_args = "128,128 512,512 8192,8192 131072,131072 1048576,1048576"
|
102
|
-
gcd_weight = 0.5
|
103
|
-
|
104
|
-
gcdext_args = "128,128 512,512 8192,8192 131072,131072 1048576,1048576"
|
105
|
-
gcdext_weight = 0.5
|
106
|
-
|
107
|
-
rsa_args = "512 1024 2048"
|
108
|
-
rsa_weight = 1
|
109
|
-
|
110
|
-
pi_args = "10000 100000 1000000"
|
111
|
-
pi_weight = 1
|
112
|
-
|
113
|
-
#base_tests = "multiply divide gcd gcdext"
|
114
|
-
base_tests = "multiply divide gcd"
|
115
|
-
#app_tests = "rsa pi"
|
116
|
-
app_tests = "rsa"
|
117
|
-
|
118
|
-
tests = "base app"
|
119
|
-
|
120
|
-
puts "Running benchmarks (propagated score accuracy exceeds printed intermediates)"
|
121
|
-
|
122
|
-
acc2 = 1
|
123
|
-
n2 = 0
|
124
|
-
tests.split(" ").each do |cat|
|
125
|
-
puts " Category #{cat}"
|
126
|
-
tests = eval "#{cat}_tests"
|
127
|
-
|
128
|
-
acc1 = 1
|
129
|
-
n1 = 0
|
130
|
-
tests.split(" ").each do |t|
|
131
|
-
weight = eval "#{t}_weight"
|
132
|
-
puts " Program #{t} (weight=#{weight})"
|
133
|
-
args = eval "#{t}_args"
|
134
|
-
|
135
|
-
acc = 1
|
136
|
-
n = 0
|
137
|
-
args.split(" ").each do |a|
|
138
|
-
ta = `echo #{a} | #{gnu_bin}sed 's;,; ;g'`.chomp
|
139
|
-
printf ' %-48s', "GMPbench.#{cat}.#{t}(#{a})"
|
140
|
-
`ruby #{t} #{ta} > "RES-#{t}-#{a}"`
|
141
|
-
sed_cmd = "#{gnu_bin}sed 's;^RESULT: \\([0-9.]*\\).*$;\\1;'"
|
142
|
-
res_cmd = "#{gnu_bin}grep \"^RESULT\" RES-#{t}-#{a} | #{sed_cmd}"
|
143
|
-
res = `#{res_cmd}`
|
144
|
-
printf "%12s\n", `gexpr -prec 4 "#{res}"`.chomp
|
145
|
-
acc = `gexpr -prec 10 "#{acc} * #{res}"`
|
146
|
-
n = `gexpr #{n}+1`
|
147
|
-
end
|
148
|
-
|
149
|
-
out = `gexpr -prec 10 "#{acc}^(1/#{n})"`
|
150
|
-
printf " %-40s%12s\n", "GMPbench.#{cat}.#{t}", `gexpr -prec 5 "#{out}"`
|
151
|
-
acc1 = `gexpr -prec 10 "#{acc1} * #{out}^#{weight}"`
|
152
|
-
n1 = `gexpr #{n1}+#{weight}`
|
153
|
-
end
|
154
|
-
|
155
|
-
out = `gexpr -prec 10 "#{acc1}^(1/#{n1})"`
|
156
|
-
printf " %-32s%12s\n", "GMPbench.#{cat}", `gexpr -prec 5 "#{out}"`
|
157
|
-
acc2 = `gexpr -prec 10 "#{acc2} * #{out}"`
|
158
|
-
n2 = `gexpr #{n2}+1`
|
159
|
-
end
|
160
|
-
|
161
|
-
|
162
|
-
out = `gexpr "#{acc2}^(1/#{n2})"`
|
163
|
-
puts "GMPbench: #{out}"
|
164
|
-
|
165
|
-
exit 0
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright 2003 Free Software Foundation, Inc.
|
4
|
+
|
5
|
+
# This file is part of the GNU GMPbench.
|
6
|
+
|
7
|
+
# This program is free software; you can redistribute it and/or modify it under
|
8
|
+
# the terms of the GNU General Public License as published by the Free Software
|
9
|
+
# Foundation; either version 2 of the License, or (at your option) any later
|
10
|
+
# version.
|
11
|
+
|
12
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
14
|
+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
15
|
+
# details.
|
16
|
+
|
17
|
+
# You should have received a copy of the GNU General Public License along with
|
18
|
+
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
19
|
+
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
20
|
+
|
21
|
+
class String
|
22
|
+
def bs
|
23
|
+
gsub("/", "\\")
|
24
|
+
end
|
25
|
+
|
26
|
+
def sh_interpolate
|
27
|
+
gsub(/\$([A-Z]+)/) { |s| ENV[$1] }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
puts "***** GMPbench version 0.2 *****"
|
32
|
+
|
33
|
+
no_compile = false
|
34
|
+
default = false
|
35
|
+
gnu_bin = "/cygwin/bin/"
|
36
|
+
gnu_bin = "/Ruby19/devkit/msys/1.0.11/bin/"
|
37
|
+
|
38
|
+
while ARGV[0] =~ /^-/
|
39
|
+
case ARGV[0]
|
40
|
+
when "-g" then gnu_bin = ARGV[1]; ARGV.shift; ARGV.shift
|
41
|
+
when "-n" then no_compile = true; ARGV.shift
|
42
|
+
else ARGV.shift
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if RUBY_VERSION =~ /mingw/ and !( ENV["PATH"] =~ /;\.$|^\.;|;\.;/ )
|
47
|
+
ENV["PATH"] += ";."
|
48
|
+
end
|
49
|
+
|
50
|
+
if no_compile
|
51
|
+
puts "Suppressing compilation"
|
52
|
+
else
|
53
|
+
unless ENV["CFLAGS"]
|
54
|
+
ENV["CFLAGS"] = "-O3 -fomit-frame-pointer"
|
55
|
+
puts "Using default CFLAGS = \"$CFLAGS\"".sh_interpolate
|
56
|
+
default = true
|
57
|
+
else
|
58
|
+
puts "Using CFLAGS = \"$CFLAGS\" from your environment".sh_interpolate
|
59
|
+
end
|
60
|
+
unless ENV["CC"]
|
61
|
+
ENV["CC"] = "gcc"
|
62
|
+
puts "Using default CC = \"$CC\"".sh_interpolate
|
63
|
+
default = true
|
64
|
+
else
|
65
|
+
puts "Using CC = \"$CC\" from your environment".sh_interpolate
|
66
|
+
end
|
67
|
+
unless ENV["LIBS"]
|
68
|
+
ENV["LIBS"] = "-static -lgmp"
|
69
|
+
puts "Using default LIBS = \"$LIBS\"".sh_interpolate
|
70
|
+
default = true
|
71
|
+
else
|
72
|
+
puts "Using LIBS = \"$LIBS\" from your environment".sh_interpolate
|
73
|
+
end
|
74
|
+
|
75
|
+
puts "Using compilation command: $CC $CFLAGS foo.c -o foo $LIBS".sh_interpolate
|
76
|
+
if default
|
77
|
+
puts "You may want to override CC, CFLAGS, and LIBS"
|
78
|
+
end
|
79
|
+
|
80
|
+
`#{"$CC $CFLAGS gmpver.c $LIBS".sh_interpolate}`
|
81
|
+
puts "Using `./a.out`"
|
82
|
+
|
83
|
+
puts "Compiling benchmarks"
|
84
|
+
`#{"$CC $CFLAGS gcd.c -o gcd $LIBS".sh_interpolate}`
|
85
|
+
`#{"$CC $CFLAGS gcdext.c -o gcdext $LIBS".sh_interpolate}`
|
86
|
+
`#{"$CC $CFLAGS multiply.c -o multiply $LIBS".sh_interpolate}`
|
87
|
+
`#{"$CC $CFLAGS divide.c -o divide $LIBS".sh_interpolate}`
|
88
|
+
`#{"$CC $CFLAGS rsa.c -o rsa $LIBS".sh_interpolate}`
|
89
|
+
`#{"$CC $CFLAGS pi.c -o pi $LIBS -lm".sh_interpolate}`
|
90
|
+
end
|
91
|
+
|
92
|
+
multiply_args = "128 512 8192 131072 2097152 128,128 512,512 8192,8192 " +
|
93
|
+
"131072,131072 2097152,2097152 15000,10000 20000,10000 " +
|
94
|
+
"30000,10000 16777216,512 16777216,262144"
|
95
|
+
multiply_weight = 1
|
96
|
+
|
97
|
+
divide_args = "8192,32 8192,64 8192,128 8192,4096 131072,65536 " +
|
98
|
+
"8388608,4194304 8192,8064 16777216,262144"
|
99
|
+
divide_weight = 1
|
100
|
+
|
101
|
+
gcd_args = "128,128 512,512 8192,8192 131072,131072 1048576,1048576"
|
102
|
+
gcd_weight = 0.5
|
103
|
+
|
104
|
+
gcdext_args = "128,128 512,512 8192,8192 131072,131072 1048576,1048576"
|
105
|
+
gcdext_weight = 0.5
|
106
|
+
|
107
|
+
rsa_args = "512 1024 2048"
|
108
|
+
rsa_weight = 1
|
109
|
+
|
110
|
+
pi_args = "10000 100000 1000000"
|
111
|
+
pi_weight = 1
|
112
|
+
|
113
|
+
#base_tests = "multiply divide gcd gcdext"
|
114
|
+
base_tests = "multiply divide gcd"
|
115
|
+
#app_tests = "rsa pi"
|
116
|
+
app_tests = "rsa"
|
117
|
+
|
118
|
+
tests = "base app"
|
119
|
+
|
120
|
+
puts "Running benchmarks (propagated score accuracy exceeds printed intermediates)"
|
121
|
+
|
122
|
+
acc2 = 1
|
123
|
+
n2 = 0
|
124
|
+
tests.split(" ").each do |cat|
|
125
|
+
puts " Category #{cat}"
|
126
|
+
tests = eval "#{cat}_tests"
|
127
|
+
|
128
|
+
acc1 = 1
|
129
|
+
n1 = 0
|
130
|
+
tests.split(" ").each do |t|
|
131
|
+
weight = eval "#{t}_weight"
|
132
|
+
puts " Program #{t} (weight=#{weight})"
|
133
|
+
args = eval "#{t}_args"
|
134
|
+
|
135
|
+
acc = 1
|
136
|
+
n = 0
|
137
|
+
args.split(" ").each do |a|
|
138
|
+
ta = `echo #{a} | #{gnu_bin}sed 's;,; ;g'`.chomp
|
139
|
+
printf ' %-48s', "GMPbench.#{cat}.#{t}(#{a})"
|
140
|
+
`ruby #{t} #{ta} > "RES-#{t}-#{a}"`
|
141
|
+
sed_cmd = "#{gnu_bin}sed 's;^RESULT: \\([0-9.]*\\).*$;\\1;'"
|
142
|
+
res_cmd = "#{gnu_bin}grep \"^RESULT\" RES-#{t}-#{a} | #{sed_cmd}"
|
143
|
+
res = `#{res_cmd}`
|
144
|
+
printf "%12s\n", `gexpr -prec 4 "#{res}"`.chomp
|
145
|
+
acc = `gexpr -prec 10 "#{acc} * #{res}"`
|
146
|
+
n = `gexpr #{n}+1`
|
147
|
+
end
|
148
|
+
|
149
|
+
out = `gexpr -prec 10 "#{acc}^(1/#{n})"`
|
150
|
+
printf " %-40s%12s\n", "GMPbench.#{cat}.#{t}", `gexpr -prec 5 "#{out}"`
|
151
|
+
acc1 = `gexpr -prec 10 "#{acc1} * #{out}^#{weight}"`
|
152
|
+
n1 = `gexpr #{n1}+#{weight}`
|
153
|
+
end
|
154
|
+
|
155
|
+
out = `gexpr -prec 10 "#{acc1}^(1/#{n1})"`
|
156
|
+
printf " %-32s%12s\n", "GMPbench.#{cat}", `gexpr -prec 5 "#{out}"`
|
157
|
+
acc2 = `gexpr -prec 10 "#{acc2} * #{out}"`
|
158
|
+
n2 = `gexpr #{n2}+1`
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
out = `gexpr "#{acc2}^(1/#{n2})"`
|
163
|
+
puts "GMPbench: #{out}"
|
164
|
+
|
165
|
+
exit 0
|