gmp 0.7.19 → 0.7.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +7 -0
- data/README.html +1 -1
- data/README.markdown +4 -2
- data/ext/gmp.c +6 -0
- data/ext/gmpz.c +23 -27
- data/ext/takeover.h +28 -0
- data/test/gmp_tcong.rb +1 -1
- data/test/gmp_tgcd.rb +1 -1
- data/test/gmp_tlcm.rb +1 -1
- data/test/gmp_tprintf.rb +1 -1
- data/test/gmp_troot.rb +1 -1
- data/test/mpfr_tcbrt.rb +1 -1
- data/test/mpfr_tconst_euler.rb +1 -1
- data/test/mpfr_tfac.rb +1 -1
- data/test/mpfr_tfrexp.rb +1 -1
- data/test/mpfr_thypot.rb +1 -1
- data/test/mpfr_tisnan.rb +1 -1
- data/test/mpfr_trec_sqrt.rb +1 -1
- data/test/mpfr_tsqrt.rb +1 -1
- data/test/tc_cmp.rb +2 -7
- data/test/tc_constants.rb +5 -5
- data/test/tc_division.rb +1 -1
- data/test/tc_f_abs_neg.rb +1 -1
- data/test/tc_f_arithmetics_coersion.rb +1 -1
- data/test/tc_f_precision.rb +1 -1
- data/test/tc_f_to_s.rb +1 -1
- data/test/tc_hashes.rb +1 -1
- data/test/tc_mpfr_cmp.rb +1 -1
- data/test/tc_mpfr_constants.rb +3 -3
- data/test/tc_mpfr_functions.rb +1 -1
- data/test/tc_mpfr_inf_nan_zero.rb +1 -1
- data/test/tc_mpfr_integer.rb +1 -1
- data/test/tc_mpfr_new_rounding.rb +1 -1
- data/test/tc_mpfr_pow.rb +1 -1
- data/test/tc_mpfr_random.rb +1 -1
- data/test/tc_mpfr_rounding.rb +1 -1
- data/test/tc_q.rb +1 -1
- data/test/tc_q_basic.rb +1 -1
- data/test/tc_q_floor_ceil_truncate.rb +1 -1
- data/test/tc_q_num_den.rb +1 -1
- data/test/tc_random.rb +1 -1
- data/test/tc_sgn_neg_abs.rb +1 -1
- data/test/tc_swap.rb +1 -1
- data/test/tc_z.rb +11 -1
- data/test/tc_z_addmul.rb +22 -34
- data/test/tc_z_basic.rb +1 -1
- data/test/tc_z_exponentiation.rb +1 -1
- data/test/tc_z_export_import.rb +1 -1
- data/test/tc_z_fib_fac_nextprime.rb +1 -1
- data/test/tc_z_functional_mappings.rb +1 -2
- data/test/tc_z_gcd_lcm_invert.rb +1 -1
- data/test/tc_z_hamdist.rb +1 -1
- data/test/tc_z_io.rb +1 -1
- data/test/tc_z_jac_leg_rem.rb +1 -1
- data/test/tc_z_logic.rb +1 -1
- data/test/tc_z_logical_roots.rb +1 -1
- data/test/tc_z_shifts_last_bits.rb +1 -1
- data/test/tc_z_submul.rb +22 -34
- data/test/tc_z_to_dis.rb +2 -2
- data/test/tc_zero_division_exceptions.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/test_unit/assertions.rb +7 -1
- metadata +26 -27
- data/benchmark/results-5.1.3_0.6.31.ods +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 739852359b6a3c45c737d9022c26711df7b9874e
|
4
|
+
data.tar.gz: 8c7d353563c3dd3f307d53d7e14b85e360d029f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3e76263abeea499f05572d76b473010a24a24a2707d7784a52cb73808c782da0c81917d867cddc09150862d1e79f399d182f30d7112df2b6c16cdaab504b943
|
7
|
+
data.tar.gz: 708ff9eb5fa093d178e65e475740a5b38a4aa82c89a3813ea14b4d307da23fca103e4a1f6f707865e839c03d59d71dfddc7d82d5ff6c6ac1eaa6d33b950c0431
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
0.7.43
|
2
|
+
* Tests now use MiniTest
|
3
|
+
* Ruby 2.4 and the new Integer class (replacement for Fixnum and Bignum) are
|
4
|
+
* now supported (thanks @timocp).
|
5
|
+
* GMP::Z can now be initialized from a Float or GMP::F, as well as the
|
6
|
+
existing Fixnum, Bignum, Integer, GMP::Z, and String.
|
7
|
+
|
1
8
|
0.7.19
|
2
9
|
* GMP::Q.new can now accept a GMP::Z or Fixnum more intelligently, and can
|
3
10
|
accept a Float, and is tested better.
|
data/README.html
CHANGED
@@ -230,7 +230,7 @@ GMP.RandState()
|
|
230
230
|
asb! in-place absolute value
|
231
231
|
coerce promotion of arguments
|
232
232
|
== equality test
|
233
|
-
<=>,>=,>,<=,<
|
233
|
+
<=>,>=,>,<=,< comparisons
|
234
234
|
class methods of GMP::Z
|
235
235
|
fac(n) factorial of n
|
236
236
|
2fac(n), double_fac(n) double factorial of n
|
data/README.markdown
CHANGED
@@ -195,9 +195,11 @@ The GMP module is provided with following classes:
|
|
195
195
|
Numbers are created by using `new()`. Constructors can take following arguments:
|
196
196
|
|
197
197
|
GMP::Z.new()
|
198
|
-
GMP::Z.new(GMP::Z)
|
199
198
|
GMP::Z.new(Fixnum)
|
200
199
|
GMP::Z.new(Bignum)
|
200
|
+
GMP::Z.new(GMP::Z)
|
201
|
+
GMP::Z.new(Float)
|
202
|
+
GMP::Z.new(GMP::F)
|
201
203
|
GMP::Z.new(String)
|
202
204
|
GMP::Q.new()
|
203
205
|
GMP::Q.new(Fixnum)
|
@@ -249,7 +251,7 @@ Methods
|
|
249
251
|
abs! in-place absolute value
|
250
252
|
coerce promotion of arguments
|
251
253
|
== equality test
|
252
|
-
<=>, >=, >, <=, <
|
254
|
+
<=>, >=, >, <=, < comparisons
|
253
255
|
class methods of GMP::Z
|
254
256
|
fac(n) factorial of n
|
255
257
|
2fac(n), double_fac(n) double factorial of n
|
data/ext/gmp.c
CHANGED
@@ -161,11 +161,17 @@ mp_rnd_t r_get_rounding_mode(VALUE rnd)
|
|
161
161
|
/* #include "gmpz.h" */
|
162
162
|
#include "takeover.h"
|
163
163
|
|
164
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
165
|
+
#define REGISTER_TAKEOVER(fname, ruby_fname, old_fname) \
|
166
|
+
rb_define_alias(rb_cInteger, old_fname, ruby_fname); \
|
167
|
+
rb_define_method(rb_cInteger, ruby_fname, takeover_integer_##fname, -1);
|
168
|
+
#else
|
164
169
|
#define REGISTER_TAKEOVER(fname, ruby_fname, old_fname) \
|
165
170
|
rb_define_alias(rb_cFixnum, old_fname, ruby_fname); \
|
166
171
|
rb_define_method(rb_cFixnum, ruby_fname, takeover_fixnum_##fname, -1); \
|
167
172
|
rb_define_alias(rb_cBignum, old_fname, ruby_fname); \
|
168
173
|
rb_define_method(rb_cBignum, ruby_fname, takeover_bignum_##fname, -1);
|
174
|
+
#endif /* RUBY_INTEGER_UNIFICATION */
|
169
175
|
|
170
176
|
void Init_gmp() {
|
171
177
|
bin_base_id = rb_intern("bin");
|
data/ext/gmpz.c
CHANGED
@@ -745,21 +745,27 @@ static VALUE r_gmpz_initialize_copy(VALUE copy_val, VALUE orig_val) {
|
|
745
745
|
* * String
|
746
746
|
* * Bignum
|
747
747
|
*/
|
748
|
-
void mpz_set_value(MP_INT *target, VALUE
|
748
|
+
void mpz_set_value(MP_INT *target, VALUE source_val, int base)
|
749
749
|
{
|
750
|
-
MP_INT *
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
750
|
+
MP_INT *source_z;
|
751
|
+
MP_FLOAT *source_f;
|
752
|
+
|
753
|
+
if (GMPZ_P (source_val)) {
|
754
|
+
mpz_get_struct (source_val, source_z);
|
755
|
+
mpz_set (target, source_z);
|
756
|
+
} else if (TYPE (source_val) == T_FIXNUM) {
|
757
|
+
mpz_set_si (target, FIX2NUM (source_val));
|
758
|
+
} else if (STRING_P (source_val)) {
|
759
|
+
mpz_set_str (target, StringValuePtr (source_val), base);
|
760
|
+
} else if (BIGNUM_P (source_val)) {
|
761
|
+
mpz_set_bignum (target, source_val);
|
762
|
+
} else if (FLOAT_P (source_val)) {
|
763
|
+
mpz_set_d (target, NUM2DBL (source_val));
|
764
|
+
} else if (GMPF_P (source_val)) {
|
765
|
+
mpf_get_struct (source_val, source_f);
|
766
|
+
mpz_set_f (target, source_f);
|
761
767
|
} else {
|
762
|
-
rb_raise (rb_eTypeError, "Don't know how to convert %s into GMP::Z", rb_class2name (rb_class_of (
|
768
|
+
rb_raise (rb_eTypeError, "Don't know how to convert %s into GMP::Z", rb_class2name (rb_class_of (source_val)));
|
763
769
|
}
|
764
770
|
}
|
765
771
|
|
@@ -1171,14 +1177,9 @@ static VALUE r_gmpz_addmul_self(VALUE self, VALUE b, VALUE c)
|
|
1171
1177
|
if (GMPZ_P (c)) {
|
1172
1178
|
mpz_get_struct (c, c_val);
|
1173
1179
|
mpz_addmul (self_val, b_val, c_val);
|
1174
|
-
} else if (
|
1175
|
-
if (FIX2NUM (c) < 0)
|
1176
|
-
{
|
1177
|
-
if (free_b_val) { mpz_temp_free (b_val); }
|
1178
|
-
rb_raise (rb_eRangeError, "multiplicand (Fixnum) must be nonnegative");
|
1179
|
-
}
|
1180
|
+
} else if (FIXNUM_P (c) && FIX2NUM (c) >= 0) {
|
1180
1181
|
mpz_addmul_ui (self_val, b_val, FIX2NUM (c));
|
1181
|
-
} else if (BIGNUM_P (c)) {
|
1182
|
+
} else if (FIXNUM_P (c) || BIGNUM_P (c)) {
|
1182
1183
|
mpz_temp_from_bignum (c_val, c);
|
1183
1184
|
mpz_addmul (self_val, b_val, c_val);
|
1184
1185
|
mpz_temp_free (c_val);
|
@@ -1226,14 +1227,9 @@ static VALUE r_gmpz_submul_self(VALUE self, VALUE b, VALUE c)
|
|
1226
1227
|
if (GMPZ_P (c)) {
|
1227
1228
|
mpz_get_struct (c, c_val);
|
1228
1229
|
mpz_submul (self_val, b_val, c_val);
|
1229
|
-
} else if (
|
1230
|
-
if (FIX2NUM (c) < 0)
|
1231
|
-
{
|
1232
|
-
if (free_b_val) { mpz_temp_free (b_val); }
|
1233
|
-
rb_raise (rb_eRangeError, "multiplicand (Fixnum) must be nonnegative");
|
1234
|
-
}
|
1230
|
+
} else if (FIXNUM_P (c) && FIX2NUM (c) >= 0) {
|
1235
1231
|
mpz_submul_ui (self_val, b_val, FIX2NUM (c));
|
1236
|
-
} else if (BIGNUM_P (c)) {
|
1232
|
+
} else if (FIXNUM_P (c) || BIGNUM_P (c)) {
|
1237
1233
|
mpz_temp_from_bignum (c_val, c);
|
1238
1234
|
mpz_submul (self_val, b_val, c_val);
|
1239
1235
|
mpz_temp_free (c_val);
|
data/ext/takeover.h
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
2
|
+
|
3
|
+
#define DEFUN_TAKEOVER_LOGIC(fname, mpz_fname, old_fname) \
|
4
|
+
static VALUE takeover_integer_##fname(int argc, VALUE *argv, VALUE self) \
|
5
|
+
{ \
|
6
|
+
MP_INT *res_val, *arg_val; \
|
7
|
+
VALUE res; \
|
8
|
+
\
|
9
|
+
if (argc != 1 || !GMPZ_P(argv[0])) { \
|
10
|
+
return rb_funcall2 (self, rb_intern (old_fname), argc, argv); \
|
11
|
+
} else { \
|
12
|
+
mpz_get_struct(argv[0], arg_val); \
|
13
|
+
if (FIXNUM_P(self)) { \
|
14
|
+
mpz_make_struct(res, res_val); \
|
15
|
+
mpz_init_set_si (res_val, FIX2INT(self)); \
|
16
|
+
} else { \
|
17
|
+
mpz_make_struct_init(res, res_val); \
|
18
|
+
mpz_set_bignum (res_val, self); \
|
19
|
+
} \
|
20
|
+
mpz_fname (res_val, res_val, arg_val); \
|
21
|
+
return res; \
|
22
|
+
} \
|
23
|
+
}
|
24
|
+
|
25
|
+
#else
|
26
|
+
|
1
27
|
#define DEFUN_TAKEOVER_LOGIC(fname, mpz_fname, old_fname) \
|
2
28
|
static VALUE takeover_fixnum_##fname(int argc, VALUE *argv, VALUE self) \
|
3
29
|
{ \
|
@@ -31,6 +57,8 @@ static VALUE takeover_bignum_##fname(int argc, VALUE *argv, VALUE self) \
|
|
31
57
|
} \
|
32
58
|
}
|
33
59
|
|
60
|
+
#endif /* RUBY_INTEGER_UNIFICATION */
|
61
|
+
|
34
62
|
DEFUN_TAKEOVER_LOGIC(and, mpz_and, "old_and")
|
35
63
|
DEFUN_TAKEOVER_LOGIC(or, mpz_ior, "old_or")
|
36
64
|
DEFUN_TAKEOVER_LOGIC(xor, mpz_xor, "old_xor")
|
data/test/gmp_tcong.rb
CHANGED
data/test/gmp_tgcd.rb
CHANGED
data/test/gmp_tlcm.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
2
2
|
|
3
|
-
class GMP_TLCM < Test
|
3
|
+
class GMP_TLCM < MiniTest::Test
|
4
4
|
Primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
|
5
5
|
101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,
|
6
6
|
191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,
|
data/test/gmp_tprintf.rb
CHANGED
data/test/gmp_troot.rb
CHANGED
data/test/mpfr_tcbrt.rb
CHANGED
data/test/mpfr_tconst_euler.rb
CHANGED
data/test/mpfr_tfac.rb
CHANGED
data/test/mpfr_tfrexp.rb
CHANGED
data/test/mpfr_thypot.rb
CHANGED
data/test/mpfr_tisnan.rb
CHANGED
data/test/mpfr_trec_sqrt.rb
CHANGED
data/test/mpfr_tsqrt.rb
CHANGED
data/test/tc_cmp.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
2
2
|
|
3
|
-
class TcCmp < Test
|
3
|
+
class TcCmp < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
@_64bit = 1_000_000_000_000.is_a? Fixnum
|
6
5
|
@a=GMP::Z.new(180)
|
7
6
|
@c=GMP::Q.new(2000,11) # ~181.82
|
8
7
|
@d=GMP::Q.new(3000,17) # ~176.47
|
9
8
|
@e=700
|
10
|
-
|
11
|
-
@f=2**64
|
12
|
-
else
|
13
|
-
@f=2**32
|
14
|
-
end
|
9
|
+
@f=2**64
|
15
10
|
@g=GMP::Q(360,2)
|
16
11
|
end
|
17
12
|
|
data/test/tc_constants.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
2
2
|
|
3
|
-
class TcConstants < Test
|
3
|
+
class TcConstants < MiniTest::Test
|
4
4
|
def test_constants
|
5
|
-
assert_instance_of(String,
|
6
|
-
assert_instance_of(String,
|
7
|
-
assert_instance_of(String,
|
8
|
-
assert_instance_of(
|
5
|
+
assert_instance_of(String, GMP::GMP_VERSION, "GMP::GMP_VERSION should be a String")
|
6
|
+
assert_instance_of(String, GMP::GMP_CC, "GMP::GMP_CC should be a String")
|
7
|
+
assert_instance_of(String, GMP::GMP_CFLAGS, "GMP::GMP_CFLAGS should be a String")
|
8
|
+
assert_instance_of(0.class, GMP::GMP_BITS_PER_LIMB, "GMP::GMP_BITS_PER_LIMB should be a Fixnum")
|
9
9
|
end
|
10
10
|
end
|
data/test/tc_division.rb
CHANGED
data/test/tc_f_abs_neg.rb
CHANGED
data/test/tc_f_precision.rb
CHANGED
data/test/tc_f_to_s.rb
CHANGED
data/test/tc_hashes.rb
CHANGED
data/test/tc_mpfr_cmp.rb
CHANGED
data/test/tc_mpfr_constants.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
2
2
|
|
3
|
-
class TcMpfrConstants < Test
|
3
|
+
class TcMpfrConstants < MiniTest::Test
|
4
4
|
def test_mpfr_constants
|
5
5
|
assert_instance_of(String, GMP::MPFR_VERSION, "GMP::MPFR_VERSION should be a String")
|
6
|
-
assert_instance_of(
|
7
|
-
assert_instance_of(
|
6
|
+
assert_instance_of(0.class, GMP::MPFR_PREC_MIN, "GMP::MPFR_PREC_MIN should be a Fixnum")
|
7
|
+
assert_instance_of(0.class, GMP::MPFR_PREC_MAX, "GMP::MPFR_PREC_MAX should be a Fixnum")
|
8
8
|
assert_instance_of(GMP::Rnd, GMP::GMP_RNDN, "GMP::GMP_RNDN should be a GMP::Rnd")
|
9
9
|
assert_instance_of(GMP::Rnd, GMP::GMP_RNDZ, "GMP::GMP_RNDZ should be a GMP::Rnd")
|
10
10
|
assert_instance_of(GMP::Rnd, GMP::GMP_RNDU, "GMP::GMP_RNDU should be a GMP::Rnd")
|
data/test/tc_mpfr_functions.rb
CHANGED
data/test/tc_mpfr_integer.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
2
2
|
|
3
|
-
class TcMpfrInteger < Test
|
3
|
+
class TcMpfrInteger < MiniTest::Test
|
4
4
|
def test_mpfr_integer_positive
|
5
5
|
assert(GMP::F(1.0).integer?, "MPFR should decide whether a number is an integer correctly.")
|
6
6
|
assert(GMP::F(2.0).integer?, "MPFR should decide whether a number is an integer correctly.")
|
data/test/tc_mpfr_pow.rb
CHANGED
data/test/tc_mpfr_random.rb
CHANGED
data/test/tc_mpfr_rounding.rb
CHANGED
data/test/tc_q.rb
CHANGED
data/test/tc_q_basic.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
2
2
|
|
3
3
|
# [Q op Q, Q op Z, Z op Q, Q op FixNum, Q op BigNum, FixNum op Q, BigNum op Q]
|
4
|
-
class TcRationalBasic < Test
|
4
|
+
class TcRationalBasic < MiniTest::Test
|
5
5
|
def setup
|
6
6
|
@a=GMP::Q.new(100,11)
|
7
7
|
@b=GMP::Q.new(200,17)
|
data/test/tc_q_num_den.rb
CHANGED
data/test/tc_random.rb
CHANGED
data/test/tc_sgn_neg_abs.rb
CHANGED
data/test/tc_swap.rb
CHANGED
data/test/tc_z.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
2
2
|
|
3
|
-
class TcInteger < Test
|
3
|
+
class TcInteger < MiniTest::Test
|
4
4
|
def test_init_null
|
5
5
|
assert_equal(GMP::Z.new(), 0, "GMP::Z.new() should initialize to 0")
|
6
6
|
end
|
@@ -55,6 +55,16 @@ class TcInteger < Test::Unit::TestCase
|
|
55
55
|
assert_equal(2**32, GMP::Z.new(2**32), "GMP::Z.new(x : Bignum) should initialize to x")
|
56
56
|
end
|
57
57
|
|
58
|
+
def test_init_float
|
59
|
+
assert_equal(3, GMP::Z.new(3.14), "GMP::Z.new(x : Float) should initialize to x")
|
60
|
+
assert_equal(3, GMP::Z.new(3.99), "GMP::Z.new(x : Float) should initialize to x")
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_init_gmpf
|
64
|
+
assert_equal(3, GMP::Z.new(GMP::F(3.14)), "GMP::Z.new(x : GMP::F) should initialize to x")
|
65
|
+
assert_equal(577, GMP::Z.new(GMP::F("0.57721566")*1000), "GMP::Z.new(x : GMP::F) should initialize to x")
|
66
|
+
end
|
67
|
+
|
58
68
|
def test_cmp_z
|
59
69
|
a = GMP::Z.new(2)
|
60
70
|
b = GMP::Z.new(1)
|
data/test/tc_z_addmul.rb
CHANGED
@@ -4,11 +4,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
|
4
4
|
# Z op (Fixnum,Z), Z op (Fixnum,Fixnum), Z op (Fixnum,Bignum)
|
5
5
|
# Z op (Bignum,Z), Z op (Bignum,Bignum), Z op (Bignum,Fixnum)]
|
6
6
|
# Things are tested both ways because the implementation is asymetrical
|
7
|
-
class TcIntegerAddmul < Test
|
8
|
-
def setup
|
9
|
-
@_64bit = 1_000_000_000_000.is_a? Fixnum
|
10
|
-
end
|
11
|
-
|
7
|
+
class TcIntegerAddmul < MiniTest::Test
|
12
8
|
def test_z
|
13
9
|
five = GMP::Z(5)
|
14
10
|
seven = GMP::Z(7)
|
@@ -55,40 +51,32 @@ class TcIntegerAddmul < Test::Unit::TestCase
|
|
55
51
|
m20 = GMP::Z(2)**20 - 1 # 1_048_575
|
56
52
|
m20.addmul!(-524_287, 2) # <= 1_048_575 + -1_048_574
|
57
53
|
assert_equal(1, m20, "GMP::Z should addmul Fixnum correctly")
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should addmul 64-bit Fixnum correctly")
|
62
|
-
end
|
54
|
+
neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
|
55
|
+
neg_m40.addmul!( 1_000_000_000_000, 1) # <= -1_099_511_627_776 + 1_000_000_000_000
|
56
|
+
assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should addmul 64-bit Fixnum correctly")
|
63
57
|
end
|
64
58
|
|
65
59
|
def test_bignum
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
m70.addmul!(-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
|
60
|
+
neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
|
61
|
+
neg_m40.addmul!( 1_000_000_000_000, 1) # <= -1_099_511_627_776 + 1_000_000_000_000
|
62
|
+
assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
|
63
|
+
neg_m40.addmul!(10, 9_000_000_000) # <= - 99_511_627_776 + 90_000_000_000
|
64
|
+
assert_equal(GMP::Z(- 9_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
|
65
|
+
neg_m40.addmul!( 3_000_000_000, 3) # <= - 9_511_627_776 + 9_000_000_000
|
66
|
+
assert_equal(GMP::Z(- 511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
|
67
|
+
m70 = GMP::Z(2)**70 - 1 # 1_180_591_620_717_411_303_423
|
68
|
+
m70.addmul!(-11*10_000_000_000, 10_000_000_000)
|
69
|
+
assert_equal(GMP::Z(80_591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
|
70
|
+
m70.addmul!(-1_000_000_000, 8*10_000_000_000)
|
71
|
+
assert_equal(GMP::Z( 591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
|
81
72
|
end
|
82
73
|
|
83
74
|
def test_raise
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
91
|
-
assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, 7) }
|
92
|
-
assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, GMP::Z(-7)) }
|
75
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, -7) }
|
76
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, -7_000_000_000) }
|
77
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, -7_000_000_000) }
|
78
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, -7_000_000_000_000_000_000) }
|
79
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, 7) }
|
80
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, GMP::Z(-7)) }
|
93
81
|
end
|
94
82
|
end
|
data/test/tc_z_basic.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
|
2
2
|
|
3
3
|
# Tested: [Z op Z, Z op FixNum, Z op BigNum, FixNum op Z, BigNum op Z]
|
4
4
|
# Things are tested both ways because the implementation is asymetrical
|
5
|
-
class TcIntegerBasic < Test
|
5
|
+
class TcIntegerBasic < MiniTest::Test
|
6
6
|
def setup
|
7
7
|
@a=GMP::Z.new(100)
|
8
8
|
@b=GMP::Z.new(200)
|
data/test/tc_z_exponentiation.rb
CHANGED
data/test/tc_z_export_import.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
2
2
|
|
3
|
-
class TcIntegerFunctionalMappings < Test
|
3
|
+
class TcIntegerFunctionalMappings < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
@_64bit = 1_000_000_000_000.is_a? Fixnum
|
6
5
|
@xp1 = 7
|
7
6
|
@xp2 = 2**30 - 1
|
8
7
|
@xn1 = -5
|
data/test/tc_z_gcd_lcm_invert.rb
CHANGED
data/test/tc_z_hamdist.rb
CHANGED
data/test/tc_z_io.rb
CHANGED
@@ -6,7 +6,7 @@ if (RUBY_DESCRIPTION =~ /rubinius/i and RUBY_VERSION =~ /^1.8/) ||
|
|
6
6
|
# Sorry charlie
|
7
7
|
else
|
8
8
|
|
9
|
-
class TcIntegerIo < Test
|
9
|
+
class TcIntegerIo < MiniTest::Test
|
10
10
|
def setup
|
11
11
|
@two_pow_100 = GMP::Z.pow(GMP::Z(2), 100)
|
12
12
|
@three_pow_100 = GMP::Z.pow(GMP::Z(3), 100)
|
data/test/tc_z_jac_leg_rem.rb
CHANGED
data/test/tc_z_logic.rb
CHANGED
data/test/tc_z_logical_roots.rb
CHANGED
data/test/tc_z_submul.rb
CHANGED
@@ -4,11 +4,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
|
4
4
|
# Z op (Fixnum,Z), Z op (Fixnum,Fixnum), Z op (Fixnum,Bignum)
|
5
5
|
# Z op (Bignum,Z), Z op (Bignum,Bignum), Z op (Bignum,Fixnum)]
|
6
6
|
# Things are tested both ways because the implementation is asymetrical
|
7
|
-
class TcIntegerSubmul < Test
|
8
|
-
def setup
|
9
|
-
@_64bit = 1_000_000_000_000.is_a? Fixnum
|
10
|
-
end
|
11
|
-
|
7
|
+
class TcIntegerSubmul < MiniTest::Test
|
12
8
|
def test_z
|
13
9
|
five = GMP::Z(5)
|
14
10
|
seven = GMP::Z(7)
|
@@ -55,40 +51,32 @@ class TcIntegerSubmul < Test::Unit::TestCase
|
|
55
51
|
m20 = GMP::Z(2)**20 - 1 # 1_048_575
|
56
52
|
m20.submul!(-524_287, 2) # <= 1_048_575 - -1_048_574
|
57
53
|
assert_equal(2_097_149, m20, "GMP::Z should submul Fixnum correctly")
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
assert_equal(GMP::Z(-2_099_511_627_776), neg_m40, "GMP::Z should submul 64-bit Fixnum correctly")
|
62
|
-
end
|
54
|
+
neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
|
55
|
+
neg_m40.submul!( 1_000_000_000_000, 1) # <= -1_099_511_627_776 - 1_000_000_000_000
|
56
|
+
assert_equal(GMP::Z(-2_099_511_627_776), neg_m40, "GMP::Z should submul 64-bit Fixnum correctly")
|
63
57
|
end
|
64
58
|
|
65
59
|
def test_bignum
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
60
|
+
neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
|
61
|
+
neg_m40.submul!( -1_000_000_000_000, 1) # <= -1_099_511_627_776 - -1_000_000_000_000
|
62
|
+
assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
|
63
|
+
neg_m40.submul!(-10, 9_000_000_000) # <= - 99_511_627_776 - -90_000_000_000
|
64
|
+
assert_equal(GMP::Z(- 9_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
|
65
|
+
neg_m40.submul!( -3_000_000_000, 3) # <= - 9_511_627_776 - -9_000_000_000
|
66
|
+
assert_equal(GMP::Z(- 511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
|
67
|
+
m70 = GMP::Z(2)**70 - 1 # 1_180_591_620_717_411_303_423
|
68
|
+
m70.submul!(11*10_000_000_000, 10_000_000_000)
|
69
|
+
assert_equal(GMP::Z(80_591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
|
70
|
+
m70.submul!(1_000_000_000, 8*10_000_000_000)
|
71
|
+
assert_equal(GMP::Z( 591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
|
81
72
|
end
|
82
73
|
|
83
74
|
def test_raise
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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)) }
|
75
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7) }
|
76
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000) }
|
77
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000) }
|
78
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000_000_000_000) }
|
79
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, 7) }
|
80
|
+
assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, GMP::Z(-7)) }
|
93
81
|
end
|
94
82
|
end
|
data/test/tc_z_to_dis.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
2
2
|
|
3
|
-
class TcIntegerToDis < Test
|
3
|
+
class TcIntegerToDis < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
@a = GMP::Z.new(100)
|
6
6
|
@b = GMP::Z.pow(2,32)
|
@@ -10,7 +10,7 @@ class TcIntegerToDis < Test::Unit::TestCase
|
|
10
10
|
|
11
11
|
def test_to_i
|
12
12
|
assert_equal(@a.to_i, 100, "GMP::Z should to_i correctly.")
|
13
|
-
assert_equal(@a.to_i.class,
|
13
|
+
assert_equal(@a.to_i.class, 0.class, "GMP::Z.to_i should be a Fixnum.")
|
14
14
|
assert_equal(@b.to_i, 2**32, "GMP::Z (Bignum) should to_i correctly.")
|
15
15
|
end
|
16
16
|
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Minitest::Assertions
|
2
2
|
def assert_less_than(expected, actual, message=nil)
|
3
3
|
assert_true(actual < expected, message)
|
4
4
|
end
|
@@ -28,4 +28,10 @@ module Test::Unit::Assertions
|
|
28
28
|
def assert_false(actual, message=nil)
|
29
29
|
assert(!actual, message)
|
30
30
|
end
|
31
|
+
|
32
|
+
# backwards compatibility with Test::Unit
|
33
|
+
alias assert_raise assert_raises
|
34
|
+
def assert_nothing_raised(e=nil)
|
35
|
+
yield
|
36
|
+
end
|
31
37
|
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.7.
|
4
|
+
version: 0.7.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Wegrzanowski
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: gmp - providing Ruby bindings to the GMP and MPFR libraries.
|
15
15
|
email:
|
@@ -20,21 +20,36 @@ extensions:
|
|
20
20
|
- ext/extconf.rb
|
21
21
|
extra_rdoc_files: []
|
22
22
|
files:
|
23
|
+
- CHANGELOG
|
24
|
+
- COPYING.md
|
25
|
+
- FEATURES.html
|
26
|
+
- README.html
|
27
|
+
- README.markdown
|
28
|
+
- benchmark/bench.sh
|
29
|
+
- benchmark/csv.sh
|
30
|
+
- benchmark/results-5.0.5_1.9.3_0.6.7.ods
|
31
|
+
- benchmark/results-5.1.0_0.6.19.ods
|
32
|
+
- ext/extconf.rb
|
23
33
|
- ext/gmp.c
|
24
34
|
- ext/gmpbench_timing.c
|
25
35
|
- ext/gmpf.c
|
36
|
+
- ext/gmpf.h
|
26
37
|
- ext/gmpq.c
|
38
|
+
- ext/gmpq.h
|
27
39
|
- ext/gmprandstate.c
|
28
40
|
- ext/gmpz.c
|
29
|
-
- ext/mprnd.c
|
30
|
-
- ext/gmpf.h
|
31
|
-
- ext/gmpq.h
|
32
41
|
- ext/gmpz.h
|
42
|
+
- ext/mprnd.c
|
33
43
|
- ext/mprnd.h
|
34
44
|
- ext/ruby_gmp.h
|
35
45
|
- ext/takeover.h
|
36
|
-
- ext/extconf.rb
|
37
46
|
- lib/gmp.rb
|
47
|
+
- manual.pdf
|
48
|
+
- manual.tex
|
49
|
+
- performance.2012.html
|
50
|
+
- performance.2012.md
|
51
|
+
- performance.2012.pdf
|
52
|
+
- test/README
|
38
53
|
- test/gmp_tcong.rb
|
39
54
|
- test/gmp_tgcd.rb
|
40
55
|
- test/gmp_tlcm.rb
|
@@ -94,27 +109,11 @@ files:
|
|
94
109
|
- test/test-22.rb
|
95
110
|
- test/test-23.rb
|
96
111
|
- test/test_helper.rb
|
97
|
-
- test/unit_tests.rb
|
98
|
-
- test/README
|
99
112
|
- test/test_unit/assertions.rb
|
100
|
-
-
|
101
|
-
- benchmark/csv.sh
|
102
|
-
- benchmark/results-5.0.5_1.9.3_0.6.7.ods
|
103
|
-
- benchmark/results-5.1.0_0.6.19.ods
|
104
|
-
- benchmark/results-5.1.3_0.6.31.ods
|
105
|
-
- CHANGELOG
|
106
|
-
- COPYING.md
|
107
|
-
- README.html
|
108
|
-
- README.markdown
|
109
|
-
- manual.pdf
|
110
|
-
- manual.tex
|
111
|
-
- FEATURES.html
|
112
|
-
- performance.2012.md
|
113
|
-
- performance.2012.html
|
114
|
-
- performance.2012.pdf
|
113
|
+
- test/unit_tests.rb
|
115
114
|
homepage: http://github.com/srawlins/gmp
|
116
115
|
licenses:
|
117
|
-
- Apache
|
116
|
+
- Apache-2.0
|
118
117
|
metadata: {}
|
119
118
|
post_install_message:
|
120
119
|
rdoc_options: []
|
@@ -122,18 +121,18 @@ require_paths:
|
|
122
121
|
- lib
|
123
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
123
|
requirements:
|
125
|
-
- -
|
124
|
+
- - ">="
|
126
125
|
- !ruby/object:Gem::Version
|
127
126
|
version: 1.8.6
|
128
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
128
|
requirements:
|
130
|
-
- -
|
129
|
+
- - ">="
|
131
130
|
- !ruby/object:Gem::Version
|
132
131
|
version: '0'
|
133
132
|
requirements:
|
134
133
|
- GMP compiled and working properly.
|
135
134
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.5.1
|
137
136
|
signing_key:
|
138
137
|
specification_version: 4
|
139
138
|
summary: Provides Ruby bindings to the GMP and MPFR libraries.
|
Binary file
|