ruby-mpfr 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +13 -0
- data/Rakefile +2 -1
- data/ext/gmp/mpfr/extconf.rb +21 -0
- data/ext/gmp/mpfr/gmp_header/gmpf.h +12 -0
- data/ext/gmp/mpfr/gmp_header/gmpq.h +12 -0
- data/ext/gmp/mpfr/gmp_header/gmpz.h +12 -0
- data/ext/gmp/mpfr/gmp_header/mprnd.h +12 -0
- data/ext/gmp/mpfr/gmp_header/ruby_gmp.h +385 -0
- data/ext/gmp/mpfr/gmp_header/takeover.h +36 -0
- data/ext/gmp/mpfr/ruby_mpfr_gmp.c +161 -0
- data/ext/gmp/mpfr/ruby_mpfr_gmp.h +14 -0
- data/ext/mpfr/ruby_mpfr.c +285 -84
- data/ext/mpfr/ruby_mpfr.h +1 -0
- data/lib/mpfr/gmp.rb +8 -0
- data/lib/mpfr/version.rb +1 -1
- data/spec/gmp/convert_spec.rb +43 -0
- data/spec/gmp/rand_spec.rb +22 -0
- data/spec/gmp/spec_helper.rb +14 -0
- data/spec/mpfr/functions_spec.rb +52 -0
- metadata +20 -6
data/Manifest.txt
CHANGED
@@ -4,6 +4,15 @@ Manifest.txt
|
|
4
4
|
PostInstall.txt
|
5
5
|
README.rdoc
|
6
6
|
Rakefile
|
7
|
+
ext/gmp/mpfr/extconf.rb
|
8
|
+
ext/gmp/mpfr/gmp_header/gmpf.h
|
9
|
+
ext/gmp/mpfr/gmp_header/gmpq.h
|
10
|
+
ext/gmp/mpfr/gmp_header/gmpz.h
|
11
|
+
ext/gmp/mpfr/gmp_header/mprnd.h
|
12
|
+
ext/gmp/mpfr/gmp_header/ruby_gmp.h
|
13
|
+
ext/gmp/mpfr/gmp_header/takeover.h
|
14
|
+
ext/gmp/mpfr/ruby_mpfr_gmp.c
|
15
|
+
ext/gmp/mpfr/ruby_mpfr_gmp.h
|
7
16
|
ext/mpfr/extconf.rb
|
8
17
|
ext/mpfr/ruby_mpfr.c
|
9
18
|
ext/mpfr/ruby_mpfr.h
|
@@ -13,12 +22,16 @@ ext/mpfr_matrix/mpfr/func_mpfr_matrix.h
|
|
13
22
|
ext/mpfr_matrix/mpfr/ruby_mpfr.h
|
14
23
|
ext/mpfr_matrix/mpfr/ruby_mpfr_matrix.c
|
15
24
|
ext/mpfr_matrix/mpfr/ruby_mpfr_matrix.h
|
25
|
+
lib/mpfr/gmp.rb
|
16
26
|
lib/mpfr/matrix.rb
|
17
27
|
lib/mpfr/version.rb
|
18
28
|
ruby-mpfr.gemspec
|
19
29
|
script/console
|
20
30
|
script/destroy
|
21
31
|
script/generate
|
32
|
+
spec/gmp/convert_spec.rb
|
33
|
+
spec/gmp/rand_spec.rb
|
34
|
+
spec/gmp/spec_helper.rb
|
22
35
|
spec/mpfr/allocate_spec.rb
|
23
36
|
spec/mpfr/arithmetic_spec.rb
|
24
37
|
spec/mpfr/comparison_spec.rb
|
data/Rakefile
CHANGED
@@ -16,7 +16,8 @@ $hoe = Hoe.spec 'ruby-mpfr' do
|
|
16
16
|
self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
17
17
|
self.rubyforge_name = self.name # TODO this is default value
|
18
18
|
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
19
|
-
self.spec_extras[:extensions] = ["ext/mpfr/extconf.rb", "ext/mpfr_matrix/mpfr/extconf.rb"
|
19
|
+
self.spec_extras[:extensions] = ["ext/mpfr/extconf.rb", "ext/mpfr_matrix/mpfr/extconf.rb",
|
20
|
+
"ext/gmp/mpfr/extconf.rb"]
|
20
21
|
self.extra_rdoc_files << 'README.rdoc'
|
21
22
|
self.extra_rdoc_files << 'Example.rdoc'
|
22
23
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
$CFLAGS += " -Wall"
|
4
|
+
|
5
|
+
REQUIRE_VERSION = 3
|
6
|
+
|
7
|
+
dir_config("mpfr")
|
8
|
+
dir_config("gmp")
|
9
|
+
if have_header('mpfr.h') && have_library('mpfr') && have_header('gmp.h') && have_library('gmp')
|
10
|
+
if have_macro('MPFR_VERSION_MAJOR', 'mpfr.h') do |src|
|
11
|
+
src + <<SRC
|
12
|
+
#if MPFR_VERSION_MAJOR < #{REQUIRE_VERSION}
|
13
|
+
# error
|
14
|
+
>>>>>> MPFR_VERSION_MAJOR requires larger than #{REQUIRE_VERSION} <<<<<<
|
15
|
+
#endif
|
16
|
+
SRC
|
17
|
+
end
|
18
|
+
# $CFLAGS += ' -DMPFR'
|
19
|
+
create_makefile("mpfr/mpfr_gmp")
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,385 @@
|
|
1
|
+
#ifndef _RUBY_GMP_H_
|
2
|
+
#define _RUBY_GMP_H_
|
3
|
+
|
4
|
+
#include <stdio.h>
|
5
|
+
#include <ruby.h>
|
6
|
+
#ifndef _GNU_SOURCE
|
7
|
+
#define _GNU_SOURCE
|
8
|
+
#endif
|
9
|
+
#include <gmp.h>
|
10
|
+
|
11
|
+
#ifdef MPFR
|
12
|
+
|
13
|
+
#ifdef HAVE_MPFR_H
|
14
|
+
#include <mpfr.h>
|
15
|
+
#endif /* HAVE_MPFR_H */
|
16
|
+
|
17
|
+
#ifdef HAVE_MPF2MPFR_H
|
18
|
+
#include <mpf2mpfr.h>
|
19
|
+
#endif /* HAVE_MPF2MPFR_H */
|
20
|
+
|
21
|
+
#endif /* MPFR */
|
22
|
+
|
23
|
+
#include <stdlib.h>
|
24
|
+
|
25
|
+
/*
|
26
|
+
MP_INT*, MP_RAT* and MP_FLOAT* are used because they don't have side-effects
|
27
|
+
of single-element arrays mp*_t
|
28
|
+
|
29
|
+
MP_FLOAT is defined here, as it's commented out in gmp.h
|
30
|
+
*/
|
31
|
+
#if defined(MPFR) && defined(HAVE_MPFR_H)
|
32
|
+
typedef __mpfr_struct MP_FLOAT;
|
33
|
+
#else
|
34
|
+
typedef __mpf_struct MP_FLOAT;
|
35
|
+
/*
|
36
|
+
* Here, MPFR is not included, so we are pure GMP. In GMP, mpf_get_prec returns
|
37
|
+
* an unsigned long int, so we will too.
|
38
|
+
*/
|
39
|
+
typedef unsigned long mpfr_prec_t;
|
40
|
+
#endif /* HAVE_MPF2MPFR_H */
|
41
|
+
|
42
|
+
#if __GNU_MP_VERSION < 5
|
43
|
+
typedef unsigned long int mp_bitcnt_t;
|
44
|
+
#endif
|
45
|
+
|
46
|
+
/*
|
47
|
+
I don't like this solution, because in gmp.h, all of these typedefs are
|
48
|
+
marked with "gmp 1 source compatibility". :(.
|
49
|
+
*/
|
50
|
+
typedef __gmp_randstate_struct MP_RANDSTATE;
|
51
|
+
|
52
|
+
#define mpz_get_struct(ruby_var,c_var) { Data_Get_Struct(ruby_var, MP_INT, c_var); }
|
53
|
+
#define mpq_get_struct(ruby_var,c_var) { Data_Get_Struct(ruby_var, MP_RAT, c_var); }
|
54
|
+
#define mpf_get_struct(ruby_var,c_var) { Data_Get_Struct(ruby_var, MP_FLOAT, c_var); }
|
55
|
+
#define mprandstate_get_struct(ruby_var,c_var) { Data_Get_Struct(ruby_var, MP_RANDSTATE, c_var); }
|
56
|
+
#define mpz_make_struct(ruby_var,c_var) { ruby_var = Data_Make_Struct(cGMP_Z, MP_INT, 0, r_gmpz_free, c_var); }
|
57
|
+
#define mpq_make_struct(ruby_var,c_var) { ruby_var = Data_Make_Struct(cGMP_Q, MP_RAT, 0, r_gmpq_free, c_var); }
|
58
|
+
#define mpf_make_struct(ruby_var,c_var) { ruby_var = Data_Make_Struct(cGMP_F, MP_FLOAT, 0, r_gmpf_free, c_var); }
|
59
|
+
#define mprandstate_make_struct(ruby_var,c_var) { ruby_var = Data_Make_Struct(cGMP_RandState, MP_RANDSTATE, 0, r_gmprandstate_free, c_var); }
|
60
|
+
#define mpz_make_struct_init(ruby_var,c_var) { mpz_make_struct(ruby_var,c_var); mpz_init (c_var); }
|
61
|
+
#define mpq_make_struct_init(ruby_var,c_var) { mpq_make_struct(ruby_var,c_var); mpq_init (c_var); }
|
62
|
+
#define BIGNUM_P(value) (TYPE(value) == T_BIGNUM)
|
63
|
+
#define FLOAT_P(value) (TYPE(value) == T_FLOAT)
|
64
|
+
#define STRING_P(value) (TYPE(value) == T_STRING)
|
65
|
+
#define GMPZ_P(value) (rb_obj_is_instance_of(value, cGMP_Z) == Qtrue)
|
66
|
+
#define GMPQ_P(value) (rb_obj_is_instance_of(value, cGMP_Q) == Qtrue)
|
67
|
+
#define GMPF_P(value) (rb_obj_is_instance_of(value, cGMP_F) == Qtrue)
|
68
|
+
#define mpz_set_bignum(var_mpz,var_bignum) { \
|
69
|
+
VALUE tmp = rb_funcall (var_bignum, rb_intern ("to_s"), 1, INT2FIX(32)); \
|
70
|
+
mpz_set_str (var_mpz, StringValuePtr (tmp), 32); \
|
71
|
+
}
|
72
|
+
#define mpz_temp_alloc(var) { var=malloc(sizeof(MP_INT)); }
|
73
|
+
#define mpz_temp_init(var) { mpz_temp_alloc(var); mpz_init(var); }
|
74
|
+
#define mpz_temp_from_bignum(var,var_bignum) { \
|
75
|
+
mpz_temp_alloc(var); \
|
76
|
+
VALUE tmp = rb_funcall (var_bignum, rb_intern ("to_s"), 1, INT2FIX(32)); \
|
77
|
+
mpz_init_set_str (var, StringValuePtr (tmp), 32); \
|
78
|
+
}
|
79
|
+
#define mpz_temp_free(var) { mpz_clear(var); free(var); }
|
80
|
+
#define mpf_temp_alloc(var) { var=malloc(sizeof(MP_FLOAT)); }
|
81
|
+
#if defined(MPFR) && defined(HAVE_MPFR_H)
|
82
|
+
#define prec_max(prec,var) {if(mpfr_get_prec(var) > prec) prec = mpfr_get_prec(var); }
|
83
|
+
#else
|
84
|
+
#define prec_max(prec,var) {if(mpf_get_prec(var) > prec) prec = mpf_get_prec(var); }
|
85
|
+
#endif
|
86
|
+
|
87
|
+
#if defined(MPFR) && defined(HAVE_MPFR_H)
|
88
|
+
#define mpf_get_struct_prec(ruby_var,c_var,prec) { mpf_get_struct(ruby_var,c_var); prec = mpfr_get_prec(c_var); }
|
89
|
+
#define mpf_make_struct_init(ruby_var,c_var,prec) { mpf_make_struct(ruby_var,c_var); mpfr_init2 (c_var,prec); }
|
90
|
+
#define mpf_temp_init(var,prec) { mpf_temp_alloc(var); mpfr_init2(var,prec); }
|
91
|
+
#define mpf_temp_free(var) { mpfr_clear(var); free(var); }
|
92
|
+
#define r_mpf_init(var1) (mpfr_init(var1))
|
93
|
+
#define r_mpf_init2(var1, var2) (mpfr_init2(var1, var2))
|
94
|
+
#define r_mpf_set_z(var1, var2) (mpfr_set_z(var1, var2, __gmp_default_rounding_mode))
|
95
|
+
#define r_mpf_set_q(var1, var2) (mpfr_set_q(var1, var2, __gmp_default_rounding_mode))
|
96
|
+
#define r_mpf_set_d(var1, var2) (mpfr_set_d(var1, var2, __gmp_default_rounding_mode))
|
97
|
+
#define r_mpf_set_str(var1, var2, var3) (mpfr_set_str(var1, var2, var3, __gmp_default_rounding_mode))
|
98
|
+
#define r_mpf_cmp(var1, var2) (mpfr_cmp(var1, var2))
|
99
|
+
#else
|
100
|
+
#define mpf_get_struct_prec(ruby_var,c_var,prec) { mpf_get_struct(ruby_var,c_var); prec = mpf_get_prec(c_var); }
|
101
|
+
#define mpf_make_struct_init(ruby_var,c_var,prec) { mpf_make_struct(ruby_var,c_var); mpf_init2 (c_var,prec); }
|
102
|
+
#define mpf_temp_init(var,prec) { mpf_temp_alloc(var); mpf_init2(var,prec); }
|
103
|
+
#define mpf_temp_free(var) { mpf_clear(var); free(var); }
|
104
|
+
#define r_mpf_init(var1) (mpf_init(var1))
|
105
|
+
#define r_mpf_init2(var1, var2) (mpf_init2(var1, var2))
|
106
|
+
#define r_mpf_set_z(var1, var2) (mpf_set_z(var1, var2))
|
107
|
+
#define r_mpf_set_q(var1, var2) (mpf_set_q(var1, var2))
|
108
|
+
#define r_mpf_set_d(var1, var2) (mpf_set_d(var1, var2))
|
109
|
+
#define r_mpf_set_str(var1, var2, var3) (mpf_set_str(var1, var2, var3))
|
110
|
+
#define r_mpf_cmp(var1, var2) (mpf_cmp(var1, var2))
|
111
|
+
#endif
|
112
|
+
|
113
|
+
#ifdef FIXNUM_WIDTH /* RBX check */
|
114
|
+
//#if ((FIXNUM_WIDTH()) == 62) /* 64-bit */
|
115
|
+
#if (((8*SIZEOF_INTPTR_T) - TAG_FIXNUM_SHIFT -1) == 63)
|
116
|
+
#define FIX2NUM(x) FIX2LONG(x)
|
117
|
+
//#else /* 32-bit */
|
118
|
+
//#define FIX2NUM(x) FIX2INT(x)
|
119
|
+
#endif
|
120
|
+
#else /* RBX check */
|
121
|
+
#if SIZEOF_INT < SIZEOF_LONG /* 64-bit */
|
122
|
+
#define FIX2NUM(x) FIX2LONG(x)
|
123
|
+
#else /* 32-bit */
|
124
|
+
#define FIX2NUM(x) FIX2INT(x)
|
125
|
+
#endif /* MRI's 32-vs-64 check */
|
126
|
+
#endif /* RBX check */
|
127
|
+
|
128
|
+
#define EXPECTED_ZQFXBD "Expected GMP::Z, GMP::Q, GMP::F, Fixnum, Bignum or Float"
|
129
|
+
#define EXPECTED_ZQFXB "Expected GMP::Z, GMP::Q, GMP::F, Fixnum or Bignum"
|
130
|
+
#define EXPECTED_ZFXBD "Expected GMP::Z, GMP::F, Fixnum, Bignum or Float"
|
131
|
+
#define EXPECTED_ZXB "Expected GMP::Z, Fixnum or Bignum"
|
132
|
+
#define EXPECTED_ZX "Expected GMP::Z or Fixnum"
|
133
|
+
#define EXPECTED_X "Expected Fixnum"
|
134
|
+
#define EXPECTED_Z "Expected GMP::Z"
|
135
|
+
#define EXPECTED_FD "Expected GMP::F or Float"
|
136
|
+
#define typeerror(expected) rb_raise(rb_eTypeError, EXPECTED_##expected)
|
137
|
+
#define typeerror_as(expected, argname) rb_raise(rb_eTypeError, EXPECTED_##expected " as " argname)
|
138
|
+
|
139
|
+
//should change exception type
|
140
|
+
#define not_yet rb_raise(rb_eTypeError,"Not implemented yet")
|
141
|
+
|
142
|
+
#ifdef MPFR
|
143
|
+
#define mprnd_get_struct(ruby_var,c_var) { Data_Get_Struct(ruby_var, int, c_var); }
|
144
|
+
#define mprnd_make_struct(ruby_var,c_var) { ruby_var = Data_Make_Struct(cGMP_Rnd, int, 0, 0, c_var); }
|
145
|
+
#define GMPRND_P(value) (rb_obj_is_instance_of(value, cGMP_Rnd) == Qtrue)
|
146
|
+
#endif /* MPFR */
|
147
|
+
|
148
|
+
extern VALUE mGMP, cGMP_Z, cGMP_Q, cGMP_F, cGMP_RandState;
|
149
|
+
#ifdef MPFR
|
150
|
+
extern VALUE cGMP_Rnd;
|
151
|
+
#endif /* MPFR */
|
152
|
+
|
153
|
+
extern void r_gmpz_free(void *ptr);
|
154
|
+
extern void r_gmpq_free(void *ptr);
|
155
|
+
extern void r_gmpf_free(void *ptr);
|
156
|
+
extern void r_gmprandstate_free(void *ptr);
|
157
|
+
|
158
|
+
|
159
|
+
/* from gmpz.h */
|
160
|
+
|
161
|
+
// Initializing, Assigning Integers
|
162
|
+
extern VALUE r_gmpzsg_new(int argc, VALUE *argv, VALUE klass);
|
163
|
+
extern VALUE r_gmpz_initialize(int argc, VALUE *argv, VALUE self);
|
164
|
+
extern void mpz_set_value(MP_INT *target, VALUE source);
|
165
|
+
extern VALUE r_gmpmod_z(int argc, VALUE *argv, VALUE module);
|
166
|
+
extern VALUE r_gmpz_swap(VALUE self, VALUE arg);
|
167
|
+
|
168
|
+
// Converting Integers
|
169
|
+
extern VALUE r_gmpz_to_i(VALUE self);
|
170
|
+
extern VALUE r_gmpz_to_d(VALUE self);
|
171
|
+
extern VALUE r_gmpz_to_s(int argc, VALUE *argv, VALUE self);
|
172
|
+
|
173
|
+
// Integer Arithmetic
|
174
|
+
extern VALUE r_gmpz_add(VALUE self, VALUE arg);
|
175
|
+
extern VALUE r_gmpz_add_self(VALUE self, VALUE arg);
|
176
|
+
extern VALUE r_gmpz_sub(VALUE self, VALUE arg);
|
177
|
+
extern VALUE r_gmpz_sub_self(VALUE self, VALUE arg);
|
178
|
+
extern VALUE r_gmpz_mul(VALUE self, VALUE arg);
|
179
|
+
extern VALUE r_gmpz_div(VALUE self, VALUE arg);
|
180
|
+
|
181
|
+
// Integer Division
|
182
|
+
extern VALUE r_gmpz_mod(VALUE self, VALUE arg);
|
183
|
+
|
184
|
+
// Integer Exponentiation
|
185
|
+
extern VALUE r_gmpzsg_pow(VALUE klass, VALUE base, VALUE exp);
|
186
|
+
extern VALUE r_gmpz_powm(VALUE self, VALUE exp, VALUE mod);
|
187
|
+
|
188
|
+
// Integer Roots
|
189
|
+
|
190
|
+
// Number Theoretic Functions
|
191
|
+
extern VALUE r_gmpz_is_probab_prime(int argc, VALUE* argv, VALUE self);
|
192
|
+
extern VALUE r_gmpz_gcd(VALUE self, VALUE arg);
|
193
|
+
extern VALUE r_gmpz_invert(VALUE self, VALUE arg);
|
194
|
+
extern VALUE r_gmpz_jacobi(VALUE self, VALUE b);
|
195
|
+
extern VALUE r_gmpzsg_jacobi(VALUE klass, VALUE a, VALUE b);
|
196
|
+
extern VALUE r_gmpz_legendre(VALUE self, VALUE p);
|
197
|
+
extern VALUE r_gmpz_remove(VALUE self, VALUE arg);
|
198
|
+
|
199
|
+
// Integer Comparisons
|
200
|
+
extern VALUE r_gmpz_eq(VALUE self, VALUE arg);
|
201
|
+
extern VALUE r_gmpz_cmp(VALUE self, VALUE arg);
|
202
|
+
extern VALUE r_gmpz_cmpabs(VALUE self, VALUE arg);
|
203
|
+
extern VALUE r_gmpz_sgn(VALUE self);
|
204
|
+
extern int mpz_cmp_value(MP_INT *OP, VALUE arg);
|
205
|
+
|
206
|
+
// Integer Logic and Bit Fiddling
|
207
|
+
extern VALUE r_gmpz_popcount(VALUE self);
|
208
|
+
extern VALUE r_gmpz_scan0(VALUE self, VALUE bitnr);
|
209
|
+
extern VALUE r_gmpz_scan1(VALUE self, VALUE bitnr);
|
210
|
+
extern VALUE r_gmpz_setbit(VALUE self, VALUE bitnr, VALUE set_to);
|
211
|
+
extern VALUE r_gmpz_getbit(VALUE self, VALUE bitnr);
|
212
|
+
|
213
|
+
// Miscelaneous Integer Functions
|
214
|
+
extern VALUE r_gmpz_sizeinbase(VALUE self, VALUE base);
|
215
|
+
extern VALUE r_gmpz_size_in_bin(VALUE self);
|
216
|
+
|
217
|
+
|
218
|
+
/* from gmpq.h */
|
219
|
+
|
220
|
+
// Initializing Rationals
|
221
|
+
extern VALUE r_gmpqsg_new(int argc, VALUE *argv, VALUE klass);
|
222
|
+
extern VALUE r_gmpmod_q(int argc, VALUE *argv, VALUE module);
|
223
|
+
extern VALUE r_gmpq_swap(VALUE self, VALUE arg);
|
224
|
+
|
225
|
+
// Rational Conversions
|
226
|
+
extern VALUE r_gmpq_to_d(VALUE self);
|
227
|
+
extern VALUE r_gmpq_to_s(VALUE self);
|
228
|
+
|
229
|
+
// Rational Arithmetic
|
230
|
+
extern VALUE r_gmpq_add(VALUE self, VALUE arg);
|
231
|
+
extern VALUE r_gmpq_sub(VALUE self, VALUE arg);
|
232
|
+
extern VALUE r_gmpq_mul(VALUE self, VALUE arg);
|
233
|
+
extern VALUE r_gmpq_div(VALUE self, VALUE arg);
|
234
|
+
extern VALUE r_gmpq_inv(VALUE self);
|
235
|
+
extern VALUE r_gmpq_inv_self(VALUE self);
|
236
|
+
|
237
|
+
// Comparing Rationals
|
238
|
+
extern VALUE r_gmpq_eq(VALUE self, VALUE arg);
|
239
|
+
extern VALUE r_gmpq_cmp(VALUE self, VALUE arg);
|
240
|
+
extern int mpq_cmp_value(MP_RAT *OP, VALUE arg);
|
241
|
+
extern VALUE r_gmpq_sgn(VALUE self);
|
242
|
+
|
243
|
+
// Applying Integer Functions
|
244
|
+
extern VALUE r_gmpq_num(VALUE self);
|
245
|
+
extern VALUE r_gmpq_den(VALUE self);
|
246
|
+
|
247
|
+
// _unsorted_
|
248
|
+
|
249
|
+
|
250
|
+
/* from gmpf.h */
|
251
|
+
|
252
|
+
// Initializing, Assigning Floats
|
253
|
+
extern VALUE r_gmpfsg_new(int argc, VALUE *argv, VALUE klass);
|
254
|
+
extern VALUE r_gmpf_initialize(int argc, VALUE *argv, VALUE self);
|
255
|
+
extern void mpf_set_value(MP_FLOAT *self_val, VALUE arg);
|
256
|
+
extern VALUE r_gmpmod_f(int argc, VALUE *argv, VALUE module);
|
257
|
+
extern VALUE r_gmpf_get_prec(VALUE self);
|
258
|
+
extern VALUE r_gmpf_set_prec(VALUE self, VALUE arg);
|
259
|
+
extern VALUE r_gmpf_set_prec_raw(VALUE self, VALUE arg);
|
260
|
+
|
261
|
+
// Converting Floats
|
262
|
+
extern VALUE r_gmpf_to_d(VALUE self);
|
263
|
+
extern VALUE r_gmpf_to_s(VALUE self);
|
264
|
+
|
265
|
+
// Float Arithmetic
|
266
|
+
#ifndef MPFR
|
267
|
+
extern VALUE r_gmpf_add(VALUE self, VALUE arg);
|
268
|
+
extern VALUE r_gmpf_mul(VALUE self, VALUE arg);
|
269
|
+
#else
|
270
|
+
extern VALUE r_gmpfr_add(int argc, VALUE *argv, VALUE self);
|
271
|
+
extern VALUE r_gmpfr_mul(int argc, VALUE *argv, VALUE self);
|
272
|
+
#endif
|
273
|
+
extern VALUE r_gmpf_sub(VALUE self, VALUE arg);
|
274
|
+
extern VALUE r_gmpf_div(VALUE self, VALUE arg);
|
275
|
+
|
276
|
+
// Float Comparison
|
277
|
+
extern VALUE r_gmpf_eq(VALUE self, VALUE arg);
|
278
|
+
extern VALUE r_gmpf_cmp(VALUE self, VALUE arg);
|
279
|
+
extern int mpf_cmp_value(MP_FLOAT *OP, VALUE arg);
|
280
|
+
|
281
|
+
// MPFR
|
282
|
+
#ifdef MPFR
|
283
|
+
extern void mpf_set_value2(MP_FLOAT *self_val, VALUE arg, int base);
|
284
|
+
|
285
|
+
extern VALUE r_gmpfr_sqrt(int argc, VALUE *argv, VALUE self);
|
286
|
+
extern VALUE r_gmpfr_rec_sqrt(int argc, VALUE *argv, VALUE self);
|
287
|
+
extern VALUE r_gmpfr_cbrt(int argc, VALUE *argv, VALUE self);
|
288
|
+
|
289
|
+
extern VALUE r_gmpfr_log(int argc, VALUE *argv, VALUE self);
|
290
|
+
extern VALUE r_gmpfr_log2(int argc, VALUE *argv, VALUE self);
|
291
|
+
extern VALUE r_gmpfr_log10(int argc, VALUE *argv, VALUE self);
|
292
|
+
extern VALUE r_gmpfr_exp(int argc, VALUE *argv, VALUE self);
|
293
|
+
extern VALUE r_gmpfr_exp2(int argc, VALUE *argv, VALUE self);
|
294
|
+
extern VALUE r_gmpfr_exp10(int argc, VALUE *argv, VALUE self);
|
295
|
+
extern VALUE r_gmpfr_cos(int argc, VALUE *argv, VALUE self);
|
296
|
+
extern VALUE r_gmpfr_sin(int argc, VALUE *argv, VALUE self);
|
297
|
+
extern VALUE r_gmpfr_tan(int argc, VALUE *argv, VALUE self);
|
298
|
+
extern VALUE r_gmpfr_sec(int argc, VALUE *argv, VALUE self);
|
299
|
+
extern VALUE r_gmpfr_csc(int argc, VALUE *argv, VALUE self);
|
300
|
+
extern VALUE r_gmpfr_cot(int argc, VALUE *argv, VALUE self);
|
301
|
+
|
302
|
+
extern VALUE r_gmpfr_acos(int argc, VALUE *argv, VALUE self);
|
303
|
+
extern VALUE r_gmpfr_asin(int argc, VALUE *argv, VALUE self);
|
304
|
+
extern VALUE r_gmpfr_atan(int argc, VALUE *argv, VALUE self);
|
305
|
+
|
306
|
+
extern VALUE r_gmpfr_cosh(int argc, VALUE *argv, VALUE self);
|
307
|
+
extern VALUE r_gmpfr_sinh(int argc, VALUE *argv, VALUE self);
|
308
|
+
extern VALUE r_gmpfr_tanh(int argc, VALUE *argv, VALUE self);
|
309
|
+
|
310
|
+
extern VALUE r_gmpfr_sech(int argc, VALUE *argv, VALUE self);
|
311
|
+
extern VALUE r_gmpfr_csch(int argc, VALUE *argv, VALUE self);
|
312
|
+
extern VALUE r_gmpfr_coth(int argc, VALUE *argv, VALUE self);
|
313
|
+
extern VALUE r_gmpfr_acosh(int argc, VALUE *argv, VALUE self);
|
314
|
+
extern VALUE r_gmpfr_asinh(int argc, VALUE *argv, VALUE self);
|
315
|
+
extern VALUE r_gmpfr_atanh(int argc, VALUE *argv, VALUE self);
|
316
|
+
|
317
|
+
extern VALUE r_gmpfr_log1p(int argc, VALUE *argv, VALUE self);
|
318
|
+
extern VALUE r_gmpfr_expm1(int argc, VALUE *argv, VALUE self);
|
319
|
+
extern VALUE r_gmpfr_eint(int argc, VALUE *argv, VALUE self);
|
320
|
+
extern VALUE r_gmpfr_li2(int argc, VALUE *argv, VALUE self);
|
321
|
+
extern VALUE r_gmpfr_gamma(int argc, VALUE *argv, VALUE self);
|
322
|
+
extern VALUE r_gmpfr_lngamma(int argc, VALUE *argv, VALUE self);
|
323
|
+
/*extern VALUE r_gmpfr_lgamma(int argc, VALUE *argv, VALUE self);*/
|
324
|
+
#if MPFR_VERSION_MAJOR > 2
|
325
|
+
extern VALUE r_gmpfr_digamma(int argc, VALUE *argv, VALUE self);
|
326
|
+
#endif
|
327
|
+
extern VALUE r_gmpfr_zeta(int argc, VALUE *argv, VALUE self);
|
328
|
+
extern VALUE r_gmpfr_erf(int argc, VALUE *argv, VALUE self);
|
329
|
+
extern VALUE r_gmpfr_erfc(int argc, VALUE *argv, VALUE self);
|
330
|
+
extern VALUE r_gmpfr_j0(int argc, VALUE *argv, VALUE self);
|
331
|
+
extern VALUE r_gmpfr_j1(int argc, VALUE *argv, VALUE self);
|
332
|
+
extern VALUE r_gmpfr_jn(int argc, VALUE *argv, VALUE self);
|
333
|
+
extern VALUE r_gmpfr_y0(int argc, VALUE *argv, VALUE self);
|
334
|
+
extern VALUE r_gmpfr_y1(int argc, VALUE *argv, VALUE self);
|
335
|
+
|
336
|
+
extern VALUE r_gmpfrsg_const_log2();
|
337
|
+
extern VALUE r_gmpfrsg_const_pi();
|
338
|
+
extern VALUE r_gmpfrsg_const_euler();
|
339
|
+
extern VALUE r_gmpfrsg_const_catalan();
|
340
|
+
|
341
|
+
extern mp_rnd_t r_get_rounding_mode(VALUE rnd);
|
342
|
+
#endif /* MPFR */
|
343
|
+
|
344
|
+
// _unsorted_
|
345
|
+
extern VALUE r_gmpf_sgn(VALUE self);
|
346
|
+
|
347
|
+
|
348
|
+
/* from gmprandstate.h */
|
349
|
+
|
350
|
+
// Random State Initialization
|
351
|
+
extern VALUE r_gmprandstatesg_new(int argc, VALUE *argv, VALUE klass);
|
352
|
+
extern VALUE r_gmprandstate_initialize(int argc, VALUE *argv, VALUE self);
|
353
|
+
extern VALUE r_gmpmod_randstate(int argc, VALUE *argv, VALUE module);
|
354
|
+
|
355
|
+
// Random State Seeding
|
356
|
+
extern VALUE r_gmprandstate_seed(VALUE self, VALUE arg);
|
357
|
+
|
358
|
+
// Integer Random Numbers
|
359
|
+
extern VALUE r_gmprandstate_urandomb(VALUE self, VALUE arg);
|
360
|
+
extern VALUE r_gmprandstate_urandomm(VALUE self, VALUE arg);
|
361
|
+
|
362
|
+
#ifdef MPFR
|
363
|
+
// Float Random Numbers
|
364
|
+
extern VALUE r_gmprandstate_mpfr_urandomb(int argc, VALUE *argv, VALUE self);
|
365
|
+
#endif /* MPFR */
|
366
|
+
|
367
|
+
|
368
|
+
/* from gmpbench_timing.c */
|
369
|
+
|
370
|
+
// GMPbench Timing
|
371
|
+
extern VALUE r_gmpmod_cputime(VALUE self);
|
372
|
+
extern VALUE r_gmpmod_time(VALUE self);
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
extern void init_gmpz();
|
377
|
+
extern void init_gmpq();
|
378
|
+
extern void init_gmpf();
|
379
|
+
extern void init_gmprandstate();
|
380
|
+
extern void init_gmpbench_timing();
|
381
|
+
#ifdef MPFR
|
382
|
+
extern void init_gmprnd();
|
383
|
+
#endif /* MPFR */
|
384
|
+
|
385
|
+
#endif
|