gmp 0.4.3-x86-mingw32 → 0.4.7-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/test/mpfr_tsqrt.rb CHANGED
@@ -19,24 +19,52 @@ class MPFR_TSQRT < Test::Unit::TestCase
19
19
  assert_equal(integer_component(q), qs)
20
20
  end
21
21
 
22
+ def special
23
+ x = GMP::F(0b1010000010100011011001010101010010001100001101011101110001011001 / 2, 64) # Ruby 0b does not support e,
24
+ y = x.sqrt(GMP::GMP_RNDN, 32) # ie 0b11e-2 = 0.75 doesnt work
25
+ #assert_equal(2405743844, y, "Error for n^2+n+1/2 with n=2405743843") # Pending
26
+
27
+ x = GMP::F(0b10100000101000110110010101010100100011000011010111011100010110001 / 4, 65)
28
+ y = x.sqrt(GMP::GMP_RNDN, 32)
29
+ #assert_equal(2405743844, y, "Error for n^2+n+1/4 with n=2405743843") # Pending
30
+
31
+ x = GMP::F(0b101000001010001101100101010101001000110000110101110111000101100011 / 8, 66)
32
+ y = x.sqrt(GMP::GMP_RNDN, 32)
33
+ #assert_equal(2405743844, y, "Error for n^2+n+1/4+1/8 with n=2405743843") # Pending
34
+
35
+ x = GMP::F(0b101000001010001101100101010101001000110000110101110111000101100001 / 8, 66)
36
+ y = x.sqrt(GMP::GMP_RNDN, 32)
37
+ assert_equal(2405743843, y, "Error for n^2+n+1/8 with n=2405743843")
38
+
39
+ #####
40
+ ##### Inexact flag test. Not implemented.
41
+
42
+ #####
43
+ ##### Test uses mpfr_nexttoinf. Not implemented.
44
+
45
+ # Not an accurate test at all. Reassigning z generates a new mpfr object.
46
+ x = GMP::F(1)
47
+ z = GMP::F(-1)
48
+ z = x.sqrt(GMP::GMP_RNDN)
49
+
50
+ # z = GMP::F(0.1011010100000100100100100110011001011100100100000011000111011001011101101101110000110100001000100001100001011000E1, 160)
51
+ # x = z.sqrt
52
+ # z = x.sqrt
53
+ # x.prec = 53
54
+ end
55
+
22
56
  def property1(p, rounding)
23
- current_rounding_mode = GMP::F.default_rounding_mode
24
- GMP::F.default_rounding_mode = rounding
25
57
  x = @rand_state.mpfr_urandomb(p)
26
58
  y = @rand_state.mpfr_urandomb(p)
27
59
  z = x**2 + y**2
28
- z = x / z.sqrt
60
+ z = x / z.sqrt(rounding)
29
61
  assert_between(-1, 1, z, "-1 <= x/sqrt(x^2+y^2) <= 1 should hold.")
30
- GMP::F.default_rounding_mode = GMP.const_get(current_rounding_mode)
31
62
  end
32
63
 
33
64
  def property2(p, rounding)
34
- current_rounding_mode = GMP::F.default_rounding_mode
35
- GMP::F.default_rounding_mode = rounding
36
65
  x = @rand_state.mpfr_urandomb(p)
37
- y = (x ** 2).sqrt
66
+ y = (x ** 2).sqrt(rounding)
38
67
  assert_true(x == y, "sqrt(x^2) = x should hold.")
39
- GMP::F.default_rounding_mode = GMP.const_get(current_rounding_mode)
40
68
  end
41
69
 
42
70
  def test_prec
@@ -49,5 +77,6 @@ class MPFR_TSQRT < Test::Unit::TestCase
49
77
  check_diverse("635030154261163106768013773815762607450069292760790610550915652722277604820131530404842415587328",
50
78
  160,
51
79
  "796887792767063979679855997149887366668464780637")
80
+ special
52
81
  end
53
82
  end
