gmp 0.4.0-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.
Files changed (59) hide show
  1. data/CHANGELOG +109 -0
  2. data/INSTALL +4 -0
  3. data/README.rdoc +357 -0
  4. data/benchmark/COPYING +674 -0
  5. data/benchmark/README +75 -0
  6. data/benchmark/divide +34 -0
  7. data/benchmark/gcd +38 -0
  8. data/benchmark/gexpr +0 -0
  9. data/benchmark/gexpr.c +359 -0
  10. data/benchmark/multiply +44 -0
  11. data/benchmark/rsa +93 -0
  12. data/benchmark/runbench +147 -0
  13. data/benchmark/version +1 -0
  14. data/ext/extconf.rb +30 -0
  15. data/ext/gmp.c +197 -0
  16. data/ext/gmpbench_timing.c +80 -0
  17. data/ext/gmpf.c +595 -0
  18. data/ext/gmpf.h +144 -0
  19. data/ext/gmpq.c +780 -0
  20. data/ext/gmpq.h +12 -0
  21. data/ext/gmprandstate.c +224 -0
  22. data/ext/gmpz.c +1968 -0
  23. data/ext/gmpz.h +20 -0
  24. data/ext/libgmp-10.dll +0 -0
  25. data/ext/ruby_gmp.h +243 -0
  26. data/ext/takeover.h +36 -0
  27. data/manual.pdf +0 -0
  28. data/manual.tex +804 -0
  29. data/test/README +34 -0
  30. data/test/tc_cmp.rb +74 -0
  31. data/test/tc_division.rb +109 -0
  32. data/test/tc_f_arithmetics_coersion.rb +71 -0
  33. data/test/tc_f_precision.rb +48 -0
  34. data/test/tc_fib_fac_nextprime.rb +51 -0
  35. data/test/tc_floor_ceil_truncate.rb +21 -0
  36. data/test/tc_logical_roots.rb +48 -0
  37. data/test/tc_q.rb +27 -0
  38. data/test/tc_q_basic.rb +41 -0
  39. data/test/tc_random.rb +54 -0
  40. data/test/tc_sgn_neg_abs.rb +47 -0
  41. data/test/tc_swap.rb +19 -0
  42. data/test/tc_z.rb +71 -0
  43. data/test/tc_z_basic.rb +35 -0
  44. data/test/tc_z_exponentiation.rb +22 -0
  45. data/test/tc_z_gcd_lcm_invert.rb +57 -0
  46. data/test/tc_z_jac_leg_rem.rb +73 -0
  47. data/test/tc_z_logic.rb +54 -0
  48. data/test/tc_z_shifts_last_bits.rb +22 -0
  49. data/test/tc_z_to_d_to_i.rb +24 -0
  50. data/test/tc_zerodivisionexceptions.rb +17 -0
  51. data/test/test-12.rb +14 -0
  52. data/test/test-19.rb +13 -0
  53. data/test/test-20.rb +29 -0
  54. data/test/test-21.rb +37 -0
  55. data/test/test-22.rb +12 -0
  56. data/test/test-23.rb +11 -0
  57. data/test/test_helper.rb +8 -0
  58. data/test/unit_tests.rb +39 -0
  59. metadata +115 -0
