ruby-mpfi 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +0 -4
- data/README.rdoc +21 -25
- data/Rakefile +2 -1
- data/ext/mpfi/ruby_mpfi.c +242 -102
- data/ext/mpfi_complex/mpfi/ruby_mpfi_complex.c +34 -14
- data/ext/mpfi_matrix/mpfi/func_mpfi_matrix.c +2 -86
- data/ext/mpfi_matrix/mpfi/func_mpfi_matrix.h +0 -6
- data/ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.c +99 -35
- data/lib/mpfi/version.rb +1 -3
- data/ruby-mpfi.gemspec +8 -5
- data/spec/mpfi/mpfi_math_functions_spec.rb +2 -2
- metadata +14 -7
- data/ext/mpfi/make_c_source.rb +0 -115
- data/ext/mpfi/yasnippet_mpfi.el +0 -44
- data/ext/mpfi_matrix/mpfi/func_ruby_mpfi_complex.h +0 -35
- data/ext/mpfi_matrix/mpfi/ruby_mpfi_complex.h +0 -15
data/ext/mpfi/ruby_mpfi.c
CHANGED
@@ -9,12 +9,14 @@ static VALUE __mpfi_class__, __mpfr_class__, __sym_to_s__, __sym_to_str__;
|
|
9
9
|
/* ------------------------------ function state start ------------------------------ */
|
10
10
|
|
11
11
|
/* Save the value of last function state. */
|
12
|
-
void r_mpfi_set_function_state(int num)
|
12
|
+
void r_mpfi_set_function_state(int num)
|
13
|
+
{
|
13
14
|
rb_cv_set(r_mpfi_class, CLASS_VAL_FUNCTION_STATE, INT2NUM(num));
|
14
15
|
}
|
15
16
|
|
16
17
|
/* Return state of last function of MPFI. */
|
17
|
-
VALUE r_mpfr_get_function_state(VALUE self)
|
18
|
+
VALUE r_mpfr_get_function_state(VALUE self)
|
19
|
+
{
|
18
20
|
return rb_cv_get(r_mpfi_class, CLASS_VAL_FUNCTION_STATE);
|
19
21
|
}
|
20
22
|
|
@@ -22,12 +24,14 @@ VALUE r_mpfr_get_function_state(VALUE self){
|
|
22
24
|
|
23
25
|
/* ------------------------------ allocation start ------------------------------ */
|
24
26
|
|
25
|
-
void r_mpfi_free(void *ptr)
|
27
|
+
void r_mpfi_free(void *ptr)
|
28
|
+
{
|
26
29
|
mpfi_clear(ptr);
|
27
30
|
free(ptr);
|
28
31
|
}
|
29
32
|
|
30
|
-
VALUE r_mpfi_make_new_fi_obj(MPFI *ptr)
|
33
|
+
VALUE r_mpfi_make_new_fi_obj(MPFI *ptr)
|
34
|
+
{
|
31
35
|
VALUE ret;
|
32
36
|
MPFI *ptr_ret;
|
33
37
|
r_mpfi_make_struct_init(ret, ptr_ret);
|
@@ -36,7 +40,8 @@ VALUE r_mpfi_make_new_fi_obj(MPFI *ptr){
|
|
36
40
|
}
|
37
41
|
|
38
42
|
/* VALUE obj must have method to_s or to_str. */
|
39
|
-
static void r_mpfi_set_from_object (MPFI *ptr, VALUE obj)
|
43
|
+
static void r_mpfi_set_from_object (MPFI *ptr, VALUE obj)
|
44
|
+
{
|
40
45
|
if(RTEST(rb_funcall(rb_funcall(obj, class, 0), method_defined, 1, __sym_to_str__))){
|
41
46
|
char *str = StringValuePtr(obj);
|
42
47
|
mpfi_set_str(ptr, str, 10);
|
@@ -47,7 +52,8 @@ static void r_mpfi_set_from_object (MPFI *ptr, VALUE obj){
|
|
47
52
|
}
|
48
53
|
}
|
49
54
|
|
50
|
-
void r_mpfi_set_robj(MPFI *ptr, VALUE obj)
|
55
|
+
void r_mpfi_set_robj(MPFI *ptr, VALUE obj)
|
56
|
+
{
|
51
57
|
if(RTEST(rb_funcall(__mpfi_class__, eqq, 1, obj))){
|
52
58
|
MPFI *ptr_obj;
|
53
59
|
r_mpfi_get_struct(ptr_obj, obj);
|
@@ -71,7 +77,8 @@ void r_mpfi_set_robj(MPFI *ptr, VALUE obj){
|
|
71
77
|
}
|
72
78
|
}
|
73
79
|
|
74
|
-
VALUE r_mpfi_new_fi_obj(VALUE obj)
|
80
|
+
VALUE r_mpfi_new_fi_obj(VALUE obj)
|
81
|
+
{
|
75
82
|
if(RTEST(rb_funcall(__mpfi_class__, eqq, 1, obj))){
|
76
83
|
return obj;
|
77
84
|
}else{
|
@@ -80,15 +87,15 @@ VALUE r_mpfi_new_fi_obj(VALUE obj){
|
|
80
87
|
}
|
81
88
|
|
82
89
|
/* Initializing and Assigning Intervals */
|
83
|
-
static VALUE r_mpfi_alloc(VALUE self)
|
90
|
+
static VALUE r_mpfi_alloc(VALUE self)
|
91
|
+
{
|
84
92
|
MPFI *ptr;
|
85
93
|
r_mpfi_make_struct(self, ptr);
|
86
94
|
return self;
|
87
95
|
}
|
88
96
|
|
89
|
-
static
|
90
|
-
|
91
|
-
r_mpfi_get_struct(ptr, self);
|
97
|
+
static void r_mpfi_set_initial_value(MPFI *ptr, int argc, VALUE *argv)
|
98
|
+
{
|
92
99
|
switch(argc){
|
93
100
|
case 0:
|
94
101
|
mpfi_init(ptr);
|
@@ -105,10 +112,28 @@ static VALUE r_mpfi_initialize(int argc, VALUE *argv, VALUE self){
|
|
105
112
|
rb_raise(rb_eArgError, "Invalid number of arguments.");
|
106
113
|
break;
|
107
114
|
}
|
115
|
+
}
|
116
|
+
|
117
|
+
/* Return new MPFI instance. The same arguments as MPFI.new is acceptable. */
|
118
|
+
static VALUE r_mpfi_global_new(int argc, VALUE *argv, VALUE self)
|
119
|
+
{
|
120
|
+
MPFI *ptr;
|
121
|
+
VALUE val;
|
122
|
+
r_mpfi_make_struct(val, ptr);
|
123
|
+
r_mpfi_set_initial_value(ptr, argc, argv);
|
124
|
+
return val;
|
125
|
+
}
|
126
|
+
|
127
|
+
static VALUE r_mpfi_initialize(int argc, VALUE *argv, VALUE self)
|
128
|
+
{
|
129
|
+
MPFI *ptr;
|
130
|
+
r_mpfi_get_struct(ptr, self);
|
131
|
+
r_mpfi_set_initial_value(ptr, argc, argv);
|
108
132
|
return Qtrue;
|
109
133
|
}
|
110
134
|
|
111
|
-
static VALUE r_mpfi_initialize_copy(VALUE self, VALUE other)
|
135
|
+
static VALUE r_mpfi_initialize_copy(VALUE self, VALUE other)
|
136
|
+
{
|
112
137
|
MPFI *ptr_self, *ptr_other;
|
113
138
|
r_mpfi_get_struct(ptr_self, self);
|
114
139
|
r_mpfi_get_struct(ptr_other, other);
|
@@ -118,7 +143,8 @@ static VALUE r_mpfi_initialize_copy(VALUE self, VALUE other){
|
|
118
143
|
}
|
119
144
|
|
120
145
|
/* Return array which have MPFI instance converted to from p1 and self. */
|
121
|
-
static VALUE r_mpfi_coerce(VALUE self, VALUE other)
|
146
|
+
static VALUE r_mpfi_coerce(VALUE self, VALUE other)
|
147
|
+
{
|
122
148
|
VALUE val_other;
|
123
149
|
MPFI *ptr_self, *ptr_other;
|
124
150
|
r_mpfi_get_struct(ptr_self, self);
|
@@ -127,14 +153,16 @@ static VALUE r_mpfi_coerce(VALUE self, VALUE other){
|
|
127
153
|
return rb_ary_new3(2, val_other, self);
|
128
154
|
}
|
129
155
|
|
130
|
-
static VALUE r_mpfi_set (VALUE self, VALUE arg)
|
156
|
+
static VALUE r_mpfi_set (VALUE self, VALUE arg)
|
157
|
+
{
|
131
158
|
MPFI *ptr_self;
|
132
159
|
r_mpfi_get_struct(ptr_self, self);
|
133
160
|
r_mpfi_set_robj(ptr_self, arg);
|
134
161
|
return self;
|
135
162
|
}
|
136
163
|
|
137
|
-
static VALUE r_mpfi_swap (VALUE self, VALUE other)
|
164
|
+
static VALUE r_mpfi_swap (VALUE self, VALUE other)
|
165
|
+
{
|
138
166
|
MPFI *ptr_self, *ptr_other;
|
139
167
|
r_mpfi_get_struct(ptr_self, self);
|
140
168
|
r_mpfi_get_struct(ptr_other, other);
|
@@ -148,7 +176,8 @@ static VALUE r_mpfi_swap (VALUE self, VALUE other){
|
|
148
176
|
|
149
177
|
/* Need to consider returned value later. */
|
150
178
|
/* mpfi_set_prec is different from reference manual. This is strange. */
|
151
|
-
static VALUE r_mpfi_set_prec (VALUE self, VALUE prec)
|
179
|
+
static VALUE r_mpfi_set_prec (VALUE self, VALUE prec)
|
180
|
+
{
|
152
181
|
MPFI *ptr_self;
|
153
182
|
r_mpfi_get_struct(ptr_self, self);
|
154
183
|
/* if(mpfi_set_prec(ptr_self, NUM2INT(prec)) != 0){ */
|
@@ -159,14 +188,16 @@ static VALUE r_mpfi_set_prec (VALUE self, VALUE prec){
|
|
159
188
|
}
|
160
189
|
|
161
190
|
/* Need to consider returned value later. */
|
162
|
-
static VALUE r_mpfi_get_prec (VALUE self)
|
191
|
+
static VALUE r_mpfi_get_prec (VALUE self)
|
192
|
+
{
|
163
193
|
MPFI *ptr_self;
|
164
194
|
r_mpfi_get_struct(ptr_self, self);
|
165
195
|
return INT2NUM((int)mpfi_get_prec(ptr_self));
|
166
196
|
}
|
167
197
|
|
168
198
|
/* Need to consider returned value later. */
|
169
|
-
static VALUE r_mpfi_round_prec (VALUE self, VALUE prec)
|
199
|
+
static VALUE r_mpfi_round_prec (VALUE self, VALUE prec)
|
200
|
+
{
|
170
201
|
MPFI *ptr_self;
|
171
202
|
r_mpfi_get_struct(ptr_self, self);
|
172
203
|
r_mpfi_set_function_state(mpfi_round_prec(ptr_self, NUM2INT(prec)));
|
@@ -176,7 +207,8 @@ static VALUE r_mpfi_round_prec (VALUE self, VALUE prec){
|
|
176
207
|
|
177
208
|
/* ------------------------------ string start ------------------------------ */
|
178
209
|
|
179
|
-
static VALUE r_mpfi_inspect(VALUE self)
|
210
|
+
static VALUE r_mpfi_inspect(VALUE self)
|
211
|
+
{
|
180
212
|
MPFI *ptr_s;
|
181
213
|
r_mpfi_get_struct(ptr_s, self);
|
182
214
|
char *ret_str;
|
@@ -187,7 +219,8 @@ static VALUE r_mpfi_inspect(VALUE self){
|
|
187
219
|
return ret_val;
|
188
220
|
}
|
189
221
|
|
190
|
-
static VALUE r_mpfi_to_str_ary(VALUE self)
|
222
|
+
static VALUE r_mpfi_to_str_ary(VALUE self)
|
223
|
+
{
|
191
224
|
MPFI *ptr_self;
|
192
225
|
r_mpfi_get_struct(ptr_self, self);
|
193
226
|
char *ret_str1, *ret_str2;
|
@@ -200,7 +233,8 @@ static VALUE r_mpfi_to_str_ary(VALUE self){
|
|
200
233
|
}
|
201
234
|
|
202
235
|
/* Output self by sprintf. */
|
203
|
-
static VALUE r_mpfi_to_strf_ary(VALUE self, VALUE format_str)
|
236
|
+
static VALUE r_mpfi_to_strf_ary(VALUE self, VALUE format_str)
|
237
|
+
{
|
204
238
|
MPFI *ptr_self;
|
205
239
|
r_mpfi_get_struct(ptr_self, self);
|
206
240
|
char *format = StringValuePtr(format_str);
|
@@ -217,7 +251,8 @@ static VALUE r_mpfi_to_strf_ary(VALUE self, VALUE format_str){
|
|
217
251
|
|
218
252
|
/* ------------------------------ Basic Arithmetic Functions start ------------------------------ */
|
219
253
|
|
220
|
-
static VALUE r_mpfi_add (VALUE self, VALUE other)
|
254
|
+
static VALUE r_mpfi_add (VALUE self, VALUE other)
|
255
|
+
{
|
221
256
|
VALUE val_ret;
|
222
257
|
MPFI *ptr_self, *ptr_ret;
|
223
258
|
r_mpfi_get_struct(ptr_self, self);
|
@@ -244,7 +279,8 @@ static VALUE r_mpfi_add (VALUE self, VALUE other){
|
|
244
279
|
return val_ret;
|
245
280
|
}
|
246
281
|
|
247
|
-
static VALUE r_mpfi_sub (VALUE self, VALUE other)
|
282
|
+
static VALUE r_mpfi_sub (VALUE self, VALUE other)
|
283
|
+
{
|
248
284
|
VALUE val_ret;
|
249
285
|
MPFI *ptr_self, *ptr_ret;
|
250
286
|
r_mpfi_get_struct(ptr_self, self);
|
@@ -271,7 +307,8 @@ static VALUE r_mpfi_sub (VALUE self, VALUE other){
|
|
271
307
|
return val_ret;
|
272
308
|
}
|
273
309
|
|
274
|
-
static VALUE r_mpfi_mul (VALUE self, VALUE other)
|
310
|
+
static VALUE r_mpfi_mul (VALUE self, VALUE other)
|
311
|
+
{
|
275
312
|
VALUE val_ret;
|
276
313
|
MPFI *ptr_self, *ptr_ret;
|
277
314
|
r_mpfi_get_struct(ptr_self, self);
|
@@ -298,7 +335,8 @@ static VALUE r_mpfi_mul (VALUE self, VALUE other){
|
|
298
335
|
return val_ret;
|
299
336
|
}
|
300
337
|
|
301
|
-
static VALUE r_mpfi_div (VALUE self, VALUE other)
|
338
|
+
static VALUE r_mpfi_div (VALUE self, VALUE other)
|
339
|
+
{
|
302
340
|
VALUE val_ret;
|
303
341
|
MPFI *ptr_self, *ptr_ret;
|
304
342
|
r_mpfi_get_struct(ptr_self, self);
|
@@ -325,7 +363,8 @@ static VALUE r_mpfi_div (VALUE self, VALUE other){
|
|
325
363
|
return val_ret;
|
326
364
|
}
|
327
365
|
|
328
|
-
static VALUE r_mpfi_mul_2si (int argc, VALUE *argv, VALUE self)
|
366
|
+
static VALUE r_mpfi_mul_2si (int argc, VALUE *argv, VALUE self)
|
367
|
+
{
|
329
368
|
MPFI *ptr_self, *ptr_ret;
|
330
369
|
r_mpfi_get_struct(ptr_self, self);
|
331
370
|
VALUE val_ret;
|
@@ -334,7 +373,8 @@ static VALUE r_mpfi_mul_2si (int argc, VALUE *argv, VALUE self){
|
|
334
373
|
return val_ret;
|
335
374
|
}
|
336
375
|
|
337
|
-
static VALUE r_mpfi_div_2si (int argc, VALUE *argv, VALUE self)
|
376
|
+
static VALUE r_mpfi_div_2si (int argc, VALUE *argv, VALUE self)
|
377
|
+
{
|
338
378
|
MPFI *ptr_self, *ptr_ret;
|
339
379
|
r_mpfi_get_struct(ptr_self, self);
|
340
380
|
VALUE val_ret;
|
@@ -343,7 +383,8 @@ static VALUE r_mpfi_div_2si (int argc, VALUE *argv, VALUE self){
|
|
343
383
|
return val_ret;
|
344
384
|
}
|
345
385
|
|
346
|
-
static VALUE r_mpfi_neg(int argc, VALUE *argv, VALUE self)
|
386
|
+
static VALUE r_mpfi_neg(int argc, VALUE *argv, VALUE self)
|
387
|
+
{
|
347
388
|
MPFI *ptr_self, *ptr_ret;
|
348
389
|
r_mpfi_get_struct(ptr_self, self);
|
349
390
|
VALUE val_ret;
|
@@ -352,7 +393,8 @@ static VALUE r_mpfi_neg(int argc, VALUE *argv, VALUE self){
|
|
352
393
|
return val_ret;
|
353
394
|
}
|
354
395
|
|
355
|
-
static VALUE r_mpfi_inv(int argc, VALUE *argv, VALUE self)
|
396
|
+
static VALUE r_mpfi_inv(int argc, VALUE *argv, VALUE self)
|
397
|
+
{
|
356
398
|
MPFI *ptr_self, *ptr_ret;
|
357
399
|
r_mpfi_get_struct(ptr_self, self);
|
358
400
|
VALUE val_ret;
|
@@ -361,7 +403,8 @@ static VALUE r_mpfi_inv(int argc, VALUE *argv, VALUE self){
|
|
361
403
|
return val_ret;
|
362
404
|
}
|
363
405
|
|
364
|
-
static VALUE r_mpfi_abs(int argc, VALUE *argv, VALUE self)
|
406
|
+
static VALUE r_mpfi_abs(int argc, VALUE *argv, VALUE self)
|
407
|
+
{
|
365
408
|
MPFI *ptr_self, *ptr_ret;
|
366
409
|
r_mpfi_get_struct(ptr_self, self);
|
367
410
|
VALUE val_ret;
|
@@ -374,7 +417,8 @@ static VALUE r_mpfi_abs(int argc, VALUE *argv, VALUE self){
|
|
374
417
|
|
375
418
|
/* ------------------------------ Comparison Functions start ------------------------------ */
|
376
419
|
|
377
|
-
static VALUE r_mpfi_cmp (VALUE self, VALUE other)
|
420
|
+
static VALUE r_mpfi_cmp (VALUE self, VALUE other)
|
421
|
+
{
|
378
422
|
MPFI *ptr_self;
|
379
423
|
r_mpfi_get_struct(ptr_self, self);
|
380
424
|
int ret;
|
@@ -400,7 +444,8 @@ static VALUE r_mpfi_cmp (VALUE self, VALUE other){
|
|
400
444
|
return NUM2INT(ret);
|
401
445
|
}
|
402
446
|
|
403
|
-
static VALUE r_mpfi_is_pos (VALUE self)
|
447
|
+
static VALUE r_mpfi_is_pos (VALUE self)
|
448
|
+
{
|
404
449
|
MPFI *ptr_self;
|
405
450
|
r_mpfi_get_struct(ptr_self, self);
|
406
451
|
if (mpfi_is_pos(ptr_self) > 0) {
|
@@ -410,7 +455,8 @@ static VALUE r_mpfi_is_pos (VALUE self){
|
|
410
455
|
}
|
411
456
|
}
|
412
457
|
|
413
|
-
static VALUE r_mpfi_is_strictly_pos (VALUE self)
|
458
|
+
static VALUE r_mpfi_is_strictly_pos (VALUE self)
|
459
|
+
{
|
414
460
|
MPFI *ptr_self;
|
415
461
|
r_mpfi_get_struct(ptr_self, self);
|
416
462
|
if (mpfi_is_strictly_pos(ptr_self) > 0) {
|
@@ -420,7 +466,8 @@ static VALUE r_mpfi_is_strictly_pos (VALUE self){
|
|
420
466
|
}
|
421
467
|
}
|
422
468
|
|
423
|
-
static VALUE r_mpfi_is_nonneg (VALUE self)
|
469
|
+
static VALUE r_mpfi_is_nonneg (VALUE self)
|
470
|
+
{
|
424
471
|
MPFI *ptr_self;
|
425
472
|
r_mpfi_get_struct(ptr_self, self);
|
426
473
|
if (mpfi_is_nonneg(ptr_self) > 0) {
|
@@ -430,7 +477,8 @@ static VALUE r_mpfi_is_nonneg (VALUE self){
|
|
430
477
|
}
|
431
478
|
}
|
432
479
|
|
433
|
-
static VALUE r_mpfi_is_neg (VALUE self)
|
480
|
+
static VALUE r_mpfi_is_neg (VALUE self)
|
481
|
+
{
|
434
482
|
MPFI *ptr_self;
|
435
483
|
r_mpfi_get_struct(ptr_self, self);
|
436
484
|
if (mpfi_is_neg(ptr_self) > 0) {
|
@@ -440,7 +488,8 @@ static VALUE r_mpfi_is_neg (VALUE self){
|
|
440
488
|
}
|
441
489
|
}
|
442
490
|
|
443
|
-
static VALUE r_mpfi_is_strictly_neg (VALUE self)
|
491
|
+
static VALUE r_mpfi_is_strictly_neg (VALUE self)
|
492
|
+
{
|
444
493
|
MPFI *ptr_self;
|
445
494
|
r_mpfi_get_struct(ptr_self, self);
|
446
495
|
if (mpfi_is_strictly_neg(ptr_self) > 0) {
|
@@ -450,7 +499,8 @@ static VALUE r_mpfi_is_strictly_neg (VALUE self){
|
|
450
499
|
}
|
451
500
|
}
|
452
501
|
|
453
|
-
static VALUE r_mpfi_is_nonpos (VALUE self)
|
502
|
+
static VALUE r_mpfi_is_nonpos (VALUE self)
|
503
|
+
{
|
454
504
|
MPFI *ptr_self;
|
455
505
|
r_mpfi_get_struct(ptr_self, self);
|
456
506
|
if (mpfi_is_nonpos(ptr_self) > 0) {
|
@@ -460,7 +510,8 @@ static VALUE r_mpfi_is_nonpos (VALUE self){
|
|
460
510
|
}
|
461
511
|
}
|
462
512
|
|
463
|
-
static VALUE r_mpfi_is_zero (VALUE self)
|
513
|
+
static VALUE r_mpfi_is_zero (VALUE self)
|
514
|
+
{
|
464
515
|
MPFI *ptr_self;
|
465
516
|
r_mpfi_get_struct(ptr_self, self);
|
466
517
|
if (mpfi_is_zero(ptr_self) > 0) {
|
@@ -470,7 +521,8 @@ static VALUE r_mpfi_is_zero (VALUE self){
|
|
470
521
|
}
|
471
522
|
}
|
472
523
|
|
473
|
-
static VALUE r_mpfi_has_zero (VALUE self)
|
524
|
+
static VALUE r_mpfi_has_zero (VALUE self)
|
525
|
+
{
|
474
526
|
MPFI *ptr_self;
|
475
527
|
r_mpfi_get_struct(ptr_self, self);
|
476
528
|
if (mpfi_has_zero(ptr_self) > 0) {
|
@@ -480,7 +532,8 @@ static VALUE r_mpfi_has_zero (VALUE self){
|
|
480
532
|
}
|
481
533
|
}
|
482
534
|
|
483
|
-
static VALUE r_mpfi_nan_p (VALUE self)
|
535
|
+
static VALUE r_mpfi_nan_p (VALUE self)
|
536
|
+
{
|
484
537
|
MPFI *ptr_self;
|
485
538
|
r_mpfi_get_struct(ptr_self, self);
|
486
539
|
if (mpfi_nan_p(ptr_self) != 0) {
|
@@ -490,7 +543,8 @@ static VALUE r_mpfi_nan_p (VALUE self){
|
|
490
543
|
}
|
491
544
|
}
|
492
545
|
|
493
|
-
static VALUE r_mpfi_inf_p (VALUE self)
|
546
|
+
static VALUE r_mpfi_inf_p (VALUE self)
|
547
|
+
{
|
494
548
|
MPFI *ptr_self;
|
495
549
|
r_mpfi_get_struct(ptr_self, self);
|
496
550
|
if (mpfi_inf_p(ptr_self) != 0) {
|
@@ -500,7 +554,8 @@ static VALUE r_mpfi_inf_p (VALUE self){
|
|
500
554
|
}
|
501
555
|
}
|
502
556
|
|
503
|
-
static VALUE r_mpfi_bounded_p (VALUE self)
|
557
|
+
static VALUE r_mpfi_bounded_p (VALUE self)
|
558
|
+
{
|
504
559
|
MPFI *ptr_self;
|
505
560
|
r_mpfi_get_struct(ptr_self, self);
|
506
561
|
if (mpfi_bounded_p(ptr_self) != 0) {
|
@@ -510,9 +565,12 @@ static VALUE r_mpfi_bounded_p (VALUE self){
|
|
510
565
|
}
|
511
566
|
}
|
512
567
|
|
513
|
-
/*
|
514
|
-
|
515
|
-
|
568
|
+
/*
|
569
|
+
Return true if self.right equals other.right and self.left equals other.right
|
570
|
+
by mpfr_equal_p.
|
571
|
+
*/
|
572
|
+
static VALUE r_mpfi_equal_p (VALUE self, VALUE other)
|
573
|
+
{
|
516
574
|
MPFI *ptr_self, *ptr_other;
|
517
575
|
r_mpfi_get_struct(ptr_self, self);
|
518
576
|
r_mpfi_get_struct(ptr_other, other);
|
@@ -528,7 +586,8 @@ static VALUE r_mpfi_equal_p (VALUE self, VALUE other){
|
|
528
586
|
|
529
587
|
/* ------------------------------ Interval Functions with Floating-point Results start ------------------------------ */
|
530
588
|
|
531
|
-
static VALUE r_mpfi_diam_abs (int argc, VALUE *argv, VALUE self)
|
589
|
+
static VALUE r_mpfi_diam_abs (int argc, VALUE *argv, VALUE self)
|
590
|
+
{
|
532
591
|
MPFI *ptr_self;
|
533
592
|
r_mpfi_get_struct(ptr_self, self);
|
534
593
|
VALUE val_ret;
|
@@ -538,7 +597,8 @@ static VALUE r_mpfi_diam_abs (int argc, VALUE *argv, VALUE self){
|
|
538
597
|
return val_ret;
|
539
598
|
}
|
540
599
|
|
541
|
-
static VALUE r_mpfi_diam_rel (int argc, VALUE *argv, VALUE self)
|
600
|
+
static VALUE r_mpfi_diam_rel (int argc, VALUE *argv, VALUE self)
|
601
|
+
{
|
542
602
|
MPFI *ptr_self;
|
543
603
|
r_mpfi_get_struct(ptr_self, self);
|
544
604
|
VALUE val_ret;
|
@@ -548,7 +608,8 @@ static VALUE r_mpfi_diam_rel (int argc, VALUE *argv, VALUE self){
|
|
548
608
|
return val_ret;
|
549
609
|
}
|
550
610
|
|
551
|
-
static VALUE r_mpfi_diam (int argc, VALUE *argv, VALUE self)
|
611
|
+
static VALUE r_mpfi_diam (int argc, VALUE *argv, VALUE self)
|
612
|
+
{
|
552
613
|
MPFI *ptr_self;
|
553
614
|
r_mpfi_get_struct(ptr_self, self);
|
554
615
|
VALUE val_ret;
|
@@ -558,7 +619,8 @@ static VALUE r_mpfi_diam (int argc, VALUE *argv, VALUE self){
|
|
558
619
|
return val_ret;
|
559
620
|
}
|
560
621
|
|
561
|
-
static VALUE r_mpfi_mag (int argc, VALUE *argv, VALUE self)
|
622
|
+
static VALUE r_mpfi_mag (int argc, VALUE *argv, VALUE self)
|
623
|
+
{
|
562
624
|
MPFI *ptr_self;
|
563
625
|
r_mpfi_get_struct(ptr_self, self);
|
564
626
|
VALUE val_ret;
|
@@ -568,7 +630,8 @@ static VALUE r_mpfi_mag (int argc, VALUE *argv, VALUE self){
|
|
568
630
|
return val_ret;
|
569
631
|
}
|
570
632
|
|
571
|
-
static VALUE r_mpfi_mig (int argc, VALUE *argv, VALUE self)
|
633
|
+
static VALUE r_mpfi_mig (int argc, VALUE *argv, VALUE self)
|
634
|
+
{
|
572
635
|
MPFI *ptr_self;
|
573
636
|
r_mpfi_get_struct(ptr_self, self);
|
574
637
|
VALUE val_ret;
|
@@ -578,7 +641,8 @@ static VALUE r_mpfi_mig (int argc, VALUE *argv, VALUE self){
|
|
578
641
|
return val_ret;
|
579
642
|
}
|
580
643
|
|
581
|
-
static VALUE r_mpfi_mid (int argc, VALUE *argv, VALUE self)
|
644
|
+
static VALUE r_mpfi_mid (int argc, VALUE *argv, VALUE self)
|
645
|
+
{
|
582
646
|
MPFI *ptr_self;
|
583
647
|
r_mpfi_get_struct(ptr_self, self);
|
584
648
|
VALUE val_ret;
|
@@ -588,7 +652,8 @@ static VALUE r_mpfi_mid (int argc, VALUE *argv, VALUE self){
|
|
588
652
|
return val_ret;
|
589
653
|
}
|
590
654
|
|
591
|
-
static VALUE r_mpfi_mid_interval (int argc, VALUE *argv, VALUE self)
|
655
|
+
static VALUE r_mpfi_mid_interval (int argc, VALUE *argv, VALUE self)
|
656
|
+
{
|
592
657
|
MPFI *ptr_self, *ptr_ret;
|
593
658
|
r_mpfi_get_struct(ptr_self, self);
|
594
659
|
VALUE val_ret;
|
@@ -597,7 +662,8 @@ static VALUE r_mpfi_mid_interval (int argc, VALUE *argv, VALUE self){
|
|
597
662
|
return val_ret;
|
598
663
|
}
|
599
664
|
|
600
|
-
static VALUE r_mpfi_alea (int argc, VALUE *argv, VALUE self)
|
665
|
+
static VALUE r_mpfi_alea (int argc, VALUE *argv, VALUE self)
|
666
|
+
{
|
601
667
|
MPFI *ptr_self;
|
602
668
|
r_mpfi_get_struct(ptr_self, self);
|
603
669
|
VALUE val_ret;
|
@@ -611,13 +677,15 @@ static VALUE r_mpfi_alea (int argc, VALUE *argv, VALUE self){
|
|
611
677
|
|
612
678
|
/* ------------------------------ Conversion Functions start ------------------------------ */
|
613
679
|
|
614
|
-
static VALUE r_mpfi_get_d(VALUE self)
|
680
|
+
static VALUE r_mpfi_get_d(VALUE self)
|
681
|
+
{
|
615
682
|
MPFI *ptr_self;
|
616
683
|
r_mpfi_get_struct(ptr_self, self);
|
617
684
|
return rb_float_new(mpfi_get_d(ptr_self));
|
618
685
|
}
|
619
686
|
|
620
|
-
static VALUE r_mpfi_get_fr(VALUE self)
|
687
|
+
static VALUE r_mpfi_get_fr(VALUE self)
|
688
|
+
{
|
621
689
|
MPFI *ptr_self;
|
622
690
|
r_mpfi_get_struct(ptr_self, self);
|
623
691
|
VALUE val_ret;
|
@@ -630,7 +698,8 @@ static VALUE r_mpfi_get_fr(VALUE self){
|
|
630
698
|
|
631
699
|
/* ------------------------------ Functions Operating on Endpoints start ------------------------------ */
|
632
700
|
|
633
|
-
static VALUE r_mpfi_get_left (VALUE self)
|
701
|
+
static VALUE r_mpfi_get_left (VALUE self)
|
702
|
+
{
|
634
703
|
VALUE val_ret;
|
635
704
|
MPFI *ptr_self;
|
636
705
|
MPFR *ptr_ret;
|
@@ -640,7 +709,8 @@ static VALUE r_mpfi_get_left (VALUE self){
|
|
640
709
|
return val_ret;
|
641
710
|
}
|
642
711
|
|
643
|
-
static VALUE r_mpfi_get_right (VALUE self)
|
712
|
+
static VALUE r_mpfi_get_right (VALUE self)
|
713
|
+
{
|
644
714
|
VALUE val_ret;
|
645
715
|
MPFI *ptr_self;
|
646
716
|
MPFR *ptr_ret;
|
@@ -650,7 +720,8 @@ static VALUE r_mpfi_get_right (VALUE self){
|
|
650
720
|
return val_ret;
|
651
721
|
}
|
652
722
|
|
653
|
-
static VALUE r_mpfi_revert_if_needed (VALUE self)
|
723
|
+
static VALUE r_mpfi_revert_if_needed (VALUE self)
|
724
|
+
{
|
654
725
|
MPFI *ptr_self;
|
655
726
|
r_mpfi_get_struct(ptr_self, self);
|
656
727
|
if(mpfi_revert_if_needed(ptr_self) != 0){
|
@@ -660,7 +731,8 @@ static VALUE r_mpfi_revert_if_needed (VALUE self){
|
|
660
731
|
};
|
661
732
|
}
|
662
733
|
|
663
|
-
static VALUE r_mpfi_put (VALUE self, VALUE other)
|
734
|
+
static VALUE r_mpfi_put (VALUE self, VALUE other)
|
735
|
+
{
|
664
736
|
MPFI *ptr_self;
|
665
737
|
r_mpfi_get_struct(ptr_self, self);
|
666
738
|
|
@@ -685,7 +757,8 @@ static VALUE r_mpfi_put (VALUE self, VALUE other){
|
|
685
757
|
return self;
|
686
758
|
}
|
687
759
|
|
688
|
-
static VALUE r_mpfi_interv (VALUE self, VALUE a1, VALUE a2)
|
760
|
+
static VALUE r_mpfi_interv (VALUE self, VALUE a1, VALUE a2)
|
761
|
+
{
|
689
762
|
MPFI *ptr_self;
|
690
763
|
r_mpfi_get_struct(ptr_self, self);
|
691
764
|
|
@@ -709,7 +782,8 @@ static VALUE r_mpfi_interv (VALUE self, VALUE a1, VALUE a2){
|
|
709
782
|
return self;
|
710
783
|
}
|
711
784
|
|
712
|
-
static VALUE r_mpfi_interval (int argc, VALUE *argv, VALUE self)
|
785
|
+
static VALUE r_mpfi_interval (int argc, VALUE *argv, VALUE self)
|
786
|
+
{
|
713
787
|
VALUE val_ret;
|
714
788
|
MPFI *ptr_ret;
|
715
789
|
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(2, 3, argc, argv));
|
@@ -739,7 +813,8 @@ static VALUE r_mpfi_interval (int argc, VALUE *argv, VALUE self){
|
|
739
813
|
return val_ret;
|
740
814
|
}
|
741
815
|
|
742
|
-
static VALUE r_mpfi_endpoints (VALUE self)
|
816
|
+
static VALUE r_mpfi_endpoints (VALUE self)
|
817
|
+
{
|
743
818
|
VALUE val_left, val_right;
|
744
819
|
MPFI *ptr_self;
|
745
820
|
MPFR *ptr_left, *ptr_right;
|
@@ -756,7 +831,8 @@ static VALUE r_mpfi_endpoints (VALUE self){
|
|
756
831
|
/* ------------------------------ Set Functions on Intervals start ------------------------------ */
|
757
832
|
|
758
833
|
/* This method corresponds to mpfi_is_strictly_inside. */
|
759
|
-
static VALUE r_mpfi_strictly_include (VALUE self, VALUE other)
|
834
|
+
static VALUE r_mpfi_strictly_include (VALUE self, VALUE other)
|
835
|
+
{
|
760
836
|
MPFI *ptr_self, *ptr_other;
|
761
837
|
r_mpfi_get_struct(ptr_self, self);
|
762
838
|
r_mpfi_get_struct(ptr_other, other);
|
@@ -768,7 +844,8 @@ static VALUE r_mpfi_strictly_include (VALUE self, VALUE other){
|
|
768
844
|
}
|
769
845
|
|
770
846
|
/* This method corresponds to mpfi_is_inside. */
|
771
|
-
static VALUE r_mpfi_include (VALUE self, VALUE other)
|
847
|
+
static VALUE r_mpfi_include (VALUE self, VALUE other)
|
848
|
+
{
|
772
849
|
MPFI *ptr_self;
|
773
850
|
r_mpfi_get_struct(ptr_self, self);
|
774
851
|
int result;
|
@@ -797,7 +874,8 @@ static VALUE r_mpfi_include (VALUE self, VALUE other){
|
|
797
874
|
}
|
798
875
|
}
|
799
876
|
|
800
|
-
static VALUE r_mpfi_is_empty (VALUE self)
|
877
|
+
static VALUE r_mpfi_is_empty (VALUE self)
|
878
|
+
{
|
801
879
|
MPFI *ptr_self;
|
802
880
|
r_mpfi_get_struct(ptr_self, self);
|
803
881
|
if(mpfi_is_empty(ptr_self) > 0){
|
@@ -809,7 +887,8 @@ static VALUE r_mpfi_is_empty (VALUE self){
|
|
809
887
|
|
810
888
|
/* If the intersection of two intervals is empty, this method returns nil.
|
811
889
|
Otherwise, it returns the intersection. */
|
812
|
-
static VALUE r_mpfi_intersect (int argc, VALUE *argv, VALUE self)
|
890
|
+
static VALUE r_mpfi_intersect (int argc, VALUE *argv, VALUE self)
|
891
|
+
{
|
813
892
|
MPFI *ptr_self, *ptr_a0, *ptr_ret;
|
814
893
|
r_mpfi_get_struct(ptr_self, self);
|
815
894
|
r_mpfi_get_struct(ptr_a0, argv[0]);
|
@@ -825,7 +904,8 @@ static VALUE r_mpfi_intersect (int argc, VALUE *argv, VALUE self){
|
|
825
904
|
|
826
905
|
/* This method returns the intersection of two intervals.
|
827
906
|
The returned value may be empty interval. */
|
828
|
-
static VALUE r_mpfi_intersect2 (int argc, VALUE *argv, VALUE self)
|
907
|
+
static VALUE r_mpfi_intersect2 (int argc, VALUE *argv, VALUE self)
|
908
|
+
{
|
829
909
|
MPFI *ptr_self, *ptr_a0, *ptr_ret;
|
830
910
|
r_mpfi_get_struct(ptr_self, self);
|
831
911
|
r_mpfi_get_struct(ptr_a0, argv[0]);
|
@@ -835,7 +915,8 @@ static VALUE r_mpfi_intersect2 (int argc, VALUE *argv, VALUE self){
|
|
835
915
|
return val_ret;
|
836
916
|
}
|
837
917
|
|
838
|
-
static VALUE r_mpfi_union (int argc, VALUE *argv, VALUE self)
|
918
|
+
static VALUE r_mpfi_union (int argc, VALUE *argv, VALUE self)
|
919
|
+
{
|
839
920
|
MPFI *ptr_self, *ptr_a0, *ptr_ret;
|
840
921
|
r_mpfi_get_struct(ptr_self, self);
|
841
922
|
r_mpfi_get_struct(ptr_a0, argv[0]);
|
@@ -849,7 +930,8 @@ static VALUE r_mpfi_union (int argc, VALUE *argv, VALUE self){
|
|
849
930
|
|
850
931
|
/* ------------------------------ Miscellaneous Interval Functions start ------------------------------ */
|
851
932
|
|
852
|
-
static VALUE r_mpfi_increase (VALUE self, VALUE a0)
|
933
|
+
static VALUE r_mpfi_increase (VALUE self, VALUE a0)
|
934
|
+
{
|
853
935
|
MPFI *ptr_self;
|
854
936
|
r_mpfi_get_struct(ptr_self, self);
|
855
937
|
MPFR *ptr_a0;
|
@@ -859,7 +941,8 @@ static VALUE r_mpfi_increase (VALUE self, VALUE a0){
|
|
859
941
|
return self;
|
860
942
|
}
|
861
943
|
|
862
|
-
static VALUE r_mpfi_blow (int argc, VALUE *argv, VALUE self)
|
944
|
+
static VALUE r_mpfi_blow (int argc, VALUE *argv, VALUE self)
|
945
|
+
{
|
863
946
|
MPFI *ptr_self, *ptr_ret;
|
864
947
|
r_mpfi_get_struct(ptr_self, self);
|
865
948
|
VALUE val_ret;
|
@@ -868,7 +951,8 @@ static VALUE r_mpfi_blow (int argc, VALUE *argv, VALUE self){
|
|
868
951
|
return val_ret;
|
869
952
|
}
|
870
953
|
|
871
|
-
static VALUE r_mpfi_bisect (int argc, VALUE *argv, VALUE self)
|
954
|
+
static VALUE r_mpfi_bisect (int argc, VALUE *argv, VALUE self)
|
955
|
+
{
|
872
956
|
MPFI *ptr_self, *ptr_ret1, *ptr_ret2;
|
873
957
|
r_mpfi_get_struct(ptr_self, self);
|
874
958
|
int prec = r_mpfr_prec_from_optional_argument(0, 1, argc, argv);
|
@@ -881,7 +965,8 @@ static VALUE r_mpfi_bisect (int argc, VALUE *argv, VALUE self){
|
|
881
965
|
|
882
966
|
/* Retrun 0 if this function puts subdivision to *ret. */
|
883
967
|
/* Otherwise, return -1. */
|
884
|
-
void r_mpfi_subdivision_func(int num, MPFI *ret[], mpfi_t x)
|
968
|
+
void r_mpfi_subdivision_func(int num, MPFI *ret[], mpfi_t x)
|
969
|
+
{
|
885
970
|
int i;
|
886
971
|
mpfr_t l;
|
887
972
|
mpfr_init(l);
|
@@ -909,7 +994,8 @@ void r_mpfi_subdivision_func(int num, MPFI *ret[], mpfi_t x){
|
|
909
994
|
mpfr_clear(l);
|
910
995
|
}
|
911
996
|
|
912
|
-
static VALUE r_mpfi_subdivision (int argc, VALUE *argv, VALUE self)
|
997
|
+
static VALUE r_mpfi_subdivision (int argc, VALUE *argv, VALUE self)
|
998
|
+
{
|
913
999
|
MPFI *ptr_self;
|
914
1000
|
r_mpfi_get_struct(ptr_self, self);
|
915
1001
|
int i, num = NUM2INT(argv[0]);
|
@@ -926,7 +1012,8 @@ static VALUE r_mpfi_subdivision (int argc, VALUE *argv, VALUE self){
|
|
926
1012
|
|
927
1013
|
/* ------------------------------ Mathematical Basic Arithmetic Functions start ------------------------------ */
|
928
1014
|
|
929
|
-
static VALUE r_mpfi_math_add (int argc, VALUE *argv, VALUE self)
|
1015
|
+
static VALUE r_mpfi_math_add (int argc, VALUE *argv, VALUE self)
|
1016
|
+
{
|
930
1017
|
VALUE val_ret;
|
931
1018
|
MPFI *ptr_a0, *ptr_ret;
|
932
1019
|
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(2, 3, argc, argv));
|
@@ -953,7 +1040,8 @@ static VALUE r_mpfi_math_add (int argc, VALUE *argv, VALUE self){
|
|
953
1040
|
return val_ret;
|
954
1041
|
}
|
955
1042
|
|
956
|
-
static VALUE r_mpfi_math_sub (int argc, VALUE *argv, VALUE self)
|
1043
|
+
static VALUE r_mpfi_math_sub (int argc, VALUE *argv, VALUE self)
|
1044
|
+
{
|
957
1045
|
VALUE val_ret;
|
958
1046
|
MPFI *ptr_a0, *ptr_ret;
|
959
1047
|
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(2, 3, argc, argv));
|
@@ -980,7 +1068,8 @@ static VALUE r_mpfi_math_sub (int argc, VALUE *argv, VALUE self){
|
|
980
1068
|
return val_ret;
|
981
1069
|
}
|
982
1070
|
|
983
|
-
static VALUE r_mpfi_math_mul (int argc, VALUE *argv, VALUE self)
|
1071
|
+
static VALUE r_mpfi_math_mul (int argc, VALUE *argv, VALUE self)
|
1072
|
+
{
|
984
1073
|
VALUE val_ret;
|
985
1074
|
MPFI *ptr_a0, *ptr_ret;
|
986
1075
|
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(2, 3, argc, argv));
|
@@ -1007,7 +1096,8 @@ static VALUE r_mpfi_math_mul (int argc, VALUE *argv, VALUE self){
|
|
1007
1096
|
return val_ret;
|
1008
1097
|
}
|
1009
1098
|
|
1010
|
-
static VALUE r_mpfi_math_div (int argc, VALUE *argv, VALUE self)
|
1099
|
+
static VALUE r_mpfi_math_div (int argc, VALUE *argv, VALUE self)
|
1100
|
+
{
|
1011
1101
|
VALUE val_ret;
|
1012
1102
|
MPFI *ptr_a0, *ptr_ret;
|
1013
1103
|
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(2, 3, argc, argv));
|
@@ -1034,7 +1124,9 @@ static VALUE r_mpfi_math_div (int argc, VALUE *argv, VALUE self){
|
|
1034
1124
|
return val_ret;
|
1035
1125
|
}
|
1036
1126
|
|
1037
|
-
|
1127
|
+
/* mpfi_sqr(ret, p1) */
|
1128
|
+
static VALUE r_mpfi_math_sqr (int argc, VALUE *argv, VALUE self)
|
1129
|
+
{
|
1038
1130
|
MPFI *ptr_a0, *ptr_ret;
|
1039
1131
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1040
1132
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1044,7 +1136,9 @@ static VALUE r_mpfi_math_sqr (int argc, VALUE *argv, VALUE self){
|
|
1044
1136
|
return val_ret;
|
1045
1137
|
}
|
1046
1138
|
|
1047
|
-
|
1139
|
+
/* mpfi_sqrt(ret, p1) */
|
1140
|
+
static VALUE r_mpfi_math_sqrt (int argc, VALUE *argv, VALUE self)
|
1141
|
+
{
|
1048
1142
|
MPFI *ptr_a0, *ptr_ret;
|
1049
1143
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1050
1144
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1058,7 +1152,9 @@ static VALUE r_mpfi_math_sqrt (int argc, VALUE *argv, VALUE self){
|
|
1058
1152
|
|
1059
1153
|
/* ------------------------------ Special Functions start ------------------------------ */
|
1060
1154
|
|
1061
|
-
|
1155
|
+
/* mpfi_log(ret, p1) */
|
1156
|
+
static VALUE r_mpfi_math_log (int argc, VALUE *argv, VALUE self)
|
1157
|
+
{
|
1062
1158
|
MPFI *ptr_a0, *ptr_ret;
|
1063
1159
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1064
1160
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1068,7 +1164,9 @@ static VALUE r_mpfi_math_log (int argc, VALUE *argv, VALUE self){
|
|
1068
1164
|
return val_ret;
|
1069
1165
|
}
|
1070
1166
|
|
1071
|
-
|
1167
|
+
/* mpfi_exp(ret, p1) */
|
1168
|
+
static VALUE r_mpfi_math_exp (int argc, VALUE *argv, VALUE self)
|
1169
|
+
{
|
1072
1170
|
MPFI *ptr_a0, *ptr_ret;
|
1073
1171
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1074
1172
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1078,7 +1176,9 @@ static VALUE r_mpfi_math_exp (int argc, VALUE *argv, VALUE self){
|
|
1078
1176
|
return val_ret;
|
1079
1177
|
}
|
1080
1178
|
|
1081
|
-
|
1179
|
+
/* mpfi_exp2(ret, p1) */
|
1180
|
+
static VALUE r_mpfi_math_exp2 (int argc, VALUE *argv, VALUE self)
|
1181
|
+
{
|
1082
1182
|
MPFI *ptr_a0, *ptr_ret;
|
1083
1183
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1084
1184
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1088,7 +1188,9 @@ static VALUE r_mpfi_math_exp2 (int argc, VALUE *argv, VALUE self){
|
|
1088
1188
|
return val_ret;
|
1089
1189
|
}
|
1090
1190
|
|
1091
|
-
|
1191
|
+
/* mpfi_cos(ret, p1) */
|
1192
|
+
static VALUE r_mpfi_math_cos (int argc, VALUE *argv, VALUE self)
|
1193
|
+
{
|
1092
1194
|
MPFI *ptr_a0, *ptr_ret;
|
1093
1195
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1094
1196
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1098,7 +1200,9 @@ static VALUE r_mpfi_math_cos (int argc, VALUE *argv, VALUE self){
|
|
1098
1200
|
return val_ret;
|
1099
1201
|
}
|
1100
1202
|
|
1101
|
-
|
1203
|
+
/* mpfi_sin(ret, p1) */
|
1204
|
+
static VALUE r_mpfi_math_sin (int argc, VALUE *argv, VALUE self)
|
1205
|
+
{
|
1102
1206
|
MPFI *ptr_a0, *ptr_ret;
|
1103
1207
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1104
1208
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1108,7 +1212,9 @@ static VALUE r_mpfi_math_sin (int argc, VALUE *argv, VALUE self){
|
|
1108
1212
|
return val_ret;
|
1109
1213
|
}
|
1110
1214
|
|
1111
|
-
|
1215
|
+
/* mpfi_tan(ret, p1) */
|
1216
|
+
static VALUE r_mpfi_math_tan (int argc, VALUE *argv, VALUE self)
|
1217
|
+
{
|
1112
1218
|
MPFI *ptr_a0, *ptr_ret;
|
1113
1219
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1114
1220
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1118,7 +1224,9 @@ static VALUE r_mpfi_math_tan (int argc, VALUE *argv, VALUE self){
|
|
1118
1224
|
return val_ret;
|
1119
1225
|
}
|
1120
1226
|
|
1121
|
-
|
1227
|
+
/* mpfi_acos(ret, p1) */
|
1228
|
+
static VALUE r_mpfi_math_acos (int argc, VALUE *argv, VALUE self)
|
1229
|
+
{
|
1122
1230
|
MPFI *ptr_a0, *ptr_ret;
|
1123
1231
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1124
1232
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1128,7 +1236,9 @@ static VALUE r_mpfi_math_acos (int argc, VALUE *argv, VALUE self){
|
|
1128
1236
|
return val_ret;
|
1129
1237
|
}
|
1130
1238
|
|
1131
|
-
|
1239
|
+
/* mpfi_asin(ret, p1) */
|
1240
|
+
static VALUE r_mpfi_math_asin (int argc, VALUE *argv, VALUE self)
|
1241
|
+
{
|
1132
1242
|
MPFI *ptr_a0, *ptr_ret;
|
1133
1243
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1134
1244
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1138,7 +1248,9 @@ static VALUE r_mpfi_math_asin (int argc, VALUE *argv, VALUE self){
|
|
1138
1248
|
return val_ret;
|
1139
1249
|
}
|
1140
1250
|
|
1141
|
-
|
1251
|
+
/* mpfi_atan(ret, p1) */
|
1252
|
+
static VALUE r_mpfi_math_atan (int argc, VALUE *argv, VALUE self)
|
1253
|
+
{
|
1142
1254
|
MPFI *ptr_a0, *ptr_ret;
|
1143
1255
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1144
1256
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1148,7 +1260,9 @@ static VALUE r_mpfi_math_atan (int argc, VALUE *argv, VALUE self){
|
|
1148
1260
|
return val_ret;
|
1149
1261
|
}
|
1150
1262
|
|
1151
|
-
|
1263
|
+
/* mpfi_cosh(ret, p1) */
|
1264
|
+
static VALUE r_mpfi_math_cosh (int argc, VALUE *argv, VALUE self)
|
1265
|
+
{
|
1152
1266
|
MPFI *ptr_a0, *ptr_ret;
|
1153
1267
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1154
1268
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1158,7 +1272,9 @@ static VALUE r_mpfi_math_cosh (int argc, VALUE *argv, VALUE self){
|
|
1158
1272
|
return val_ret;
|
1159
1273
|
}
|
1160
1274
|
|
1161
|
-
|
1275
|
+
/* mpfi_sinh(ret, p1) */
|
1276
|
+
static VALUE r_mpfi_math_sinh (int argc, VALUE *argv, VALUE self)
|
1277
|
+
{
|
1162
1278
|
MPFI *ptr_a0, *ptr_ret;
|
1163
1279
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1164
1280
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1168,7 +1284,9 @@ static VALUE r_mpfi_math_sinh (int argc, VALUE *argv, VALUE self){
|
|
1168
1284
|
return val_ret;
|
1169
1285
|
}
|
1170
1286
|
|
1171
|
-
|
1287
|
+
/* mpfi_tanh(ret, p1) */
|
1288
|
+
static VALUE r_mpfi_math_tanh (int argc, VALUE *argv, VALUE self)
|
1289
|
+
{
|
1172
1290
|
MPFI *ptr_a0, *ptr_ret;
|
1173
1291
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1174
1292
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1178,7 +1296,9 @@ static VALUE r_mpfi_math_tanh (int argc, VALUE *argv, VALUE self){
|
|
1178
1296
|
return val_ret;
|
1179
1297
|
}
|
1180
1298
|
|
1181
|
-
|
1299
|
+
/* mpfi_acosh(ret, p1) */
|
1300
|
+
static VALUE r_mpfi_math_acosh (int argc, VALUE *argv, VALUE self)
|
1301
|
+
{
|
1182
1302
|
MPFI *ptr_a0, *ptr_ret;
|
1183
1303
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1184
1304
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1188,7 +1308,9 @@ static VALUE r_mpfi_math_acosh (int argc, VALUE *argv, VALUE self){
|
|
1188
1308
|
return val_ret;
|
1189
1309
|
}
|
1190
1310
|
|
1191
|
-
|
1311
|
+
/* mpfi_asinh(ret, p1) */
|
1312
|
+
static VALUE r_mpfi_math_asinh (int argc, VALUE *argv, VALUE self)
|
1313
|
+
{
|
1192
1314
|
MPFI *ptr_a0, *ptr_ret;
|
1193
1315
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1194
1316
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1198,7 +1320,9 @@ static VALUE r_mpfi_math_asinh (int argc, VALUE *argv, VALUE self){
|
|
1198
1320
|
return val_ret;
|
1199
1321
|
}
|
1200
1322
|
|
1201
|
-
|
1323
|
+
/* mpfi_atanh(ret, p1) */
|
1324
|
+
static VALUE r_mpfi_math_atanh (int argc, VALUE *argv, VALUE self)
|
1325
|
+
{
|
1202
1326
|
MPFI *ptr_a0, *ptr_ret;
|
1203
1327
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1204
1328
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1208,7 +1332,9 @@ static VALUE r_mpfi_math_atanh (int argc, VALUE *argv, VALUE self){
|
|
1208
1332
|
return val_ret;
|
1209
1333
|
}
|
1210
1334
|
|
1211
|
-
|
1335
|
+
/* mpfi_log1p(ret, p1) */
|
1336
|
+
static VALUE r_mpfi_math_log1p (int argc, VALUE *argv, VALUE self)
|
1337
|
+
{
|
1212
1338
|
MPFI *ptr_a0, *ptr_ret;
|
1213
1339
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1214
1340
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1218,7 +1344,9 @@ static VALUE r_mpfi_math_log1p (int argc, VALUE *argv, VALUE self){
|
|
1218
1344
|
return val_ret;
|
1219
1345
|
}
|
1220
1346
|
|
1221
|
-
|
1347
|
+
/* mpfi_expm1(ret, p1) */
|
1348
|
+
static VALUE r_mpfi_math_expm1 (int argc, VALUE *argv, VALUE self)
|
1349
|
+
{
|
1222
1350
|
MPFI *ptr_a0, *ptr_ret;
|
1223
1351
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1224
1352
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1228,7 +1356,9 @@ static VALUE r_mpfi_math_expm1 (int argc, VALUE *argv, VALUE self){
|
|
1228
1356
|
return val_ret;
|
1229
1357
|
}
|
1230
1358
|
|
1231
|
-
|
1359
|
+
/* mpfi_log2(ret, p1) */
|
1360
|
+
static VALUE r_mpfi_math_log2 (int argc, VALUE *argv, VALUE self)
|
1361
|
+
{
|
1232
1362
|
MPFI *ptr_a0, *ptr_ret;
|
1233
1363
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1234
1364
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1238,7 +1368,9 @@ static VALUE r_mpfi_math_log2 (int argc, VALUE *argv, VALUE self){
|
|
1238
1368
|
return val_ret;
|
1239
1369
|
}
|
1240
1370
|
|
1241
|
-
|
1371
|
+
/* mpfi_log10(ret, p1) */
|
1372
|
+
static VALUE r_mpfi_math_log10 (int argc, VALUE *argv, VALUE self)
|
1373
|
+
{
|
1242
1374
|
MPFI *ptr_a0, *ptr_ret;
|
1243
1375
|
volatile VALUE tmp_argv0 = r_mpfi_new_fi_obj(argv[0]);
|
1244
1376
|
r_mpfi_get_struct(ptr_a0, tmp_argv0);
|
@@ -1248,7 +1380,9 @@ static VALUE r_mpfi_math_log10 (int argc, VALUE *argv, VALUE self){
|
|
1248
1380
|
return val_ret;
|
1249
1381
|
}
|
1250
1382
|
|
1251
|
-
|
1383
|
+
/* mpfi_const_log2(ret) */
|
1384
|
+
static VALUE r_mpfi_math_const_log2 (int argc, VALUE *argv, VALUE self)
|
1385
|
+
{
|
1252
1386
|
MPFI *ptr_ret;
|
1253
1387
|
VALUE val_ret;
|
1254
1388
|
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
|
@@ -1256,7 +1390,9 @@ static VALUE r_mpfi_math_const_log2 (int argc, VALUE *argv, VALUE self){
|
|
1256
1390
|
return val_ret;
|
1257
1391
|
}
|
1258
1392
|
|
1259
|
-
|
1393
|
+
/* mpfi_const_pi(ret) */
|
1394
|
+
static VALUE r_mpfi_math_const_pi (int argc, VALUE *argv, VALUE self)
|
1395
|
+
{
|
1260
1396
|
MPFI *ptr_ret;
|
1261
1397
|
VALUE val_ret;
|
1262
1398
|
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
|
@@ -1264,7 +1400,9 @@ static VALUE r_mpfi_math_const_pi (int argc, VALUE *argv, VALUE self){
|
|
1264
1400
|
return val_ret;
|
1265
1401
|
}
|
1266
1402
|
|
1267
|
-
|
1403
|
+
/* mpfi_const_euler(ret) */
|
1404
|
+
static VALUE r_mpfi_math_const_euler (int argc, VALUE *argv, VALUE self)
|
1405
|
+
{
|
1268
1406
|
MPFI *ptr_ret;
|
1269
1407
|
VALUE val_ret;
|
1270
1408
|
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
|
@@ -1274,7 +1412,8 @@ static VALUE r_mpfi_math_const_euler (int argc, VALUE *argv, VALUE self){
|
|
1274
1412
|
|
1275
1413
|
/* ------------------------------ Special Functions end ------------------------------ */
|
1276
1414
|
|
1277
|
-
void Init_mpfi()
|
1415
|
+
void Init_mpfi()
|
1416
|
+
{
|
1278
1417
|
r_mpfi_class = rb_define_class("MPFI", rb_cNumeric);
|
1279
1418
|
|
1280
1419
|
/* ------------------------------ function state start ------------------------------ */
|
@@ -1283,6 +1422,7 @@ void Init_mpfi(){
|
|
1283
1422
|
/* ------------------------------ function state end ------------------------------ */
|
1284
1423
|
|
1285
1424
|
/* ------------------------------ allocation start ------------------------------ */
|
1425
|
+
rb_define_global_function("MPFI", r_mpfi_global_new, -1);
|
1286
1426
|
rb_define_alloc_func(r_mpfi_class, r_mpfi_alloc);
|
1287
1427
|
rb_define_private_method(r_mpfi_class, "initialize", r_mpfi_initialize, -1);
|
1288
1428
|
rb_define_private_method(r_mpfi_class, "initialize_copy", r_mpfi_initialize_copy, 1);
|