data/test/tc_hashes.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+
3
+ class TC_Hashes < Test::Unit::TestCase
4
+ def setup
5
+ end
6
+
7
+ def test_z_hashes
8
+ h = {}
9
+ h[GMP::Z(131)] = [GMP::Z(41), GMP::Z(43), GMP::Z(47)]
10
+ assert(h[GMP::Z(131)] != nil, "Newly created GMP::Zs should hash equally if they are equal.")
11
+ assert(h[GMP::Z(59)].nil?, "Newly created GMP::Zs should hash differently if they are different.")
12
+ 10.times do
13
+ assert(GMP::Z(73).hash == GMP::Z(73).hash)
14
+ end
15
+
16
+ 100.times do |i|
17
+ assert(GMP::Z(101).hash != GMP::Z(i).hash)
18
+ end
19
+
20
+ # GMP::Z(5) and "5" might (I think, 'do') hash the same, but should not be equal
21
+ assert(! GMP::Z(101).eql?("101"))
22
+
23
+ h["127"] = "String"
24
+ h[GMP::Z(127)] = "GMP::Z"
25
+ assert(h["127"] != "GMP::Z")
26
+ assert(h[GMP::Z(127)] != "String")
27
+ assert(h[GMP::Z(127)] == "GMP::Z")
28
+ assert(h["127"] == "String")
29
+ end
30
+ end
@@ -19,7 +19,8 @@ class TC_MPFR_Functions < Test::Unit::TestCase
19
19
  assert_nothing_raised("GMP::F.log2 should be callable.") { @a.log2 }
20
20
  assert_nothing_raised("GMP::F.log10 should be callable.") { @a.log10 }
21
21
  assert_nothing_raised("GMP::F.exp should be callable.") { @a.exp }
22
-
22
+ assert_nothing_raised("GMP::F.exp2 should be callable.") { @a.exp2 }
23
+ assert_nothing_raised("GMP::F.exp10 should be callable.") { @a.exp10 }
23
24
  assert_nothing_raised("GMP::F.cos should be callable.") { @a.cos }
24
25
  assert_nothing_raised("GMP::F.sin should be callable.") { @a.sin }
25
26
  assert_nothing_raised("GMP::F.tan should be callable.") { @a.tan }
@@ -34,12 +35,54 @@ class TC_MPFR_Functions < Test::Unit::TestCase
34
35
  assert_nothing_raised("GMP::F.cosh should be callable.") { @a.cosh }
35
36
  assert_nothing_raised("GMP::F.sinh should be callable.") { @a.sinh }
36
37
  assert_nothing_raised("GMP::F.tanh should be callable.") { @a.tanh }
37
-
38
+
39
+ assert_nothing_raised("GMP::F.sech should be callable.") { @a.sech }
40
+ assert_nothing_raised("GMP::F.csch should be callable.") { @a.csch }
41
+ assert_nothing_raised("GMP::F.coth should be callable.") { @a.coth }
38
42
  assert_nothing_raised("GMP::F.acosh should be callable.") { @a.acosh }
39
43
  assert_nothing_raised("GMP::F.asinh should be callable.") { @a.asinh }
40
44
  assert_nothing_raised("GMP::F.atanh should be callable.") { @a.atanh }
41
45
 
42
46
  assert_nothing_raised("GMP::F.log1p should be callable.") { @a.log1p }
43
47
  assert_nothing_raised("GMP::F.expm1 should be callable.") { @a.expm1 }
