ruby-mpfi 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/README.rdoc +22 -9
- data/ext/mpfi/ruby_mpfi.c +71 -6
- data/ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.c +5 -4
- data/lib/mpfi/version.rb +1 -1
- metadata +27 -5
data/History.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
=== 0.0.4
|
2
|
+
* 1 bug fix:
|
3
|
+
* Fix bugs of Methods MPFI::SquareMatrix, MPFI::ColumnVector, and MPFI::RowVector.
|
4
|
+
|
1
5
|
=== 0.0.3 2009-12-19
|
2
6
|
* 1 major enhancement:
|
3
7
|
* Add methods MPFI, MPFI::Complex, MPFI::Matrix, MPFI::SquareMatrix, MPFI::ColumnVector, and MPFI::RowVector.
|
data/README.rdoc
CHANGED
@@ -3,26 +3,39 @@
|
|
3
3
|
* http://rubyforge.org/projects/ruby-mpfr/
|
4
4
|
* http://gemcutter.org/gems/ruby-mpfi/
|
5
5
|
|
6
|
-
==
|
6
|
+
== Description:
|
7
7
|
|
8
|
-
|
8
|
+
ruby-mpfi is an extended C library to use MPFI[http://gforge.inria.fr/projects/mpfi/]
|
9
|
+
which is the library of the interval arithmetic with multiprecision.
|
9
10
|
|
10
|
-
==
|
11
|
+
== Notice:
|
11
12
|
|
12
|
-
*
|
13
|
+
* Many methods have not been tested sufficiently.
|
14
|
+
* Documentation is not complete.
|
13
15
|
|
14
|
-
==
|
16
|
+
== Example:
|
17
|
+
You must require 'mpfr' to use 'mpfi'.
|
18
|
+
|
19
|
+
require "mpfr"
|
20
|
+
require "mpfi"
|
21
|
+
MPFR.set_default_prec(100)
|
22
|
+
a = MPFI(-5)
|
23
|
+
b = MPFI(3.4)
|
24
|
+
c = a - b
|
15
25
|
|
16
|
-
FIX (code sample of usage)
|
17
26
|
|
18
27
|
== Requirements:
|
19
28
|
|
20
|
-
*
|
21
|
-
*
|
29
|
+
* Ruby[http://www.ruby-lang.org/] 1.9.1 or later
|
30
|
+
* MPFR[http://www.mpfr.org/] 2.4.1 or later
|
31
|
+
* MPFI[http://gforge.inria.fr/projects/mpfi/] 1.3.4 or later
|
22
32
|
* ruby-mpfr
|
23
33
|
|
24
34
|
== Install:
|
25
|
-
|
35
|
+
The package of rubygems of ruby-mpfr is provided.
|
36
|
+
You can install ruby-mpfr with the following command
|
37
|
+
in the system satisfying the above requirements.
|
38
|
+
|
26
39
|
$ sudo gem install ruby-mpfi
|
27
40
|
|
28
41
|
== License:
|
data/ext/mpfi/ruby_mpfi.c
CHANGED
@@ -87,6 +87,8 @@ VALUE r_mpfi_new_fi_obj(VALUE obj)
|
|
87
87
|
}
|
88
88
|
|
89
89
|
/* Initializing and Assigning Intervals */
|
90
|
+
|
91
|
+
/* Allocation function. */
|
90
92
|
static VALUE r_mpfi_alloc(VALUE self)
|
91
93
|
{
|
92
94
|
MPFI *ptr;
|
@@ -124,6 +126,7 @@ static VALUE r_mpfi_global_new(int argc, VALUE *argv, VALUE self)
|
|
124
126
|
return val;
|
125
127
|
}
|
126
128
|
|
129
|
+
/* Two optional arguments are acceptable. First argument is value and second is precision. */
|
127
130
|
static VALUE r_mpfi_initialize(int argc, VALUE *argv, VALUE self)
|
128
131
|
{
|
129
132
|
MPFI *ptr;
|
@@ -132,6 +135,7 @@ static VALUE r_mpfi_initialize(int argc, VALUE *argv, VALUE self)
|
|
132
135
|
return Qtrue;
|
133
136
|
}
|
134
137
|
|
138
|
+
/* initialize_copy. */
|
135
139
|
static VALUE r_mpfi_initialize_copy(VALUE self, VALUE other)
|
136
140
|
{
|
137
141
|
MPFI *ptr_self, *ptr_other;
|
@@ -153,6 +157,7 @@ static VALUE r_mpfi_coerce(VALUE self, VALUE other)
|
|
153
157
|
return rb_ary_new3(2, val_other, self);
|
154
158
|
}
|
155
159
|
|
160
|
+
/* Set the value. */
|
156
161
|
static VALUE r_mpfi_set (VALUE self, VALUE arg)
|
157
162
|
{
|
158
163
|
MPFI *ptr_self;
|
@@ -161,6 +166,7 @@ static VALUE r_mpfi_set (VALUE self, VALUE arg)
|
|
161
166
|
return self;
|
162
167
|
}
|
163
168
|
|
169
|
+
/* Swap value for other MPFI instance. */
|
164
170
|
static VALUE r_mpfi_swap (VALUE self, VALUE other)
|
165
171
|
{
|
166
172
|
MPFI *ptr_self, *ptr_other;
|
@@ -175,7 +181,10 @@ static VALUE r_mpfi_swap (VALUE self, VALUE other)
|
|
175
181
|
/* ------------------------------ Rounding Modes and Precision Handling start ------------------------------*/
|
176
182
|
|
177
183
|
/* Need to consider returned value later. */
|
178
|
-
/*
|
184
|
+
/*
|
185
|
+
Set the precision of self.
|
186
|
+
Notice that mpfi_set_prec is different from reference manual. This is strange.
|
187
|
+
*/
|
179
188
|
static VALUE r_mpfi_set_prec (VALUE self, VALUE prec)
|
180
189
|
{
|
181
190
|
MPFI *ptr_self;
|
@@ -188,6 +197,7 @@ static VALUE r_mpfi_set_prec (VALUE self, VALUE prec)
|
|
188
197
|
}
|
189
198
|
|
190
199
|
/* Need to consider returned value later. */
|
200
|
+
/* Return precision of self. */
|
191
201
|
static VALUE r_mpfi_get_prec (VALUE self)
|
192
202
|
{
|
193
203
|
MPFI *ptr_self;
|
@@ -196,6 +206,7 @@ static VALUE r_mpfi_get_prec (VALUE self)
|
|
196
206
|
}
|
197
207
|
|
198
208
|
/* Need to consider returned value later. */
|
209
|
+
/* mpfi_round_prec(self, prec) */
|
199
210
|
static VALUE r_mpfi_round_prec (VALUE self, VALUE prec)
|
200
211
|
{
|
201
212
|
MPFI *ptr_self;
|
@@ -207,6 +218,7 @@ static VALUE r_mpfi_round_prec (VALUE self, VALUE prec)
|
|
207
218
|
|
208
219
|
/* ------------------------------ string start ------------------------------ */
|
209
220
|
|
221
|
+
/* String for inspect. */
|
210
222
|
static VALUE r_mpfi_inspect(VALUE self)
|
211
223
|
{
|
212
224
|
MPFI *ptr_s;
|
@@ -219,6 +231,7 @@ static VALUE r_mpfi_inspect(VALUE self)
|
|
219
231
|
return ret_val;
|
220
232
|
}
|
221
233
|
|
234
|
+
/* Return array having two strings to which endpoints is converted. */
|
222
235
|
static VALUE r_mpfi_to_str_ary(VALUE self)
|
223
236
|
{
|
224
237
|
MPFI *ptr_self;
|
@@ -232,7 +245,7 @@ static VALUE r_mpfi_to_str_ary(VALUE self)
|
|
232
245
|
return rb_ary_new3(2, str1, str2);
|
233
246
|
}
|
234
247
|
|
235
|
-
/*
|
248
|
+
/* Return array having two strings to which endpoints are converted by mpfr_asprintf with format_str. */
|
236
249
|
static VALUE r_mpfi_to_strf_ary(VALUE self, VALUE format_str)
|
237
250
|
{
|
238
251
|
MPFI *ptr_self;
|
@@ -251,6 +264,7 @@ static VALUE r_mpfi_to_strf_ary(VALUE self, VALUE format_str)
|
|
251
264
|
|
252
265
|
/* ------------------------------ Basic Arithmetic Functions start ------------------------------ */
|
253
266
|
|
267
|
+
/* Return self + p1. */
|
254
268
|
static VALUE r_mpfi_add (VALUE self, VALUE other)
|
255
269
|
{
|
256
270
|
VALUE val_ret;
|
@@ -279,6 +293,7 @@ static VALUE r_mpfi_add (VALUE self, VALUE other)
|
|
279
293
|
return val_ret;
|
280
294
|
}
|
281
295
|
|
296
|
+
/* Return self - p1. */
|
282
297
|
static VALUE r_mpfi_sub (VALUE self, VALUE other)
|
283
298
|
{
|
284
299
|
VALUE val_ret;
|
@@ -307,6 +322,7 @@ static VALUE r_mpfi_sub (VALUE self, VALUE other)
|
|
307
322
|
return val_ret;
|
308
323
|
}
|
309
324
|
|
325
|
+
/* Return self * p1. */
|
310
326
|
static VALUE r_mpfi_mul (VALUE self, VALUE other)
|
311
327
|
{
|
312
328
|
VALUE val_ret;
|
@@ -335,6 +351,7 @@ static VALUE r_mpfi_mul (VALUE self, VALUE other)
|
|
335
351
|
return val_ret;
|
336
352
|
}
|
337
353
|
|
354
|
+
/* Return self / p1. */
|
338
355
|
static VALUE r_mpfi_div (VALUE self, VALUE other)
|
339
356
|
{
|
340
357
|
VALUE val_ret;
|
@@ -363,6 +380,7 @@ static VALUE r_mpfi_div (VALUE self, VALUE other)
|
|
363
380
|
return val_ret;
|
364
381
|
}
|
365
382
|
|
383
|
+
/* mpfi_mul_2si(ret, self, p1) */
|
366
384
|
static VALUE r_mpfi_mul_2si (int argc, VALUE *argv, VALUE self)
|
367
385
|
{
|
368
386
|
MPFI *ptr_self, *ptr_ret;
|
@@ -373,6 +391,7 @@ static VALUE r_mpfi_mul_2si (int argc, VALUE *argv, VALUE self)
|
|
373
391
|
return val_ret;
|
374
392
|
}
|
375
393
|
|
394
|
+
/* mpfi_div_2si(ret, self, p1) */
|
376
395
|
static VALUE r_mpfi_div_2si (int argc, VALUE *argv, VALUE self)
|
377
396
|
{
|
378
397
|
MPFI *ptr_self, *ptr_ret;
|
@@ -383,6 +402,7 @@ static VALUE r_mpfi_div_2si (int argc, VALUE *argv, VALUE self)
|
|
383
402
|
return val_ret;
|
384
403
|
}
|
385
404
|
|
405
|
+
/* mpfi_neg(ret, self) */
|
386
406
|
static VALUE r_mpfi_neg(int argc, VALUE *argv, VALUE self)
|
387
407
|
{
|
388
408
|
MPFI *ptr_self, *ptr_ret;
|
@@ -393,6 +413,7 @@ static VALUE r_mpfi_neg(int argc, VALUE *argv, VALUE self)
|
|
393
413
|
return val_ret;
|
394
414
|
}
|
395
415
|
|
416
|
+
/* mpfi_inv(ret, self) */
|
396
417
|
static VALUE r_mpfi_inv(int argc, VALUE *argv, VALUE self)
|
397
418
|
{
|
398
419
|
MPFI *ptr_self, *ptr_ret;
|
@@ -403,6 +424,7 @@ static VALUE r_mpfi_inv(int argc, VALUE *argv, VALUE self)
|
|
403
424
|
return val_ret;
|
404
425
|
}
|
405
426
|
|
427
|
+
/* mpfi_abs(ret, self) */
|
406
428
|
static VALUE r_mpfi_abs(int argc, VALUE *argv, VALUE self)
|
407
429
|
{
|
408
430
|
MPFI *ptr_self, *ptr_ret;
|
@@ -417,6 +439,7 @@ static VALUE r_mpfi_abs(int argc, VALUE *argv, VALUE self)
|
|
417
439
|
|
418
440
|
/* ------------------------------ Comparison Functions start ------------------------------ */
|
419
441
|
|
442
|
+
/* For MPFI instance, use mpfi_cmp. */
|
420
443
|
static VALUE r_mpfi_cmp (VALUE self, VALUE other)
|
421
444
|
{
|
422
445
|
MPFI *ptr_self;
|
@@ -444,6 +467,7 @@ static VALUE r_mpfi_cmp (VALUE self, VALUE other)
|
|
444
467
|
return NUM2INT(ret);
|
445
468
|
}
|
446
469
|
|
470
|
+
/* Return true if mpfi_is_pos(self) > 0. Otherwise, nil. */
|
447
471
|
static VALUE r_mpfi_is_pos (VALUE self)
|
448
472
|
{
|
449
473
|
MPFI *ptr_self;
|
@@ -455,6 +479,7 @@ static VALUE r_mpfi_is_pos (VALUE self)
|
|
455
479
|
}
|
456
480
|
}
|
457
481
|
|
482
|
+
/* Return true if mpfi_is_strictly_pos(self) > 0. Otherwise, nil. */
|
458
483
|
static VALUE r_mpfi_is_strictly_pos (VALUE self)
|
459
484
|
{
|
460
485
|
MPFI *ptr_self;
|
@@ -466,6 +491,7 @@ static VALUE r_mpfi_is_strictly_pos (VALUE self)
|
|
466
491
|
}
|
467
492
|
}
|
468
493
|
|
494
|
+
/* Return true if mpfi_is_nonneg(self) > 0. Otherwise, nil. */
|
469
495
|
static VALUE r_mpfi_is_nonneg (VALUE self)
|
470
496
|
{
|
471
497
|
MPFI *ptr_self;
|
@@ -477,6 +503,7 @@ static VALUE r_mpfi_is_nonneg (VALUE self)
|
|
477
503
|
}
|
478
504
|
}
|
479
505
|
|
506
|
+
/* Return true if mpfi_is_neg(self) > 0. Otherwise, nil. */
|
480
507
|
static VALUE r_mpfi_is_neg (VALUE self)
|
481
508
|
{
|
482
509
|
MPFI *ptr_self;
|
@@ -488,6 +515,7 @@ static VALUE r_mpfi_is_neg (VALUE self)
|
|
488
515
|
}
|
489
516
|
}
|
490
517
|
|
518
|
+
/* Return true if mpfi_is_strictly_neg(self) > 0. Otherwise, nil. */
|
491
519
|
static VALUE r_mpfi_is_strictly_neg (VALUE self)
|
492
520
|
{
|
493
521
|
MPFI *ptr_self;
|
@@ -499,6 +527,7 @@ static VALUE r_mpfi_is_strictly_neg (VALUE self)
|
|
499
527
|
}
|
500
528
|
}
|
501
529
|
|
530
|
+
/* Return true if mpfi_is_nonpos(self) > 0. Otherwise, nil. */
|
502
531
|
static VALUE r_mpfi_is_nonpos (VALUE self)
|
503
532
|
{
|
504
533
|
MPFI *ptr_self;
|
@@ -510,6 +539,7 @@ static VALUE r_mpfi_is_nonpos (VALUE self)
|
|
510
539
|
}
|
511
540
|
}
|
512
541
|
|
542
|
+
/* Return true if mpfi_is_zero(self) > 0. Otherwise, nil. */
|
513
543
|
static VALUE r_mpfi_is_zero (VALUE self)
|
514
544
|
{
|
515
545
|
MPFI *ptr_self;
|
@@ -521,6 +551,7 @@ static VALUE r_mpfi_is_zero (VALUE self)
|
|
521
551
|
}
|
522
552
|
}
|
523
553
|
|
554
|
+
/* Return true if mpfi_has_zero(self) > 0. Otherwise, nil. */
|
524
555
|
static VALUE r_mpfi_has_zero (VALUE self)
|
525
556
|
{
|
526
557
|
MPFI *ptr_self;
|
@@ -532,6 +563,7 @@ static VALUE r_mpfi_has_zero (VALUE self)
|
|
532
563
|
}
|
533
564
|
}
|
534
565
|
|
566
|
+
/* Return true if mpfi_nan_p(self) != 0. Otherwise, nil. */
|
535
567
|
static VALUE r_mpfi_nan_p (VALUE self)
|
536
568
|
{
|
537
569
|
MPFI *ptr_self;
|
@@ -543,6 +575,7 @@ static VALUE r_mpfi_nan_p (VALUE self)
|
|
543
575
|
}
|
544
576
|
}
|
545
577
|
|
578
|
+
/* Return true if mpfi_inf_p(self) != 0. Otherwise, nil. */
|
546
579
|
static VALUE r_mpfi_inf_p (VALUE self)
|
547
580
|
{
|
548
581
|
MPFI *ptr_self;
|
@@ -554,6 +587,7 @@ static VALUE r_mpfi_inf_p (VALUE self)
|
|
554
587
|
}
|
555
588
|
}
|
556
589
|
|
590
|
+
/* Return true if mpfi_bounded_p(self) != 0. Otherwise, nil. */
|
557
591
|
static VALUE r_mpfi_bounded_p (VALUE self)
|
558
592
|
{
|
559
593
|
MPFI *ptr_self;
|
@@ -586,6 +620,7 @@ static VALUE r_mpfi_equal_p (VALUE self, VALUE other)
|
|
586
620
|
|
587
621
|
/* ------------------------------ Interval Functions with Floating-point Results start ------------------------------ */
|
588
622
|
|
623
|
+
/* mpfi_diam_abs(ret, self) */
|
589
624
|
static VALUE r_mpfi_diam_abs (int argc, VALUE *argv, VALUE self)
|
590
625
|
{
|
591
626
|
MPFI *ptr_self;
|
@@ -597,6 +632,7 @@ static VALUE r_mpfi_diam_abs (int argc, VALUE *argv, VALUE self)
|
|
597
632
|
return val_ret;
|
598
633
|
}
|
599
634
|
|
635
|
+
/* mpfi_diam_rel(ret, self) */
|
600
636
|
static VALUE r_mpfi_diam_rel (int argc, VALUE *argv, VALUE self)
|
601
637
|
{
|
602
638
|
MPFI *ptr_self;
|
@@ -608,6 +644,7 @@ static VALUE r_mpfi_diam_rel (int argc, VALUE *argv, VALUE self)
|
|
608
644
|
return val_ret;
|
609
645
|
}
|
610
646
|
|
647
|
+
/* mpfi_diam(ret, self) */
|
611
648
|
static VALUE r_mpfi_diam (int argc, VALUE *argv, VALUE self)
|
612
649
|
{
|
613
650
|
MPFI *ptr_self;
|
@@ -619,6 +656,7 @@ static VALUE r_mpfi_diam (int argc, VALUE *argv, VALUE self)
|
|
619
656
|
return val_ret;
|
620
657
|
}
|
621
658
|
|
659
|
+
/* mpfi_mag(ret, self) */
|
622
660
|
static VALUE r_mpfi_mag (int argc, VALUE *argv, VALUE self)
|
623
661
|
{
|
624
662
|
MPFI *ptr_self;
|
@@ -630,6 +668,7 @@ static VALUE r_mpfi_mag (int argc, VALUE *argv, VALUE self)
|
|
630
668
|
return val_ret;
|
631
669
|
}
|
632
670
|
|
671
|
+
/* mpfi_mig(ret, self) */
|
633
672
|
static VALUE r_mpfi_mig (int argc, VALUE *argv, VALUE self)
|
634
673
|
{
|
635
674
|
MPFI *ptr_self;
|
@@ -641,6 +680,7 @@ static VALUE r_mpfi_mig (int argc, VALUE *argv, VALUE self)
|
|
641
680
|
return val_ret;
|
642
681
|
}
|
643
682
|
|
683
|
+
/* mpfi_mid(ret, self) */
|
644
684
|
static VALUE r_mpfi_mid (int argc, VALUE *argv, VALUE self)
|
645
685
|
{
|
646
686
|
MPFI *ptr_self;
|
@@ -652,6 +692,7 @@ static VALUE r_mpfi_mid (int argc, VALUE *argv, VALUE self)
|
|
652
692
|
return val_ret;
|
653
693
|
}
|
654
694
|
|
695
|
+
/* Return MPFI instance of which value is middle of self. */
|
655
696
|
static VALUE r_mpfi_mid_interval (int argc, VALUE *argv, VALUE self)
|
656
697
|
{
|
657
698
|
MPFI *ptr_self, *ptr_ret;
|
@@ -662,6 +703,7 @@ static VALUE r_mpfi_mid_interval (int argc, VALUE *argv, VALUE self)
|
|
662
703
|
return val_ret;
|
663
704
|
}
|
664
705
|
|
706
|
+
/* mpfi_alea(ret, self) */
|
665
707
|
static VALUE r_mpfi_alea (int argc, VALUE *argv, VALUE self)
|
666
708
|
{
|
667
709
|
MPFI *ptr_self;
|
@@ -677,6 +719,7 @@ static VALUE r_mpfi_alea (int argc, VALUE *argv, VALUE self)
|
|
677
719
|
|
678
720
|
/* ------------------------------ Conversion Functions start ------------------------------ */
|
679
721
|
|
722
|
+
/* Return float by mpfi_get_d(self). */
|
680
723
|
static VALUE r_mpfi_get_d(VALUE self)
|
681
724
|
{
|
682
725
|
MPFI *ptr_self;
|
@@ -684,6 +727,7 @@ static VALUE r_mpfi_get_d(VALUE self)
|
|
684
727
|
return rb_float_new(mpfi_get_d(ptr_self));
|
685
728
|
}
|
686
729
|
|
730
|
+
/* Return MPFR by mpfi_get_fr(ret, self). */
|
687
731
|
static VALUE r_mpfi_get_fr(VALUE self)
|
688
732
|
{
|
689
733
|
MPFI *ptr_self;
|
@@ -698,6 +742,7 @@ static VALUE r_mpfi_get_fr(VALUE self)
|
|
698
742
|
|
699
743
|
/* ------------------------------ Functions Operating on Endpoints start ------------------------------ */
|
700
744
|
|
745
|
+
/* mpfi_get_left(ret, self) */
|
701
746
|
static VALUE r_mpfi_get_left (VALUE self)
|
702
747
|
{
|
703
748
|
VALUE val_ret;
|
@@ -709,6 +754,7 @@ static VALUE r_mpfi_get_left (VALUE self)
|
|
709
754
|
return val_ret;
|
710
755
|
}
|
711
756
|
|
757
|
+
/* mpfi_get_right(ret, self) */
|
712
758
|
static VALUE r_mpfi_get_right (VALUE self)
|
713
759
|
{
|
714
760
|
VALUE val_ret;
|
@@ -720,6 +766,7 @@ static VALUE r_mpfi_get_right (VALUE self)
|
|
720
766
|
return val_ret;
|
721
767
|
}
|
722
768
|
|
769
|
+
/* Return true if mpfi_revert_if_needed(self) != 0. Otherwise, nil. */
|
723
770
|
static VALUE r_mpfi_revert_if_needed (VALUE self)
|
724
771
|
{
|
725
772
|
MPFI *ptr_self;
|
@@ -731,6 +778,7 @@ static VALUE r_mpfi_revert_if_needed (VALUE self)
|
|
731
778
|
};
|
732
779
|
}
|
733
780
|
|
781
|
+
/* Extend the interval so that it contains other. */
|
734
782
|
static VALUE r_mpfi_put (VALUE self, VALUE other)
|
735
783
|
{
|
736
784
|
MPFI *ptr_self;
|
@@ -757,6 +805,7 @@ static VALUE r_mpfi_put (VALUE self, VALUE other)
|
|
757
805
|
return self;
|
758
806
|
}
|
759
807
|
|
808
|
+
/* Change two endpoints so that it are the same as a1 and a2. */
|
760
809
|
static VALUE r_mpfi_interv (VALUE self, VALUE a1, VALUE a2)
|
761
810
|
{
|
762
811
|
MPFI *ptr_self;
|
@@ -782,6 +831,7 @@ static VALUE r_mpfi_interv (VALUE self, VALUE a1, VALUE a2)
|
|
782
831
|
return self;
|
783
832
|
}
|
784
833
|
|
834
|
+
/* Return new MPFI of which endpoints are the same as p1 and p2. */
|
785
835
|
static VALUE r_mpfi_interval (int argc, VALUE *argv, VALUE self)
|
786
836
|
{
|
787
837
|
VALUE val_ret;
|
@@ -813,6 +863,7 @@ static VALUE r_mpfi_interval (int argc, VALUE *argv, VALUE self)
|
|
813
863
|
return val_ret;
|
814
864
|
}
|
815
865
|
|
866
|
+
/* Return array having two MPFR numbers which are endpoints. */
|
816
867
|
static VALUE r_mpfi_endpoints (VALUE self)
|
817
868
|
{
|
818
869
|
VALUE val_left, val_right;
|
@@ -874,6 +925,7 @@ static VALUE r_mpfi_include (VALUE self, VALUE other)
|
|
874
925
|
}
|
875
926
|
}
|
876
927
|
|
928
|
+
/* Return true if mpfi_is_empty(self) > 0. Otherwise, nil. */
|
877
929
|
static VALUE r_mpfi_is_empty (VALUE self)
|
878
930
|
{
|
879
931
|
MPFI *ptr_self;
|
@@ -885,8 +937,10 @@ static VALUE r_mpfi_is_empty (VALUE self)
|
|
885
937
|
}
|
886
938
|
}
|
887
939
|
|
888
|
-
/*
|
889
|
-
|
940
|
+
/*
|
941
|
+
If the intersection of two intervals is empty, this method returns nil.
|
942
|
+
Otherwise, it returns the intersection.
|
943
|
+
*/
|
890
944
|
static VALUE r_mpfi_intersect (int argc, VALUE *argv, VALUE self)
|
891
945
|
{
|
892
946
|
MPFI *ptr_self, *ptr_a0, *ptr_ret;
|
@@ -902,8 +956,10 @@ static VALUE r_mpfi_intersect (int argc, VALUE *argv, VALUE self)
|
|
902
956
|
}
|
903
957
|
}
|
904
958
|
|
905
|
-
/*
|
906
|
-
|
959
|
+
/*
|
960
|
+
This method returns the intersection of two intervals.
|
961
|
+
The returned value may be empty interval.
|
962
|
+
*/
|
907
963
|
static VALUE r_mpfi_intersect2 (int argc, VALUE *argv, VALUE self)
|
908
964
|
{
|
909
965
|
MPFI *ptr_self, *ptr_a0, *ptr_ret;
|
@@ -915,6 +971,7 @@ static VALUE r_mpfi_intersect2 (int argc, VALUE *argv, VALUE self)
|
|
915
971
|
return val_ret;
|
916
972
|
}
|
917
973
|
|
974
|
+
/* mpfi_union(ret, self, p1) */
|
918
975
|
static VALUE r_mpfi_union (int argc, VALUE *argv, VALUE self)
|
919
976
|
{
|
920
977
|
MPFI *ptr_self, *ptr_a0, *ptr_ret;
|
@@ -930,6 +987,7 @@ static VALUE r_mpfi_union (int argc, VALUE *argv, VALUE self)
|
|
930
987
|
|
931
988
|
/* ------------------------------ Miscellaneous Interval Functions start ------------------------------ */
|
932
989
|
|
990
|
+
/* mpfi_increase(self, p1) */
|
933
991
|
static VALUE r_mpfi_increase (VALUE self, VALUE a0)
|
934
992
|
{
|
935
993
|
MPFI *ptr_self;
|
@@ -941,6 +999,7 @@ static VALUE r_mpfi_increase (VALUE self, VALUE a0)
|
|
941
999
|
return self;
|
942
1000
|
}
|
943
1001
|
|
1002
|
+
/* mpfi_blow(ret, self, p1) */
|
944
1003
|
static VALUE r_mpfi_blow (int argc, VALUE *argv, VALUE self)
|
945
1004
|
{
|
946
1005
|
MPFI *ptr_self, *ptr_ret;
|
@@ -951,6 +1010,7 @@ static VALUE r_mpfi_blow (int argc, VALUE *argv, VALUE self)
|
|
951
1010
|
return val_ret;
|
952
1011
|
}
|
953
1012
|
|
1013
|
+
/* Return array [ret1, ret2] by mpfi_bisect(ret1, ret2, self). */
|
954
1014
|
static VALUE r_mpfi_bisect (int argc, VALUE *argv, VALUE self)
|
955
1015
|
{
|
956
1016
|
MPFI *ptr_self, *ptr_ret1, *ptr_ret2;
|
@@ -994,6 +1054,7 @@ void r_mpfi_subdivision_func(int num, MPFI *ret[], mpfi_t x)
|
|
994
1054
|
mpfr_clear(l);
|
995
1055
|
}
|
996
1056
|
|
1057
|
+
/* Return array having MPFI instances by subdividing. */
|
997
1058
|
static VALUE r_mpfi_subdivision (int argc, VALUE *argv, VALUE self)
|
998
1059
|
{
|
999
1060
|
MPFI *ptr_self;
|
@@ -1012,6 +1073,7 @@ static VALUE r_mpfi_subdivision (int argc, VALUE *argv, VALUE self)
|
|
1012
1073
|
|
1013
1074
|
/* ------------------------------ Mathematical Basic Arithmetic Functions start ------------------------------ */
|
1014
1075
|
|
1076
|
+
/* Addition. */
|
1015
1077
|
static VALUE r_mpfi_math_add (int argc, VALUE *argv, VALUE self)
|
1016
1078
|
{
|
1017
1079
|
VALUE val_ret;
|
@@ -1040,6 +1102,7 @@ static VALUE r_mpfi_math_add (int argc, VALUE *argv, VALUE self)
|
|
1040
1102
|
return val_ret;
|
1041
1103
|
}
|
1042
1104
|
|
1105
|
+
/* Subtraction. */
|
1043
1106
|
static VALUE r_mpfi_math_sub (int argc, VALUE *argv, VALUE self)
|
1044
1107
|
{
|
1045
1108
|
VALUE val_ret;
|
@@ -1068,6 +1131,7 @@ static VALUE r_mpfi_math_sub (int argc, VALUE *argv, VALUE self)
|
|
1068
1131
|
return val_ret;
|
1069
1132
|
}
|
1070
1133
|
|
1134
|
+
/* Multiplication. */
|
1071
1135
|
static VALUE r_mpfi_math_mul (int argc, VALUE *argv, VALUE self)
|
1072
1136
|
{
|
1073
1137
|
VALUE val_ret;
|
@@ -1096,6 +1160,7 @@ static VALUE r_mpfi_math_mul (int argc, VALUE *argv, VALUE self)
|
|
1096
1160
|
return val_ret;
|
1097
1161
|
}
|
1098
1162
|
|
1163
|
+
/* Division. */
|
1099
1164
|
static VALUE r_mpfi_math_div (int argc, VALUE *argv, VALUE self)
|
1100
1165
|
{
|
1101
1166
|
VALUE val_ret;
|
@@ -90,7 +90,7 @@ static VALUE r_mpfi_matrix_global_new(int argc, VALUE *argv, VALUE self)
|
|
90
90
|
{
|
91
91
|
MPFIMatrix *ptr;
|
92
92
|
VALUE val;
|
93
|
-
|
93
|
+
r_mpfi_make_col_vector_struct(val, ptr);
|
94
94
|
r_mpfi_matrix_set_initial_value(ptr, argc, argv);
|
95
95
|
return val;
|
96
96
|
}
|
@@ -149,7 +149,7 @@ static VALUE r_mpfi_square_matrix_global_new(int argc, VALUE arg)
|
|
149
149
|
{
|
150
150
|
MPFIMatrix *ptr;
|
151
151
|
VALUE val;
|
152
|
-
|
152
|
+
r_mpfi_make_square_matrix_struct(val, ptr);
|
153
153
|
r_mpfi_square_matrix_set_initial_value(ptr, arg);
|
154
154
|
return val;
|
155
155
|
}
|
@@ -257,7 +257,7 @@ static VALUE r_mpfi_row_vector_global_new(int argc, VALUE arg)
|
|
257
257
|
{
|
258
258
|
MPFIMatrix *ptr;
|
259
259
|
VALUE val;
|
260
|
-
|
260
|
+
r_mpfi_make_row_vector_struct(val, ptr);
|
261
261
|
r_mpfi_row_vector_set_initial_value(ptr, arg);
|
262
262
|
return val;
|
263
263
|
}
|
@@ -365,7 +365,7 @@ static VALUE r_mpfi_matrix_each_element_with_index (VALUE self){
|
|
365
365
|
return ret;
|
366
366
|
}
|
367
367
|
|
368
|
-
/* Return array which has strings converted elements to. */
|
368
|
+
/* Return one dimensinal array which has strings converted elements to. */
|
369
369
|
static VALUE r_mpfi_matrix_str_ary_for_inspect(VALUE self){
|
370
370
|
MPFIMatrix *ptr_self;
|
371
371
|
r_mpfi_get_matrix_struct(ptr_self, self);
|
@@ -381,6 +381,7 @@ static VALUE r_mpfi_matrix_str_ary_for_inspect(VALUE self){
|
|
381
381
|
return rb_ary_new4(ptr_self->size, ret_val);
|
382
382
|
}
|
383
383
|
|
384
|
+
/* Return two dimensinal array which has strings converted elements to. */
|
384
385
|
static VALUE r_mpfi_matrix_str_ary_for_inspect2(VALUE self){
|
385
386
|
MPFIMatrix *ptr_self;
|
386
387
|
r_mpfi_get_matrix_struct(ptr_self, self);
|
data/lib/mpfi/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
RUBY_MPFI_VERSION = '0.0.
|
1
|
+
RUBY_MPFI_VERSION = '0.0.4'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-mpfi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takayuki YAMAGUCHI
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-06 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,26 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.0.4
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rubyforge
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.0.3
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: gemcutter
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.3.0
|
44
|
+
version:
|
25
45
|
- !ruby/object:Gem::Dependency
|
26
46
|
name: hoe
|
27
47
|
type: :development
|
@@ -30,9 +50,11 @@ dependencies:
|
|
30
50
|
requirements:
|
31
51
|
- - ">="
|
32
52
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
53
|
+
version: 2.5.0
|
34
54
|
version:
|
35
|
-
description:
|
55
|
+
description: |-
|
56
|
+
ruby-mpfi is an extended C library to use MPFI[http://gforge.inria.fr/projects/mpfi/]
|
57
|
+
which is the library of the interval arithmetic with multiprecision.
|
36
58
|
email:
|
37
59
|
- d@ytak.info
|
38
60
|
executables: []
|
@@ -134,6 +156,6 @@ rubyforge_project: ruby-mpfi
|
|
134
156
|
rubygems_version: 1.3.5
|
135
157
|
signing_key:
|
136
158
|
specification_version: 3
|
137
|
-
summary:
|
159
|
+
summary: ruby-mpfi is an extended C library to use MPFI[http://gforge.inria.fr/projects/mpfi/] which is the library of the interval arithmetic with multiprecision.
|
138
160
|
test_files: []
|
139
161
|
|