gmp 0.5.3-x86-mingw32 → 0.5.23-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +19 -0
- data/FEATURES.html +393 -0
- data/README.rdoc +64 -32
- data/ext/gmp.c +5 -55
- data/ext/gmp.so +0 -0
- data/ext/gmpf.c +300 -179
- data/ext/gmpq.c +81 -111
- data/ext/gmprandstate.c +30 -0
- data/ext/gmpz.c +543 -424
- data/ext/gmpz.h +0 -8
- data/ext/ruby_gmp.h +14 -20
- data/manual.pdf +0 -0
- data/manual.tex +56 -11
- data/test/gmp_tgcd.rb +126 -0
- data/test/mpfr_tconst_euler.rb +36 -0
- data/test/tc_mpfr_functions.rb +48 -17
- data/test/tc_q.rb +80 -0
- data/test/tc_q_basic.rb +2 -2
- data/test/tc_z.rb +46 -16
- data/test/tc_z_submul.rb +94 -0
- data/test/tc_z_to_dis.rb +69 -0
- data/test/unit_tests.rb +8 -5
- metadata +10 -9
- data/benchmark/gexpr +0 -0
- data/test/tc_z_to_d_to_i.rb +0 -24
- data/test/test-12.rb +0 -14
- data/test/test-19.rb +0 -13
data/test/tc_q.rb
CHANGED
@@ -23,6 +23,86 @@ class TC_Q < Test::Unit::TestCase
|
|
23
23
|
assert_equal(GMP::Q.new(a), a, "GMP::Q.new(x : Q) should initialize to x")
|
24
24
|
end
|
25
25
|
|
26
|
+
def test_neg
|
27
|
+
a = GMP::Q( 1,2)
|
28
|
+
neg_a = GMP::Q(-1,2)
|
29
|
+
assert_equal(neg_a, -a, "GMP::Q#-@ should work.")
|
30
|
+
assert_equal(neg_a, a.neg, "GMP::Q#neg should work.")
|
31
|
+
a.neg!
|
32
|
+
assert_equal(neg_a, a, "GMP::Q#neg! should work.")
|
33
|
+
|
34
|
+
b = GMP::Q(-4,3)
|
35
|
+
neg_b = GMP::Q( 4,3)
|
36
|
+
assert_equal(neg_b, -b, "GMP::Q#-@ should work.")
|
37
|
+
assert_equal(neg_b, b.neg, "GMP::Q#neg should work.")
|
38
|
+
b.neg!
|
39
|
+
assert_equal(neg_b, b, "GMP::Q#neg! should work.")
|
40
|
+
|
41
|
+
c = GMP::Q( "9753108642/2")
|
42
|
+
neg_c = GMP::Q("-9753108642/2")
|
43
|
+
assert_equal(neg_c, -c, "GMP::Q#-@ should work.")
|
44
|
+
assert_equal(neg_c, c.neg, "GMP::Q#neg should work.")
|
45
|
+
c.neg!
|
46
|
+
assert_equal(neg_c, c, "GMP::Q#neg! should work.")
|
47
|
+
|
48
|
+
d = GMP::Q(0)
|
49
|
+
neg_d = GMP::Q(0)
|
50
|
+
assert_equal(neg_d, -d, "GMP::Q#-@ should work.")
|
51
|
+
assert_equal(neg_d, d.neg, "GMP::Q#neg should work.")
|
52
|
+
d.neg!
|
53
|
+
assert_equal(neg_d, d, "GMP::Q#neg! should work.")
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_abs
|
57
|
+
a = GMP::Q(1,2)
|
58
|
+
abs_a = GMP::Q(1,2)
|
59
|
+
assert_equal(abs_a, a.abs, "GMP::Q#abs should work.")
|
60
|
+
a.abs!
|
61
|
+
assert_equal(abs_a, a, "GMP::Q#abs! should work.")
|
62
|
+
|
63
|
+
b = GMP::Q(-4,3)
|
64
|
+
abs_b = GMP::Q( 4,3)
|
65
|
+
assert_equal(abs_b, b.abs, "GMP::Q#abs should work.")
|
66
|
+
b.abs!
|
67
|
+
assert_equal(abs_b, b, "GMP::Q#abs! should work.")
|
68
|
+
|
69
|
+
c = GMP::Q("9753108642/2")
|
70
|
+
abs_c = GMP::Q("9753108642/2")
|
71
|
+
assert_equal(abs_c, c.abs, "GMP::Q#abs should work.")
|
72
|
+
c.abs!
|
73
|
+
assert_equal(abs_c, c, "GMP::Q#abs! should work.")
|
74
|
+
|
75
|
+
d = GMP::Q(0)
|
76
|
+
abs_d = GMP::Q(0)
|
77
|
+
assert_equal(abs_d, d.abs, "GMP::Q#abs should work.")
|
78
|
+
d.abs!
|
79
|
+
assert_equal(abs_d, d, "GMP::Q#abs! should work.")
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_inv
|
83
|
+
a = GMP::Q(1,2)
|
84
|
+
inv_a = GMP::Q(2,1)
|
85
|
+
assert_equal(inv_a, a.inv, "GMP::Q#inv should work.")
|
86
|
+
a.inv!
|
87
|
+
assert_equal(inv_a, a, "GMP::Q#inv! should work.")
|
88
|
+
|
89
|
+
b = GMP::Q(-4,3)
|
90
|
+
inv_b = GMP::Q(-3,4)
|
91
|
+
assert_equal(inv_b, b.inv, "GMP::Q#inv should work.")
|
92
|
+
b.inv!
|
93
|
+
assert_equal(inv_b, b, "GMP::Q#inv! should work.")
|
94
|
+
|
95
|
+
c = GMP::Q("9753108642/2")
|
96
|
+
inv_c = GMP::Q("2/9753108642")
|
97
|
+
assert_equal(inv_c, c.inv, "GMP::Q#inv should work.")
|
98
|
+
c.inv!
|
99
|
+
assert_equal(inv_c, c, "GMP::Q#inv! should work.")
|
100
|
+
|
101
|
+
d = GMP::Q(0)
|
102
|
+
assert_raise(ZeroDivisionError) { d.inv }
|
103
|
+
assert_raise(ZeroDivisionError) { d.inv! }
|
104
|
+
end
|
105
|
+
|
26
106
|
def test_to_s
|
27
107
|
assert_equal("1/2", GMP::Q(1,2).to_s, "GMP::Q should to_s properly.")
|
28
108
|
assert_equal("1/4294967296", GMP::Q(1,2**32).to_s, "GMP::Q should to_s properly.")
|
data/test/tc_q_basic.rb
CHANGED
@@ -32,8 +32,8 @@ class TC_Q_Basic < Test::Unit::TestCase
|
|
32
32
|
assert_equal(@a * @c, GMP::Q(4000, 11), "GMP::Q should multiply GMP::Z correctly")
|
33
33
|
assert_equal(@c * @a, GMP::Q(4000, 11), "GMP::Z should multiply GMP::Q correctly")
|
34
34
|
assert_equal(@a * 2, GMP::Q(200, 11), "GMP::Z should multiply Fixnum correctly")
|
35
|
-
#
|
35
|
+
#assert_equal(@a * @d, GMP::Q(429496729600, 11),"GMP::Z should multiply Bignum correctly") # SEGFAULT
|
36
36
|
assert_equal( 2 * @a, GMP::Q(200, 11), "Fixnum should multiply GMP::Q correctly")
|
37
|
-
#
|
37
|
+
#assert_equal(@d * @a, GMP::Q(429496729600, 11),"Bignum should multiply GMP::Q correctly") # SEGFAULT
|
38
38
|
end
|
39
39
|
end
|
data/test/tc_z.rb
CHANGED
@@ -51,21 +51,51 @@ class TC_Z < Test::Unit::TestCase
|
|
51
51
|
assert_equal(a <=> a, 0, "GMP::Z should <=> correctly with GMP::Z")
|
52
52
|
assert_equal(b <=> a, -1, "GMP::Z should <=> correctly with GMP::Z")
|
53
53
|
end
|
54
|
-
|
55
|
-
def
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
54
|
+
|
55
|
+
def test_divisible_ui
|
56
|
+
a = GMP::Z(120)
|
57
|
+
b = GMP::Z(17)
|
58
|
+
a_factors = [1,2,3,4,5,6,8,10,12,15,20,24,30,40,60,120]
|
59
|
+
a_factors.each do |d|
|
60
|
+
assert_true(a.divisible?(d), "GMP::Z#divisible? ui should be false: #{a}.divisible? #{d}")
|
61
|
+
end
|
62
|
+
((1..120).to_a - a_factors).each do |d|
|
63
|
+
assert_false(a.divisible?(d), "GMP::Z#divisible? ui should be false: #{a}.divisible? #{d}")
|
64
|
+
end
|
65
|
+
(2..16).to_a.each do |d|
|
66
|
+
assert_false(b.divisible?(d), "GMP::Z#divisible? ui should be false: #{a}.divisible? #{d}")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_divisible_bignum
|
71
|
+
a = GMP::Z(2**71 - 3**31)
|
72
|
+
a_factors = [29, 743, 109_582_894_312_963_583,
|
73
|
+
29*743, 29*109_582_894_312_963_583,
|
74
|
+
743*109_582_894_312_963_583,
|
75
|
+
29*743*109_582_894_312_963_583]
|
76
|
+
a_factors.each do |d|
|
77
|
+
assert_true(a.divisible?(d), "GMP::Z#divisible? bignum should be false: #{a}.divisible? #{d}")
|
78
|
+
end
|
79
|
+
a_factors.map { |n| n*2 }.each do |d|
|
80
|
+
assert_false(a.divisible?(d), "GMP::Z#divisible? ui should be false: #{a}.divisible? #{d}")
|
81
|
+
end
|
82
|
+
a_factors.map { |n| n*3 }.each do |d|
|
83
|
+
assert_false(a.divisible?(d), "GMP::Z#divisible? ui should be false: #{a}.divisible? #{d}")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_divisible_z
|
88
|
+
a = GMP::Z(120)
|
89
|
+
b = GMP::Z(17)
|
90
|
+
a_factors = [1,2,3,4,5,6,8,10,12,15,20,24,30,40,60,120].map { |n| GMP::Z(n) }
|
91
|
+
a_factors.each do |d|
|
92
|
+
assert_true(a.divisible?(d), "GMP::Z#divisible? GMP::Z should be true: #{a}.divisible? #{d}")
|
93
|
+
end
|
94
|
+
((1..120).to_a.map { |n| GMP::Z(n) } - a_factors).each do |d|
|
95
|
+
assert_false(a.divisible?(d), "GMP::Z#divisible? ui should be false: #{a}.divisible? #{d}")
|
96
|
+
end
|
97
|
+
(2..16).to_a.map { |n| GMP::Z(n) }.each do |d|
|
98
|
+
assert_false(b.divisible?(d), "GMP::Z#divisible? ui should be false: #{a}.divisible? #{d}")
|
99
|
+
end
|
70
100
|
end
|
71
101
|
end
|
data/test/tc_z_submul.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
require './test_helper'
|
2
|
+
|
3
|
+
# Tested: [Z op (Z,Z), Z op (Z,Fixnum), Z op (Z,Bignum),
|
4
|
+
# Z op (Fixnum,Z), Z op (Fixnum,Fixnum), Z op (Fixnum,Bignum)
|
5
|
+
# Z op (Bignum,Z), Z op (Bignum,Bignum), Z op (Bignum,Fixnum)]
|
6
|
+
# Things are tested both ways because the implementation is asymetrical
|
7
|
+
class TC_Z_Submul < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
@_64bit = 1_000_000_000_000.is_a? Fixnum
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_z
|
13
|
+
five = GMP::Z(5)
|
14
|
+
seven = GMP::Z(7)
|
15
|
+
five.submul!(seven, seven) # <= 5 - 49
|
16
|
+
assert_equal(-44, five, "GMP::Z should submul GMP::Z correctly")
|
17
|
+
five = GMP::Z(5)
|
18
|
+
twenty = GMP::Z(20)
|
19
|
+
neg2 = GMP::Z(-2)
|
20
|
+
five.submul!(twenty, neg2) # <= 5 - -40
|
21
|
+
assert_equal(45, five, "GMP::Z should submul GMP::Z correctly")
|
22
|
+
m20 = GMP::Z(2)**20 - 1 # 1_048_575
|
23
|
+
m19 = GMP::Z(2)**19 - 1 # 524_287
|
24
|
+
neg_two = GMP::Z(-2)
|
25
|
+
m20.submul!(m19, neg_two) # <= 1_048_575 - -1_048_574
|
26
|
+
assert_equal(2_097_149, m20, "GMP::Z should submul GMP::Z correctly")
|
27
|
+
|
28
|
+
neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
|
29
|
+
ten_million = 10_000_000
|
30
|
+
neg_million = -GMP::Z(1_000_000)
|
31
|
+
million = GMP::Z(1_000_000)
|
32
|
+
thirty_thou = GMP::Z( 30_000)
|
33
|
+
thirty = GMP::Z( 30)
|
34
|
+
neg_m40.submul!(-neg_million, neg_million) # <= -1_099_511_627_776 + 1_000_000_000_000
|
35
|
+
assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should submul GMP::Z correctly")
|
36
|
+
neg_m40.submul!(-ten_million, GMP::Z(9_000)) # <= - 99_511_627_776 + 90_000_000_000
|
37
|
+
assert_equal(GMP::Z(- 9_511_627_776), neg_m40, "GMP::Z should submul GMP::Z correctly")
|
38
|
+
neg_m40.submul!( -million, GMP::Z(9_000)) # <= - 9_511_627_776 + 9_000_000_000
|
39
|
+
assert_equal(GMP::Z(- 511_627_776), neg_m40, "GMP::Z should submul GMP::Z correctly")
|
40
|
+
neg_m40.submul!(GMP::Z(-17_000), thirty_thou) # <= - 511_627_776 + 510_000_000
|
41
|
+
assert_equal(GMP::Z(- 1_627_776), neg_m40, "GMP::Z should submul GMP::Z correctly")
|
42
|
+
neg_m40.submul!(GMP::Z(400), GMP::Z(-4000)) # <= - 1_627_776 + 1_600_000
|
43
|
+
assert_equal(GMP::Z(- 27_776), neg_m40, "GMP::Z should submul GMP::Z correctly")
|
44
|
+
neg_m40.submul!(GMP::Z(30), thirty*(-30)) # <= - 27_776 + 27_000
|
45
|
+
assert_equal(GMP::Z(- 776), neg_m40, "GMP::Z should submul GMP::Z correctly")
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_fixnum
|
49
|
+
five = GMP::Z(5)
|
50
|
+
five.submul!(7, 7) # <= 5 - 49
|
51
|
+
assert_equal(-44, five, "GMP::Z should submul Fixnum correctly")
|
52
|
+
five = GMP::Z(5)
|
53
|
+
five.submul!(-20, 2) # <= 5 - -40
|
54
|
+
assert_equal(45, five, "GMP::Z should submul Fixnum correctly")
|
55
|
+
m20 = GMP::Z(2)**20 - 1 # 1_048_575
|
56
|
+
m20.submul!(-524_287, 2) # <= 1_048_575 - -1_048_574
|
57
|
+
assert_equal(2_097_149, m20, "GMP::Z should submul Fixnum correctly")
|
58
|
+
if @_64bit
|
59
|
+
neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
|
60
|
+
neg_m40.submul!( 1_000_000_000_000, 1) # <= -1_099_511_627_776 - 1_000_000_000_000
|
61
|
+
assert_equal(GMP::Z(-2_099_511_627_776), neg_m40, "GMP::Z should submul 64-bit Fixnum correctly")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_bignum
|
66
|
+
if ! @_64bit
|
67
|
+
neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
|
68
|
+
neg_m40.submul!( -1_000_000_000_000, 1) # <= -1_099_511_627_776 - -1_000_000_000_000
|
69
|
+
assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
|
70
|
+
neg_m40.submul!(-10, 9_000_000_000) # <= - 99_511_627_776 - -90_000_000_000
|
71
|
+
assert_equal(GMP::Z(- 9_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
|
72
|
+
neg_m40.submul!( -3_000_000_000, 3) # <= - 9_511_627_776 - -9_000_000_000
|
73
|
+
assert_equal(GMP::Z(- 511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
|
74
|
+
else
|
75
|
+
m70 = GMP::Z(2)**70 - 1 # 1_180_591_620_717_411_303_423
|
76
|
+
m70.submul!(11*10_000_000_000, 10_000_000_000)
|
77
|
+
assert_equal(GMP::Z(80_591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
|
78
|
+
m70.submul!(1_000_000_000, 8*10_000_000_000)
|
79
|
+
assert_equal(GMP::Z( 591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_raise
|
84
|
+
if ! @_64bit
|
85
|
+
assert_raise(RangeError) { GMP::Z(123).submul!(456, -7) }
|
86
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000) }
|
87
|
+
else
|
88
|
+
assert_raise(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000) }
|
89
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000_000_000_000) }
|
90
|
+
end
|
91
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, 7) }
|
92
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, GMP::Z(-7)) }
|
93
|
+
end
|
94
|
+
end
|
data/test/tc_z_to_dis.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require './test_helper'
|
2
|
+
|
3
|
+
class TC_to_i_to_d < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@a = GMP::Z.new(100)
|
6
|
+
@b = GMP::Z.pow(2,32)
|
7
|
+
@c = GMP::Q.new(200,11)
|
8
|
+
@d = GMP::Z.new(-123456789)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_to_i
|
12
|
+
assert_equal(@a.to_i, 100, "GMP::Z should to_i correctly.")
|
13
|
+
assert_equal(@a.to_i.class, Fixnum, "GMP::Z.to_i should be a Fixnum.")
|
14
|
+
assert_equal(@b.to_i, 2**32, "GMP::Z (Bignum) should to_i correctly.")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_to_d
|
18
|
+
assert_equal(@a.to_d, 100.0, "GMP::Z should to_d correctly.")
|
19
|
+
assert_equal(@a.to_d.class, Float, "GMP::Z.to_d should be a Float.")
|
20
|
+
#assert_equal(@b.to_d, 2**32*1.0, "GMP::Z should to_d correctly.")
|
21
|
+
assert_equal(@b.to_d.class, Float, "GMP::Z.to_d should be a Float.")
|
22
|
+
assert_equal(@c.to_d.class, Float, "GMP::Q.to_d should be a Float.")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_to_s
|
26
|
+
assert_equal( "100", @a.to_s , "GMP::Z should to_s correctly.")
|
27
|
+
assert_equal( "4294967296", @b.to_s , "GMP::Z should to_s correctly.")
|
28
|
+
assert_equal("-111010110111100110100010101", @d.to_s( 2), "GMP::Z should to_s correctly.")
|
29
|
+
assert_equal( "-22121022020212200", @d.to_s( 3), "GMP::Z should to_s correctly.")
|
30
|
+
assert_equal( "-13112330310111", @d.to_s( 4), "GMP::Z should to_s correctly.")
|
31
|
+
assert_equal( "-223101104124", @d.to_s( 5), "GMP::Z should to_s correctly.")
|
32
|
+
assert_equal( "-20130035113", @d.to_s( 6), "GMP::Z should to_s correctly.")
|
33
|
+
assert_equal( "-3026236221", @d.to_s( 7), "GMP::Z should to_s correctly.")
|
34
|
+
assert_equal( "-726746425", @d.to_s( 8), "GMP::Z should to_s correctly.")
|
35
|
+
assert_equal( "-277266780", @d.to_s( 9), "GMP::Z should to_s correctly.")
|
36
|
+
assert_equal( "-123456789", @d.to_s( 10), "GMP::Z should to_s correctly.")
|
37
|
+
assert_equal( "-63762a05", @d.to_s( 11), "GMP::Z should to_s correctly.")
|
38
|
+
assert_equal( "-35418a99", @d.to_s( 12), "GMP::Z should to_s correctly.")
|
39
|
+
assert_equal( "-1c767471", @d.to_s( 13), "GMP::Z should to_s correctly.")
|
40
|
+
assert_equal( "-12579781", @d.to_s( 14), "GMP::Z should to_s correctly.")
|
41
|
+
assert_equal( "-ac89bc9", @d.to_s( 15), "GMP::Z should to_s correctly.")
|
42
|
+
assert_equal( "-75bcd15", @d.to_s( 16), "GMP::Z should to_s correctly.")
|
43
|
+
assert_equal( "-63762A05", @d.to_s( -11), "GMP::Z should to_s correctly.")
|
44
|
+
assert_equal( "-35418A99", @d.to_s( -12), "GMP::Z should to_s correctly.")
|
45
|
+
assert_equal( "-1C767471", @d.to_s( -13), "GMP::Z should to_s correctly.")
|
46
|
+
assert_equal( "-12579781", @d.to_s( -14), "GMP::Z should to_s correctly.")
|
47
|
+
assert_equal( "-AC89BC9", @d.to_s( -15), "GMP::Z should to_s correctly.")
|
48
|
+
assert_equal( "-75BCD15", @d.to_s( -16), "GMP::Z should to_s correctly.")
|
49
|
+
assert_equal("-111010110111100110100010101", @d.to_s(:bin), "GMP::Z should to_s correctly.")
|
50
|
+
assert_equal( "-726746425", @d.to_s(:oct), "GMP::Z should to_s correctly.")
|
51
|
+
assert_equal( "-123456789", @d.to_s(:dec), "GMP::Z should to_s correctly.")
|
52
|
+
assert_equal( "-75bcd15", @d.to_s(:hex), "GMP::Z should to_s correctly.")
|
53
|
+
|
54
|
+
assert_equal("1", GMP::Z.new(1).to_s, "Z(1).to_s should equal '1'")
|
55
|
+
assert_equal("-1", GMP::Z.new(-1).to_s, "Z(1).to_s should equal '-1'")
|
56
|
+
assert_equal("1234567890", GMP::Z.new(1234567890).to_s, "GMP::Z should to_s correctly.")
|
57
|
+
assert_equal("100000", GMP::Z.new(32).to_s( 2), "GMP::Z should to_s( 2) correctly.")
|
58
|
+
assert_equal("200", GMP::Z.new(32).to_s( 4), "GMP::Z should to_s( 4) correctly.")
|
59
|
+
assert_equal("40", GMP::Z.new(32).to_s( 8), "GMP::Z should to_s( 8) correctly.")
|
60
|
+
assert_equal("32", GMP::Z.new(32).to_s( 10), "GMP::Z should to_s( 10) correctly.")
|
61
|
+
assert_equal("20", GMP::Z.new(32).to_s( 16), "GMP::Z should to_s( 16) correctly.")
|
62
|
+
assert_equal("a", GMP::Z.new(10).to_s( 16), "GMP::Z should to_s( 16) correctly.")
|
63
|
+
assert_equal("A", GMP::Z.new(10).to_s( -16), "GMP::Z should to_s( -16) correctly.")
|
64
|
+
assert_equal("11111111", GMP::Z.new(255).to_s(:bin), "GMP::Z should to_s(:bin) correctly.")
|
65
|
+
assert_equal("377", GMP::Z.new(255).to_s(:oct), "GMP::Z should to_s(:oct) correctly.")
|
66
|
+
assert_equal("255", GMP::Z.new(255).to_s(:dec), "GMP::Z should to_s(:dec) correctly.")
|
67
|
+
assert_equal("ff", GMP::Z.new(255).to_s(:hex), "GMP::Z should to_s(:hex) correctly.")
|
68
|
+
end
|
69
|
+
end
|
data/test/unit_tests.rb
CHANGED
@@ -6,27 +6,30 @@ require './tc_constants'
|
|
6
6
|
require './tc_z'
|
7
7
|
require './tc_z_basic'
|
8
8
|
require './tc_z_addmul'
|
9
|
+
require './tc_z_submul'
|
9
10
|
require './tc_z_logic'
|
11
|
+
require './tc_z_exponentiation'
|
12
|
+
require './tc_z_to_dis'
|
13
|
+
require './tc_z_shifts_last_bits'
|
14
|
+
require './tc_z_jac_leg_rem'
|
15
|
+
require './tc_z_gcd_lcm_invert'
|
10
16
|
require './tc_q'
|
11
17
|
require './tc_cmp'
|
12
18
|
require './tc_q_basic'
|
13
|
-
require './tc_z_exponentiation'
|
14
19
|
require './tc_zerodivisionexceptions'
|
15
20
|
require './tc_sgn_neg_abs'
|
16
21
|
require './tc_fib_fac_nextprime'
|
17
22
|
require './tc_swap'
|
18
23
|
require './tc_floor_ceil_truncate'
|
19
|
-
require './tc_z_to_d_to_i'
|
20
|
-
require './tc_z_shifts_last_bits'
|
21
24
|
require './tc_logical_roots'
|
22
25
|
require './tc_f_precision'
|
23
26
|
require './tc_f_arithmetics_coersion'
|
24
27
|
require './tc_division'
|
25
|
-
require './tc_z_jac_leg_rem'
|
26
|
-
require './tc_z_gcd_lcm_invert'
|
27
28
|
require './tc_random'
|
28
29
|
require './tc_hashes'
|
29
30
|
|
31
|
+
require './gmp_tgcd'
|
32
|
+
|
30
33
|
begin
|
31
34
|
GMP::MPFR_VERSION
|
32
35
|
require './tc_mpfr_constants'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 37
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 23
|
10
|
+
version: 0.5.23
|
11
11
|
platform: x86-mingw32
|
12
12
|
authors:
|
13
13
|
- Tomasz Wegrzanowski
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-10-04 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|
@@ -50,7 +50,9 @@ files:
|
|
50
50
|
- ext/libmpfr-1.dll
|
51
51
|
- ext/libmpfr-4.dll
|
52
52
|
- ext/gmp.so
|
53
|
+
- test/gmp_tgcd.rb
|
53
54
|
- test/mpfr_tcbrt.rb
|
55
|
+
- test/mpfr_tconst_euler.rb
|
54
56
|
- test/mpfr_tisnan.rb
|
55
57
|
- test/mpfr_trec_sqrt.rb
|
56
58
|
- test/mpfr_tsqrt.rb
|
@@ -81,9 +83,8 @@ files:
|
|
81
83
|
- test/tc_z_jac_leg_rem.rb
|
82
84
|
- test/tc_z_logic.rb
|
83
85
|
- test/tc_z_shifts_last_bits.rb
|
84
|
-
- test/
|
85
|
-
- test/
|
86
|
-
- test/test-19.rb
|
86
|
+
- test/tc_z_submul.rb
|
87
|
+
- test/tc_z_to_dis.rb
|
87
88
|
- test/test-20.rb
|
88
89
|
- test/test-21.rb
|
89
90
|
- test/test-22.rb
|
@@ -95,7 +96,6 @@ files:
|
|
95
96
|
- benchmark/COPYING
|
96
97
|
- benchmark/divide
|
97
98
|
- benchmark/gcd
|
98
|
-
- benchmark/gexpr
|
99
99
|
- benchmark/gexpr.c
|
100
100
|
- benchmark/gexpr.exe
|
101
101
|
- benchmark/multiply
|
@@ -112,7 +112,8 @@ files:
|
|
112
112
|
- README.rdoc
|
113
113
|
- manual.pdf
|
114
114
|
- manual.tex
|
115
|
-
|
115
|
+
- FEATURES.html
|
116
|
+
has_rdoc: yard
|
116
117
|
homepage: http://github.com/srawlins/gmp
|
117
118
|
licenses: []
|
118
119
|
|
data/benchmark/gexpr
DELETED
Binary file
|
data/test/tc_z_to_d_to_i.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require './test_helper'
|
2
|
-
|
3
|
-
class TC_to_i_to_d < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@a = GMP::Z.new(100)
|
6
|
-
#@b = GMP::Z.pow(2,32)
|
7
|
-
@c = GMP::Q.new(200,11)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_to_i
|
11
|
-
assert_equal(@a.to_i, 100, "GMP::Z should to_i correctly.")
|
12
|
-
assert_equal(@a.to_i.class, Fixnum, "GMP::Z.to_i should be a Fixnum.")
|
13
|
-
#assert_equal(@b.to_i, 2**32, "GMP::Z (Bignum) should to_i correctly.")
|
14
|
-
#assert_equal(@b.to_i.class, Bignum, "GMP::Z.to_i should be a Bignum.")
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_to_d
|
18
|
-
assert_equal(@a.to_d, 100.0, "GMP::Z should to_d correctly.")
|
19
|
-
assert_equal(@a.to_d.class, Float, "GMP::Z.to_d should be a Float.")
|
20
|
-
#assert_equal(@b.to_d, 2**32*1.0, "GMP::Z should to_d correctly.")
|
21
|
-
#assert_equal(@b.to_d.class, Float, "GMP::Z.to_d should be a Float.")
|
22
|
-
assert_equal(@c.to_d.class, Float, "GMP::Q.to_d should be a Float.")
|
23
|
-
end
|
24
|
-
end
|