48
+ assert_nothing_raised("GMP::F.eint should be callable.") { @a.eint }
49
+ assert_nothing_raised("GMP::F.li2 should be callable.") { @a.li2 }
50
+ assert_nothing_raised("GMP::F.gamma should be callable.") { @a.gamma }
51
+ assert_nothing_raised("GMP::F.lngamma should be callable.") { @a.lngamma }
52
+ #assert_nothing_raised("GMP::F.lgamma should be callable.") { @a.lgamma }
53
+ assert_nothing_raised("GMP::F.zeta should be callable.") { @a.zeta }
54
+ assert_nothing_raised("GMP::F.erf should be callable.") { @a.erf }
55
+ assert_nothing_raised("GMP::F.erfc should be callable.") { @a.erfc }
56
+ assert_nothing_raised("GMP::F.j0 should be callable.") { @a.j0 }
57
+ assert_nothing_raised("GMP::F.j1 should be callable.") { @a.j1 }
58
+ assert_nothing_raised("GMP::F.jn should be callable.") { @a.jn(-1) }
59
+ assert_nothing_raised("GMP::F.jn should be callable.") { @a.jn(0) }
60
+ assert_nothing_raised("GMP::F.jn should be callable.") { @a.jn(1) }
61
+ assert_nothing_raised("GMP::F.jn should be callable.") { @a.jn(2) }
62
+ assert_nothing_raised("GMP::F.y0 should be callable.") { @a.y0 }
63
+ assert_nothing_raised("GMP::F.y1 should be callable.") { @a.y1 }
64
+ assert_nothing_raised("GMP::F.yn should be callable.") { @a.yn(-1) }
65
+ assert_nothing_raised("GMP::F.yn should be callable.") { @a.yn(0) }
66
+ assert_nothing_raised("GMP::F.yn should be callable.") { @a.yn(1) }
67
+ assert_nothing_raised("GMP::F.yn should be callable.") { @a.yn(2) }
68
+ end
69
+
70
+ def test_function_parameters
71
+ functions = [:sqrt, :log, :log2, :log10, :exp, :exp2, :exp10,
72
+ :cos, :sin, :tan, :sec, :csc, :cot, :acos, :asin, :atan,
73
+ :cosh, :sinh, :tanh, :sech, :csch, :coth,
74
+ :acosh, :asinh, :atanh,
75
+ :log1p, :expm1, :eint, :li2, :gamma, :lngamma,
76
+ :zeta, :erf, :erfc,
77
+ :j0, :j1, :y0, :y1
78
+ ]
79
+
80
+ functions.each do |f|
81
+ assert_nothing_raised("GMP::F.#{f} can be called with 1 argument, the rounding_mode.") { @a.send(f, GMP::GMP_RNDN) }
82
+ assert_nothing_raised("GMP::F.#{f} can be called with 1 argument, the rounding_mode.") { @a.send(f, GMP::GMP_RNDZ) }
83
+ assert_nothing_raised("GMP::F.#{f} can be called with 2 args, rounding_mode, prec.") { @a.send(f, GMP::GMP_RNDN, 32) }
84
+ assert_nothing_raised("GMP::F.#{f} can be called with 2 args, rounding_mode, prec.") { @a.send(f, GMP::GMP_RNDN, 128) }
85
+ assert_nothing_raised("GMP::F.#{f} can be called with 2 args, rounding_mode, prec.") { @a.send(f, GMP::GMP_RNDN, 200) }
86
+ end
44
87
  end
45
88
  end
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ class TC_MPFR_Rounding < Test::Unit::TestCase
4
+ def setup
5
+ end
6
+
7
+ def test_rounding_mode
8
+ assert_equal(0, GMP::GMP_RNDN.mode, "GMP::Rnd.mode should be correct.")
9
+ assert_equal(1, GMP::GMP_RNDZ.mode, "GMP::Rnd.mode should be correct.")
10
+ assert_equal(2, GMP::GMP_RNDU.mode, "GMP::Rnd.mode should be correct.")
11
+ assert_equal(3, GMP::GMP_RNDD.mode, "GMP::Rnd.mode should be correct.")
12
+ end
13
+
14
+ def test_rounding_name
15
+ assert_equal("GMP_RNDN", GMP::GMP_RNDN.name, "GMP::Rnd.name should be correct.")
16
+ assert_equal("GMP_RNDZ", GMP::GMP_RNDZ.name, "GMP::Rnd.name should be correct.")
17
+ assert_equal("GMP_RNDU", GMP::GMP_RNDU.name, "GMP::Rnd.name should be correct.")
18
+ assert_equal("GMP_RNDD", GMP::GMP_RNDD.name, "GMP::Rnd.name should be correct.")
19
+ end
20
+
21
+ def test_rounding_ieee754
22
+ assert_equal("roundTiesToEven", GMP::GMP_RNDN.ieee754, "GMP::Rnd.ieee754 should be correct.")
23
+ assert_equal("roundTowardZero", GMP::GMP_RNDZ.ieee754, "GMP::Rnd.ieee754 should be correct.")
24
+ assert_equal("roundTowardPositive", GMP::GMP_RNDU.ieee754, "GMP::Rnd.ieee754 should be correct.")
25
+ assert_equal("roundTowardNegative", GMP::GMP_RNDD.ieee754, "GMP::Rnd.ieee754 should be correct.")
26
+ end
27
+ end
data/test/tc_q.rb CHANGED
@@ -24,4 +24,16 @@ class TC_Q < Test::Unit::TestCase
24
24
  a = GMP::Q.new(1,2)
