gmp 0.6.43 → 0.6.47

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,8 +5,8 @@ class TC_MPFR_Random < Test::Unit::TestCase
5
5
  end
6
6
 
7
7
  def test_urandomb
8
- @a = GMP::RandState.new
9
- @a.seed(577)
8
+ a = GMP::RandState.new
9
+ a.seed(577)
10
10
  if (GMP::MPFR_VERSION_MAJOR == 3 and GMP::MPFR_VERSION_MINOR < 1) or (GMP::MPFR_VERSION_MAJOR < 3)
11
11
  g1 = [
12
12
  GMP::F("0.39810885576093713"), GMP::F("0.97212443610368071"), GMP::F("0.23084385480845748"),
@@ -21,7 +21,67 @@ class TC_MPFR_Random < Test::Unit::TestCase
21
21
  ]
22
22
  end
23
23
  g1.size.times do |i|
24
- assert_in_delta(g1[i], @a.mpfr_urandomb, 1e-12, "GMP::RandState should mpfr_urandomb predictably.")
24
+ assert_in_delta(g1[i], a.mpfr_urandomb, 1e-12, "GMP::RandState should mpfr_urandomb predictably.")
25
+ end
26
+ end
27
+
28
+ def test_urandomb_with_prec
29
+ return unless GMP::MPFR_VERSION_MAJOR >= 3 and GMP::MPFR_VERSION_MINOR >= 1
30
+
31
+ a = GMP::RandState.new
32
+ a.seed(577)
33
+ g1 = [
34
+ GMP::F("0.74120618845", 32), GMP::F("0.39810885559", 32), GMP::F("0.70775037003", 32),
35
+ GMP::F("0.97212443594", 32), GMP::F("0.88489733171", 32), GMP::F("0.23084385460", 32),
36
+ GMP::F("0.25290360907", 32), GMP::F("0.29428636981", 32), GMP::F("0.85951062967", 32)
37
+ ]
38
+
39
+ g1.size.times do |i|
40
+ assert_in_delta(g1[i], a.mpfr_urandomb(32), 1e-12, "GMP::RandState should mpfr_urandomb with a precision predictably.")
41
+ end
42
+ end
43
+
44
+ def test_urandom
45
+ return unless GMP::MPFR_VERSION_MAJOR >= 3
46
+
47
+ a = GMP::RandState.new
48
+ a.seed(577)
49
+
50
+ g1 = [
51
+ GMP::F("0.48637900307389631"), GMP::F("0.94659148733322840"), GMP::F("0.27564210151536123"),
52
+ GMP::F("0.25908603728464119"), GMP::F("0.54208688851416087"), GMP::F("0.45824186569746128e-1"),
53
+ GMP::F("0.52706696601697367"), GMP::F("0.10260542184139945"), GMP::F("0.38678438390336384")
54
+ ]
55
+ g1.size.times do |i|
56
+ assert_in_delta(g1[i], a.mpfr_urandom, 1e-12, "GMP::RandState should mpfr_urandom predictably.")
57
+ end
58
+ end
59
+
60
+ def test_urandom_with_prec
61
+ return unless GMP::MPFR_VERSION_MAJOR >= 3
62
+
63
+ a = GMP::RandState.new
64
+ a.seed(577)
65
+
66
+ g1 = [
67
+ GMP::F("0.44905442791", 32), GMP::F("0.88489733171", 32), GMP::F("0.39714318502", 32),
68
+ GMP::F("0.19476944383", 32), GMP::F("0.30126355996", 32), GMP::F("0.22586148366", 32),
69
+ GMP::F("0.67203788180", 32), GMP::F("0.11863605876", 32), GMP::F("0.54191642837", 32)
70
+ ]
71
+ g1.size.times do |i|
72
+ assert_in_delta(g1[i], a.mpfr_urandom(GMP::GMP_RNDN, 32), 1e-12, "GMP::RandState should mpfr_urandom predictably.")
73
+ end
74
+
75
+ a = GMP::RandState.new
76
+ a.seed(577)
77
+
78
+ g2 = [
79
+ GMP::F("0.44905442779", 32), GMP::F("0.97212443594", 32), GMP::F("0.73084385460", 32),
80
+ GMP::F("0.39714318491", 32), GMP::F("0.38447714283", 32), GMP::F("0.86661665933e-1", 32),
81
+ GMP::F("0.30126355984", 32), GMP::F("0.53530920530", 32), GMP::F("0.60242124950", 32)
82
+ ]
83
+ g2.size.times do |i|
84
+ assert_in_delta(g2[i], a.mpfr_urandom(GMP::GMP_RNDZ, 32), 1e-12, "GMP::RandState should mpfr_urandom predictably.")
25
85
  end
26
86
  end
27
87
 
@@ -15,12 +15,12 @@ class TC_sgn_neg_abs < Test::Unit::TestCase
15
15
  @o=GMP::Q.new()
16
16
  @p=GMP::Q.new(-10)
17
17
  end
18
-
18
+
19
19
  def test_sgn
20
20
  assert_equal([1, 0, 1, 0], [@a.sgn, @b.sgn, @d.sgn, @e.sgn], "GMP::Z, GMP::Q should calculate sgn correctly")
21
21
  assert_equal([-1, -1], [@c.sgn, @f.sgn], "GMP::Z, GMP::Q should calculate sgn correctly")
22
22
  end
23
-
23
+
24
24
  def test_neg
25
25
  assert_equal(-@a, @c, "-(x : GMP::Z) should be calculated correctly.")
26
26
  assert_equal(-@c, @a, "-(x : GMP::Z) should be calculated correctly.")