@@ -0,0 +1,54 @@
1
+ require 'test_helper'
2
+
3
+ class TC_Z_Logic < Test::Unit::TestCase
4
+ def setup
5
+ @a=GMP::Z.new(0xffff00000000ffff)
6
+ @b=GMP::Z.new(0xffff0000ffff0000)
7
+ @c=0xff00ff00ff00ff00
8
+ @d=0x1248
9
+ end
10
+
11
+ def test_and
12
+ assert_equal(@a & @b, 0xffff00000000ffff & 0xffff0000ffff0000, "GMP::Z should AND correctly")
13
+ assert_equal(@a & @d, 0xffff00000000ffff & 0x1248, "GMP::Z should AND correctly")
14
+ assert_equal(@a & @c, 0xffff00000000ffff & 0xff00ff00ff00ff00, "GMP::Z should AND correctly")
15
+ assert_equal(@d & @a, 0x1248 & 0xffff00000000ffff, "GMP::Z should AND correctly")
16
+ assert_equal(@c & @a, 0xff00ff00ff00ff00 & 0xffff00000000ffff, "GMP::Z should AND correctly")
17
+ end
18
+
19
+ def test_or
20
+ assert_equal(@a | @b, 0xffff00000000ffff | 0xffff0000ffff0000, "GMP::Z should OR correctly")
21
+ assert_equal(@a | @d, 0xffff00000000ffff | 0x1248, "GMP::Z should OR correctly")
22
+ assert_equal(@a | @c, 0xffff00000000ffff | 0xff00ff00ff00ff00, "GMP::Z should OR correctly")
23
+ assert_equal(@d | @a, 0x1248 | 0xffff00000000ffff, "GMP::Z should OR correctly")
24
+ assert_equal(@c | @a, 0xff00ff00ff00ff00 | 0xffff00000000ffff, "GMP::Z should OR correctly")
25
+ end
26
+
27
+ def test_xor
28
+ assert_equal(@a ^ @b, 0xffff00000000ffff ^ 0xffff0000ffff0000, "GMP::Z should XOR correctly")
29
+ assert_equal(@a ^ @d, 0xffff00000000ffff ^ 0x1248, "GMP::Z should XOR correctly")
30
+ assert_equal(@a ^ @c, 0xffff00000000ffff ^ 0xff00ff00ff00ff00, "GMP::Z should XOR correctly")
31
+ assert_equal(@d ^ @a, 0x1248 ^ 0xffff00000000ffff, "GMP::Z should XOR correctly")
32
+ assert_equal(@c ^ @a, 0xff00ff00ff00ff00 ^ 0xffff00000000ffff, "GMP::Z should XOR correctly")
33
+ end
34
+
35
+ def test_com
36
+ assert_equal(GMP::Z().com, -1, "GMP::Z.com should complement")
37
+ assert_equal(GMP::Z(1).com, -2, "GMP::Z.com should complement")
38
+ assert_equal(GMP::Z(-1).com, 0, "GMP::Z.com should complement")
39
+ assert_equal(@a.com, -0xffff00000000ffff-1, "GMP::Z.com should complement")
40
+ end
41
+
42
+ def test_logic
43
+ a=GMP::Z.new(0x1234)
44
+ b=GMP::Z.new(a)
45
+ b[0]=true
46
+
47
+ assert_equal(a, 0x1234, "GMP::Z.new() should create a new copy, not alias")
48
+ assert_equal(b, 0x1235, "GMP::Z#[]= should modify bits")
49
+ assert_equal(a[2], true, "GMP::Z#[] should access bits")
50
+ assert_equal(a.scan0(0), 0, "GMP::Z#scan0 should scan for 0s")
51
+ assert_equal(a.scan1(0), 2, "GMP::Z#scan1 should scan for 1s")
52
+
53
+ end
54
+ end
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+
3
+ class TC_shifts_last_bits < Test::Unit::TestCase
4
+ def setup
5
+ @a = GMP::Z.new(100) # 01100100
6
+ @b =- @a # 10011100
7
+ end
8
+
9
+ def test_shifts
10
+ assert_equal( 3, @a >> 5, "GMP::Z should >> correctly.") # 00000011
11
+ assert_equal(- 4, @b >> 5, "GMP::Z should >> correctly.") # 11111100
12
+ assert_equal( 400, @a << 2, "GMP::Z should << correctly.") # 0110010000
13
+ assert_equal(-400, @b << 2, "GMP::Z should << correctly.") # 1110010000
14
+ end
15
+
16
+ def test_last_bits
17
+ #assert_equal( 5, @a.lastbits_pos(5), "GMP::Z should lastbits_pos correctly.") # 100
18
+ #assert_equal(28, @b.lastbits_pos(5), "GMP::Z should lastbits_pos correctly.") # 11100
19
+ #assert_equal(-4, @b.lastbits_sgn(5), "GMP::Z should lastbits_sgn correctly.")
20
+ # a.tshr 5 ???
21
+ end
22
+ end
@@ -0,0 +1,24 @@
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
@@ -0,0 +1,17 @@
1
+ class TC_ZeroDivisionExceptions < Test::Unit::TestCase
2
+ def setup
3
+ @a = GMP::Z.new(10)
4
+ @b = GMP::Z.new()
5
+ @c = GMP::Q.new(1)
6
+ @d = GMP::Q.new()
7
+ end
8
+
9
+ def test_division_by_zero
10
+ assert_raise(ZeroDivisionError) { @a.tdiv(0) }
11
+ assert_raise(ZeroDivisionError) { @a.tdiv(@b) }
12
+ assert_raise(ZeroDivisionError) { @d.inv }
13
+ assert_raise(ZeroDivisionError) { @d.inv! }
14
+ assert_raise(ZeroDivisionError) { @c/0 }
15
+ assert_raise(ZeroDivisionError) { @c/@d }
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gmp'
4
+
5
+ a=GMP::Q.new(200,11)
6
+ b=-a
7
+ c=a.floor
8
+ d=a.ceil
9
+ e=a.trunc
10
+ f=b.floor
11
+ g=b.ceil
12
+ h=b.trunc
13
+
14
+ [c,d,e,f,g,h].each { |var| p var }
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gmp'
4
+
5
+ a=GMP::Z.new(5)
6
+ b=GMP::Z.new(7)
7
+ c=GMP::Q.new(3,11)
8
+ d=GMP::F.new(3.14)
9
+ e=2**32
10
+
11
+ f=[a/b,a/3,3/a,a/c,c/a,a/d,d/a,a/e,e/a]
12
+
13
+ f.each {|var| p var}
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gmp'
4
+
5
+ a=GMP::F.new -1
6
+ b=GMP::F.new 0
7
+ c=GMP::F.new 0.1
8
+ d=GMP::F.new 1
9
+ e=GMP::F.new 2
10
+ f=GMP::F.new 4
11
+ g=GMP::F.new 10
12
+
13
+ print "exp:\n"
14
+ [a,b,c,d,e,f,g].map{|x| p x.exp}
15
+
16
+ print "log:\n"
17
+ [c,d,e,f,g].map{|x| p x.log}
18
+
19
+ print "log2:\n"
20
+ [c,d,e,f,g].map{|x| p x.log2}
21
+
22
+ print "log10:\n"
23
+ [c,d,e,f,g].map{|x| p x.log10}
24
+
25
+ print "log1p:\n"
26
+ [c,d,e,f,g].map{|x| p x.log1p}
27
+
28
+ print "expm1:\n"
29
+ [a,b,c,d,e,f,g].map{|x| p x.expm1}
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gmp'
4
+
5
+ pi = GMP::F.new(1).asin * 2
6
+
7
+ a = GMP::F.new 0
8
+ b = pi / 4
9
+ c = pi / 2
10
+ d = -pi / 2
11
+
12
+ print "cos:\n"
13
+ [a,b,c,d].map{|x| p x.cos}
14
+
15
+ print "sin:\n"
16
+ [a,b,c,d].map{|x| p x.sin}
17
+
18
+ print "tan:\n"
19
+ [a,b,c,d].map{|x| p x.tan}
20
+
21
+ print "cosh:\n"
22
+ [a,b,c,d].map{|x| p x.cosh}
23
+
24
+ print "sinh:\n"
25
+ [a,b,c,d].map{|x| p x.sinh}
26
+
27
+ print "tanh:\n"
28
+ [a,b,c,d].map{|x| p x.tanh}
29
+
30
+
31
+ print "inverses:\n"
32
+ [a,b,c,d].map{|x| p [x,x.cos.acos] }
33
+ [a,b,c,d].map{|x| p [x,x.sin.asin] }
34
+ [a,b,c,d].map{|x| p [x,x.tan.atan] }
35
+ [a,b,c,d].map{|x| p [x,x.cosh.acosh] }
36
+ [a,b,c,d].map{|x| p [x,x.sinh.asinh] }
37
+ [a,b,c,d].map{|x| p [x,x.tanh.atanh] }
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gmp'
4
+
5
+ a = GMP::F.new 0
6
+ b = GMP::F.new 1
7
+ c = b / a
8
+ d = -c
9
+ e = a * c
10
+
11
+ [a,b,c,d,e].map{|x| p [x, x.finite?, x.infinite?] }
12
+ [a,b,c,d,e].map{|x| p [x, x.number?, x.nan?] }
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gmp'
4
+
5
+ a = GMP::F.new 256
6
+ b = GMP::F.new 10
7
+ c = GMP::F.new 0.5
8
+
9
+ [a,b].map{|x| p x.sqrt }
10
+ [a,b].map{|x| p x ** c }
11
+
@@ -0,0 +1,8 @@
1
+ require 'test/unit'
2
+ require 'rbconfig'
3
+
4
+ ENV['PATH'] = [File.expand_path(
5
+ File.join(File.dirname(__FILE__), "..", "ext")
6
+ ), ENV['PATH']].compact.join(';') if RbConfig::CONFIG['host_os'] =~ /(mswin|mingw|mingw32)/i
7
+
8
+ require File.dirname(__FILE__) + '/../ext/gmp'
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test_helper'
4
+ require 'tc_z'
5
+ require 'tc_z_basic'
6
+ require 'tc_z_logic'
7
+ require 'tc_q'
8
+ require 'tc_cmp'
9
+ require 'tc_q_basic'
10
+ require 'tc_z_exponentiation'
11
+ require 'tc_zerodivisionexceptions'
12
+ require 'tc_sgn_neg_abs'
13
+ require 'tc_fib_fac_nextprime'
14
+ require 'tc_swap'
15
+ require 'tc_floor_ceil_truncate'
16
+ require 'tc_z_to_d_to_i'
17
+ require 'tc_z_shifts_last_bits'
18
+ require 'tc_logical_roots'
19
+ require 'tc_f_precision'
20
+ require 'tc_f_arithmetics_coersion'
21
+ require 'tc_division'
22
+ require 'tc_z_jac_leg_rem'
23
+ require 'tc_z_gcd_lcm_invert'
24
+ require 'tc_random'
25
+
26
+ class TC_default_prec < Test::Unit::TestCase
27
+ def test_default_prec
28
+ assert_equal( 64, GMP::F.default_prec, "GMP::F.default_prec should be 64.")
29
+ GMP::F.default_prec = 100
30
+ assert_equal(128, GMP::F.default_prec, "GMP::F.default_prec should be assignable.")
31
+ GMP::F.default_prec = 130
32
+ assert_equal(160, GMP::F.default_prec, "GMP::F.default_prec should be assignable.")
33
+ GMP::F.default_prec = 1000
34
+ assert_equal(1024, GMP::F.default_prec, "GMP::F.default_prec should be assignable.")
35
+ assert_raise(RangeError) { GMP::F.default_prec = -64 }
36
+ assert_raise(TypeError) { GMP::F.default_prec = "Cow" }
37
+ GMP::F.default_prec = 64
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gmp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: x86-mingw32
6
+ authors:
7
+ - Tomasz Wegrzanowski
8
+ - srawlins
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2010-01-03 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: gmp - providing Ruby bindings to the GMP library.
18
+ email:
19
+ - Tomasz.Wegrzanowski@gmail.com
20
+ - sam.rawlins@gmail.com
21
+ executables: []
22
+
23
+ extensions:
24
+ - ext/extconf.rb
25
+ extra_rdoc_files: []
26
+
27
+ files:
28
+ - ext/gmp.c
29
+ - ext/gmpbench_timing.c
30
+ - ext/gmpf.c
31
+ - ext/gmpq.c
32
+ - ext/gmprandstate.c
33
+ - ext/gmpz.c
34
+ - ext/gmpf.h
35
+ - ext/gmpq.h
36
+ - ext/gmpz.h
37
+ - ext/ruby_gmp.h
38
+ - ext/takeover.h
39
+ - ext/extconf.rb
40
+ - ext/libgmp-10.dll
41
+ - test/tc_cmp.rb
42
+ - test/tc_division.rb
43
+ - test/tc_fib_fac_nextprime.rb
44
+ - test/tc_floor_ceil_truncate.rb
45
+ - test/tc_f_arithmetics_coersion.rb
46
+ - test/tc_f_precision.rb
47
+ - test/tc_logical_roots.rb
48
+ - test/tc_q.rb
49
+ - test/tc_q_basic.rb
50
+ - test/tc_random.rb
51
+ - test/tc_sgn_neg_abs.rb
52
+ - test/tc_swap.rb
53
+ - test/tc_z.rb
54
+ - test/tc_zerodivisionexceptions.rb
55
+ - test/tc_z_basic.rb
56
+ - test/tc_z_exponentiation.rb
57
+ - test/tc_z_gcd_lcm_invert.rb
58
+ - test/tc_z_jac_leg_rem.rb
59
+ - test/tc_z_logic.rb
60
+ - test/tc_z_shifts_last_bits.rb
61
+ - test/tc_z_to_d_to_i.rb
62
+ - test/test-12.rb
63
+ - test/test-19.rb
64
+ - test/test-20.rb
65
+ - test/test-21.rb
66
+ - test/test-22.rb
67
+ - test/test-23.rb
68
+ - test/test_helper.rb
69
+ - test/unit_tests.rb
70
+ - test/README
71
+ - benchmark/COPYING
72
+ - benchmark/divide
73
+ - benchmark/gcd
74
+ - benchmark/gexpr
75
+ - benchmark/gexpr.c
76
+ - benchmark/multiply
77
+ - benchmark/README
78
+ - benchmark/rsa
79
+ - benchmark/runbench
80
+ - benchmark/version
81
+ - CHANGELOG
82
+ - INSTALL
83
+ - README.rdoc
84
+ - manual.pdf
85
+ - manual.tex
86
+ has_rdoc: true
87
+ homepage: http://github.com/srawlins/gmp
88
+ licenses: []
89
+
90
+ post_install_message:
91
+ rdoc_options: []
92
+
93
+ require_paths:
94
+ - ext
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 1.8.1
100
+ version:
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: "0"
106
+ version:
107
+ requirements:
108
+ - GMP compiled and working properly.
109
+ rubyforge_project:
110
+ rubygems_version: 1.3.5
111
+ signing_key:
112
+ specification_version: 3
113
+ summary: Provides Ruby bindings to the GMP library.
114
+ test_files: []
115
+