25
25
  assert_equal(GMP::Q.new(a), a, "GMP::Q.new(x : Q) should initialize to x")
26
26
  end
27
+
28
+ def test_to_s
29
+ assert_equal("1/2", GMP::Q(1,2).to_s, "GMP::Q should to_s properly.")
30
+ assert_equal("1/4294967296", GMP::Q(1,2**32).to_s, "GMP::Q should to_s properly.")
31
+ assert_equal("1/4294967296", GMP::Q(1,2**32).to_s, "GMP::Q should to_s properly.")
32
+ assert_equal("-22/7", GMP::Q(-22,7).to_s, "GMP::Q should to_s properly.")
33
+ assert_equal("-22/7", GMP::Q(22,-7).to_s, "GMP::Q should to_s properly.")
34
+ assert_equal("22/7", GMP::Q(-22,-7).to_s, "GMP::Q should to_s properly.")
35
+ assert_equal("0", GMP::Q(0,1).to_s, "GMP::Q should to_s properly.")
36
+ assert_equal("0", GMP::Q(0,2000).to_s, "GMP::Q should to_s properly.")
37
+ assert_equal("0", GMP::Q(0,-2000).to_s, "GMP::Q should to_s properly.")
38
+ end
27
39
  end
data/test/test_helper.rb CHANGED
@@ -6,4 +6,4 @@ ENV['PATH'] = [File.expand_path(
6
6
  File.join(File.dirname(__FILE__), "..", "ext")
7
7
  ), ENV['PATH']].compact.join(';') if RbConfig::CONFIG['host_os'] =~ /(mswin|mingw|mingw32)/i
8
8
 
9
- require File.dirname(__FILE__) + '/../ext/gmp'
9
+ require File.dirname(__FILE__) + '/../ext/gmp'
data/test/unit_tests.rb CHANGED
@@ -23,11 +23,13 @@ require 'tc_division'
23
23
  require 'tc_z_jac_leg_rem'
24
24
  require 'tc_z_gcd_lcm_invert'
25
25
  require 'tc_random'
26
+ require 'tc_hashes'
26
27
 
27
28
  begin
28
29
  GMP::MPFR_VERSION
29
30
  require 'tc_mpfr_random'
30
31
  require 'tc_mpfr_functions'
32
+ require 'tc_mpfr_rounding'
31
33
  require 'mpfr_tsqrt'
32
34
  rescue
33
35
 
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.4.3
4
+ version: 0.4.7
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Tomasz Wegrzanowski
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-03-08 00:00:00 -07:00
13
+ date: 2010-03-25 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -31,9 +31,11 @@ files:
31
31
  - ext/gmpq.c
32
32
  - ext/gmprandstate.c
33
33
  - ext/gmpz.c
34
+ - ext/mprnd.c
34
35
  - ext/gmpf.h
35
36
  - ext/gmpq.h
36
37
  - ext/gmpz.h
38
+ - ext/mprnd.h
37
39
  - ext/ruby_gmp.h
38
40
  - ext/takeover.h
39
41
  - ext/extconf.rb
@@ -47,9 +49,11 @@ files:
47
49
  - test/tc_floor_ceil_truncate.rb
48
50
  - test/tc_f_arithmetics_coersion.rb
49
51
  - test/tc_f_precision.rb
52
+ - test/tc_hashes.rb
50
53
  - test/tc_logical_roots.rb
51
54
  - test/tc_mpfr_functions.rb
52
55
  - test/tc_mpfr_random.rb
56
+ - test/tc_mpfr_rounding.rb
53
57
  - test/tc_q.rb
54
58
  - test/tc_q_basic.rb
55
59
  - test/tc_random.rb