@@ -36,7 +36,7 @@ class TC_sgn_neg_abs < Test::Unit::TestCase
36
36
  assert_equal(@o, @e, "(x : GMP::Q).neg! should be calculated correctly.")
37
37
  assert_equal(@p, @d, "GMP::Q.new().neg! should equal GMP::Q.new().")
38
38
  end
39
-
39
+
40
40
  def test_abs
41
41
  assert_equal([10, 0, 10], [@a.abs, @b.abs, @c.abs], "(x : GMP::Z).abs should be calculated correctly.")
42
42
  assert_equal([10, 0, 10], [@d.abs, @e.abs, @f.abs], "(x : GMP::Q).abs should be calculated correctly.")
@@ -3,8 +3,17 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'test_unit', 'asserti
3
3
  #require './test_unit/assertions' # Monkey patch
4
4
  require 'rbconfig'
5
5
 
6
- ENV['PATH'] = [File.expand_path(
7
- File.join(File.dirname(__FILE__), "..", "ext")
8
- ), ENV['PATH']].compact.join(';') if RbConfig::CONFIG['host_os'] =~ /(mswin|mingw|mingw32)/i
6
+ ENV['PATH'] = [
7
+ File.expand_path(File.join(File.dirname(__FILE__), "..", "ext")),
8
+ ENV['PATH']
9
+ ].compact.join(';') if RbConfig::CONFIG['host_os'] =~ /(mswin|mingw|mingw32)/i
9
10
 
10
11
  require File.dirname(__FILE__) + '/../lib/gmp'
12
+
13
+ if GMP.const_defined?(:MPFR_VERSION)
14
+ if GMP::MPFR_VERSION >= "3.0.0"
15
+ RND_MODES = [GMP::MPFR_RNDN, GMP::MPFR_RNDZ, GMP::MPFR_RNDU, GMP::MPFR_RNDD, GMP::MPFR_RNDA]
16
+ else
17
+ RND_MODES = [GMP::GMP_RNDN, GMP::GMP_RNDZ, GMP::GMP_RNDU, GMP::GMP_RNDD]
18
+ end
19
+ end
@@ -39,17 +39,21 @@ require File.join(DIR, 'gmp_tlcm')
39
39
  require File.join(DIR, 'gmp_tprintf')
40
40
  require File.join(DIR, 'gmp_troot')
41
41
 
42
- begin
43
- GMP::MPFR_VERSION
42
+ if GMP.const_defined? :MPFR_VERSION
43
+ require File.join(DIR, 'tc_mpfr_cmp')
44
44
  require File.join(DIR, 'tc_mpfr_constants')
45
+ require File.join(DIR, 'tc_mpfr_inf_nan_zero')
45
46
  require File.join(DIR, 'tc_mpfr_integer')
46
47
  require File.join(DIR, 'tc_mpfr_random')
47
48
  require File.join(DIR, 'tc_mpfr_functions')
48
49
  require File.join(DIR, 'tc_mpfr_rounding')
50
+ require File.join(DIR, 'tc_mpfr_new_rounding')
49
51
  require File.join(DIR, 'mpfr_tcbrt')
52
+ require File.join(DIR, 'mpfr_tfac')
53
+ if GMP::MPFR_VERSION >= "3.1.0"
54
+ require File.join(DIR, 'mpfr_tfrexp')
55
+ end
50
56
  require File.join(DIR, 'mpfr_tisnan')
51
57
  require File.join(DIR, 'mpfr_trec_sqrt')
52
58
  require File.join(DIR, 'mpfr_tsqrt')
53
- rescue
54
-
55
59
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.43
4
+ version: 0.6.47
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-11-06 00:00:00.000000000 Z
13
+ date: 2013-12-31 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: gmp - providing Ruby bindings to the GMP library.
16
16
  email:
@@ -43,12 +43,15 @@ files:
43
43
  - test/gmp_troot.rb
44
44
  - test/mpfr_tcbrt.rb
45
45
  - test/mpfr_tconst_euler.rb
46
+ - test/mpfr_tfac.rb
47
+ - test/mpfr_tfrexp.rb
46
48
  - test/mpfr_tisnan.rb
47
49
  - test/mpfr_trec_sqrt.rb
48
50
  - test/mpfr_tsqrt.rb
49
51
  - test/tc_cmp.rb
50
52
  - test/tc_constants.rb
51
53
  - test/tc_division.rb
54
+ - test/tc_f_abs_neg.rb
52
55
  - test/tc_f_arithmetics_coersion.rb
53
56
  - test/tc_f_precision.rb
54
57
  - test/tc_f_to_s.rb
@@ -56,9 +59,12 @@ files:
56
59
  - test/tc_floor_ceil_truncate.rb
57
60
  - test/tc_hashes.rb
58
61
  - test/tc_logical_roots.rb
62
+ - test/tc_mpfr_cmp.rb
59
63
  - test/tc_mpfr_constants.rb
60
64
  - test/tc_mpfr_functions.rb
65
+ - test/tc_mpfr_inf_nan_zero.rb
61
66
  - test/tc_mpfr_integer.rb
67
+ - test/tc_mpfr_new_rounding.rb
62
68
  - test/tc_mpfr_random.rb
63
69
  - test/tc_mpfr_rounding.rb
64
70
  - test/tc_q.rb
@@ -127,8 +133,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
133
  requirements:
128
134
  - GMP compiled and working properly.
129
135
  rubyforge_project:
130
- rubygems_version: 1.8.25
136
+ rubygems_version: 1.8.24
131
137
  signing_key:
132
138
  specification_version: 3
133
139
  summary: Provides Ruby bindings to the GMP library.
134
140
  test_files: []
141
+ has_rdoc: yard