Class: MPFI
- Inherits:
-
Numeric
- Object
- Numeric
- MPFI
- Defined in:
- lib/mpfi/matrix.rb,
lib/mpfi.rb,
lib/mpfi/version.rb,
ext/mpfi/ruby_mpfi.c,
ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.c,
ext/mpfi_complex/mpfi/ruby_mpfi_complex.c
Overview
If we do not load “mpfr/matrix” before load of “mpfi/matrix.so”, segmentation fault error raises.
Defined Under Namespace
Modules: Math, Vector Classes: ColumnVector, Complex, Matrix, RowVector, SquareMatrix
Constant Summary collapse
- VERSION =
'0.0.10'
Class Method Summary collapse
-
.ColumnVector ⇒ Object
Return new MPFI::ColumnVector instance.
-
.function_state ⇒ Object
Return state of last function of MPFI.
-
.interval ⇒ Object
Return new MPFI of which endpoints are the same as p1 and p2.
-
.Matrix ⇒ Object
Return new MPFI::Matrix instance.
-
.RowVector ⇒ Object
Return new MPFI::RowVector instance.
-
.SquareMatrix ⇒ Object
Return new MPFI::SquareMatrix instance.
Instance Method Summary collapse
-
#* ⇒ Object
Return self * p1.
-
#+ ⇒ Object
Return self + p1.
-
#- ⇒ Object
Return self - p1.
-
#/ ⇒ Object
Return self / p1.
-
#== ⇒ Object
Return true if self.right equals other.right and self.left equals other.right by mpfr_equal_p.
-
#abs ⇒ Object
mpfi_abs(ret, self).
-
#alea ⇒ Object
mpfi_alea(ret, self).
-
#bisect ⇒ Object
Return array [ret1, ret2] by mpfi_bisect(ret1, ret2, self).
-
#blow ⇒ Object
mpfi_blow(ret, self, p1).
-
#bounded_p ⇒ Object
(also: #bounded?)
Return true if mpfi_bounded_p(self) != 0.
-
#coerce ⇒ Object
Return array which have MPFI instance converted to from p1 and self.
-
#diam ⇒ Object
mpfi_diam(ret, self).
-
#diam_abs ⇒ Object
mpfi_diam_abs(ret, self).
-
#diam_rel ⇒ Object
mpfi_diam_rel(ret, self).
-
#div_2si ⇒ Object
mpfi_div_2si(ret, self, p1).
-
#each_subdivision ⇒ Object
Yield MPFI instances obtained by subdividing.
- #each_subdivision_by_size(size, &block) ⇒ Object
-
#endpoints ⇒ Object
Return array having two MPFR numbers which are endpoints.
-
#equal_p ⇒ Object
Return true if self.right equals other.right and self.left equals other.right by mpfr_equal_p.
-
#get_d ⇒ Object
(also: #to_f)
Return float by mpfi_get_d(self).
-
#get_fr ⇒ Object
(also: #to_fr)
Return MPFR by mpfi_get_fr(ret, self).
-
#get_left ⇒ Object
(also: #left)
mpfi_get_left(ret, self).
-
#get_prec ⇒ Object
Return precision of self.
-
#get_right ⇒ Object
(also: #right)
mpfi_get_right(ret, self).
-
#has_zero ⇒ Object
(also: #has_zero?)
Return true if mpfi_has_zero(self) > 0.
-
#include? ⇒ Boolean
This method corresponds to mpfi_is_inside.
-
#increase ⇒ Object
mpfi_increase(self, p1).
-
#inf_p ⇒ Object
(also: #inf?)
Return true if mpfi_inf_p(self) != 0.
-
#inspect ⇒ Object
String for inspect.
-
#intersect ⇒ Object
If the intersection of two intervals is empty, this method returns nil.
-
#intersect2 ⇒ Object
This method returns the intersection of two intervals.
-
#interv ⇒ Object
Change two endpoints so that it are the same as a1 and a2.
-
#inv ⇒ Object
mpfi_inv(ret, self).
-
#is_empty ⇒ Object
(also: #empty?)
Return true if mpfi_is_empty(self) > 0.
-
#is_neg ⇒ Object
(also: #neg?)
Return true if mpfi_is_neg(self) > 0.
-
#is_nonneg ⇒ Object
(also: #nonneg?)
Return true if mpfi_is_nonneg(self) > 0.
-
#is_nonpos ⇒ Object
(also: #nonpos?)
Return true if mpfi_is_nonpos(self) > 0.
-
#is_pos ⇒ Object
(also: #pos?)
Return true if mpfi_is_pos(self) > 0.
-
#is_strictly_neg ⇒ Object
(also: #strictly_neg?)
Return true if mpfi_is_strictly_neg(self) > 0.
-
#is_strictly_pos ⇒ Object
(also: #strictly_pos?)
Return true if mpfi_is_strictly_pos(self) > 0.
-
#is_zero ⇒ Object
(also: #zero?)
Return true if mpfi_is_zero(self) > 0.
-
#mag ⇒ Object
mpfi_mag(ret, self).
- #marshal_dump ⇒ Object
- #marshal_load ⇒ Object
-
#mid ⇒ Object
mpfi_mid(ret, self).
-
#mid_interval ⇒ Object
Return MPFI instance of which value is middle of self.
-
#mig ⇒ Object
mpfi_mig(ret, self).
-
#mul_2si ⇒ Object
mpfi_mul_2si(ret, self, p1).
-
#nan_p ⇒ Object
(also: #nan?)
Return true if mpfi_nan_p(self) != 0.
-
#neg ⇒ Object
mpfi_neg(ret, self).
-
#put ⇒ Object
Extend the interval so that it contains other.
-
#revert_if_needed ⇒ Object
Return true if mpfi_revert_if_needed(self) != 0.
-
#round_prec ⇒ Object
mpfi_round_prec(self, prec).
-
#set ⇒ Object
Set the value.
-
#set_prec ⇒ Object
Set the precision of self.
-
#strictly_include? ⇒ Boolean
This method corresponds to mpfi_is_strictly_inside.
- #subdivision(num) ⇒ Object
- #subdivision_by_size(size) ⇒ Object
-
#swap ⇒ Object
Swap value for other MPFI instance.
-
#to_str_ary ⇒ Object
Return array having two strings to which endpoints is converted.
-
#to_strf_ary ⇒ Object
Return array having two strings to which endpoints are converted by mpfr_asprintf with format_str.
-
#union ⇒ Object
mpfi_union(ret, self, p1).
Class Method Details
.ColumnVector ⇒ Object
Return new MPFI::ColumnVector instance. The same arguments as MPFI::ColumnVector.new is acceptable.
209 210 211 212 213 214 215 216 |
# File 'ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.c', line 209
static VALUE r_mpfi_col_vector_global_new (int argc, VALUE arg)
{
MPFIMatrix *ptr;
VALUE val;
r_mpfi_make_col_vector_struct(val, ptr);
r_mpfi_col_vector_set_initial_value(ptr, arg);
return val;
}
|
.function_state ⇒ Object
Return state of last function of MPFI.
18 19 20 21 |
# File 'ext/mpfi/ruby_mpfi.c', line 18
VALUE r_mpfi_get_function_state (VALUE self)
{
return rb_cv_get(r_mpfi_class, CLASS_VAL_FUNCTION_STATE);
}
|
.interval ⇒ Object
Return new MPFI of which endpoints are the same as p1 and p2.
929 930 931 932 933 934 935 936 |
# File 'ext/mpfi/ruby_mpfi.c', line 929
static VALUE r_mpfi_interval (int argc, VALUE *argv, VALUE self)
{
VALUE val_ret;
MPFI *ptr_ret;
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(2, 3, argc, argv));
r_mpfi_set_interv_from_robjs(ptr_ret, argv[0], argv[1]);
return val_ret;
}
|
.Matrix ⇒ Object
Return new MPFI::Matrix instance. The same arguments as MPFI::Matrix.new is acceptable.
90 91 92 93 94 95 96 97 |
# File 'ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.c', line 90
static VALUE r_mpfi_matrix_global_new (int argc, VALUE *argv, VALUE self)
{
MPFIMatrix *ptr;
VALUE val;
r_mpfi_make_matrix_struct(val, ptr);
r_mpfi_matrix_set_initial_value(ptr, argc, argv);
return val;
}
|
.RowVector ⇒ Object
Return new MPFI::RowVector instance. The same arguments as MPFI::RowVector.new is acceptable.
259 260 261 262 263 264 265 266 |
# File 'ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.c', line 259
static VALUE r_mpfi_row_vector_global_new (int argc, VALUE arg)
{
MPFIMatrix *ptr;
VALUE val;
r_mpfi_make_row_vector_struct(val, ptr);
r_mpfi_row_vector_set_initial_value(ptr, arg);
return val;
}
|
.SquareMatrix ⇒ Object
Return new MPFI::SquareMatrix instance. The same arguments as MPFI::SquareMatrix.new is acceptable.
149 150 151 152 153 154 155 156 |
# File 'ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.c', line 149
static VALUE r_mpfi_square_matrix_global_new (int argc, VALUE arg)
{
MPFIMatrix *ptr;
VALUE val;
r_mpfi_make_square_matrix_struct(val, ptr);
r_mpfi_square_matrix_set_initial_value(ptr, arg);
return val;
}
|
Instance Method Details
#* ⇒ Object
Return self * p1.
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
# File 'ext/mpfi/ruby_mpfi.c', line 437
static VALUE r_mpfi_mul (VALUE self, VALUE other)
{
VALUE val_ret;
MPFI *ptr_self, *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init(val_ret, ptr_ret);
if (RTEST(rb_funcall(__mpfi_class__, eqq, 1, other))) {
MPFI *ptr_other;
r_mpfi_get_struct(ptr_other, other);
mpfi_mul(ptr_ret, ptr_self, ptr_other);
} else if (RTEST(rb_funcall(__mpfr_class__, eqq, 1, other))) {
MPFR *ptr_other;
r_mpfr_get_struct(ptr_other, other);
mpfi_mul_fr(ptr_ret, ptr_self, ptr_other);
} else if (TYPE(other) == T_FIXNUM) {
mpfi_mul_si(ptr_ret, ptr_self, FIX2LONG(other));
} else if (TYPE(other) == T_FLOAT) {
mpfi_mul_d(ptr_ret, ptr_self, NUM2DBL(other));
} else {
MPFI *ptr_other;
volatile VALUE tmp_other = r_mpfi_new_fi_obj(other);
r_mpfi_get_struct(ptr_other, tmp_other);
mpfi_mul(ptr_ret, ptr_self, ptr_other);
}
return val_ret;
}
|
#+ ⇒ Object
Return self + p1.
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
# File 'ext/mpfi/ruby_mpfi.c', line 379
static VALUE r_mpfi_add (VALUE self, VALUE other)
{
VALUE val_ret;
MPFI *ptr_self, *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init(val_ret, ptr_ret);
if (RTEST(rb_funcall(__mpfi_class__, eqq, 1, other))) {
MPFI *ptr_other;
r_mpfi_get_struct(ptr_other, other);
mpfi_add(ptr_ret, ptr_self, ptr_other);
} else if (RTEST(rb_funcall(__mpfr_class__, eqq, 1, other))) {
MPFR *ptr_other;
r_mpfr_get_struct(ptr_other, other);
mpfi_add_fr(ptr_ret, ptr_self, ptr_other);
} else if (TYPE(other) == T_FIXNUM) {
mpfi_add_si(ptr_ret, ptr_self, FIX2LONG(other));
} else if (TYPE(other) == T_FLOAT) {
mpfi_add_d(ptr_ret, ptr_self, NUM2DBL(other));
} else {
MPFI *ptr_other;
volatile VALUE tmp_other = r_mpfi_new_fi_obj(other);
r_mpfi_get_struct(ptr_other, tmp_other);
mpfi_add(ptr_ret, ptr_self, ptr_other);
}
return val_ret;
}
|
#- ⇒ Object
Return self - p1.
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
# File 'ext/mpfi/ruby_mpfi.c', line 408
static VALUE r_mpfi_sub (VALUE self, VALUE other)
{
VALUE val_ret;
MPFI *ptr_self, *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init(val_ret, ptr_ret);
if (RTEST(rb_funcall(__mpfi_class__, eqq, 1, other))) {
MPFI *ptr_other;
r_mpfi_get_struct(ptr_other, other);
mpfi_sub(ptr_ret, ptr_self, ptr_other);
} else if (RTEST(rb_funcall(__mpfr_class__, eqq, 1, other))) {
MPFR *ptr_other;
r_mpfr_get_struct(ptr_other, other);
mpfi_sub_fr(ptr_ret, ptr_self, ptr_other);
} else if (TYPE(other) == T_FIXNUM) {
mpfi_sub_si(ptr_ret, ptr_self, FIX2LONG(other));
} else if (TYPE(other) == T_FLOAT) {
mpfi_sub_d(ptr_ret, ptr_self, NUM2DBL(other));
} else {
MPFI *ptr_other;
volatile VALUE tmp_other = r_mpfi_new_fi_obj(other);
r_mpfi_get_struct(ptr_other, tmp_other);
mpfi_sub(ptr_ret, ptr_self, ptr_other);
}
return val_ret;
}
|
#/ ⇒ Object
Return self / p1.
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'ext/mpfi/ruby_mpfi.c', line 466
static VALUE r_mpfi_div (VALUE self, VALUE other)
{
VALUE val_ret;
MPFI *ptr_self, *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init(val_ret, ptr_ret);
if (RTEST(rb_funcall(__mpfi_class__, eqq, 1, other))) {
MPFI *ptr_other;
r_mpfi_get_struct(ptr_other, other);
mpfi_div(ptr_ret, ptr_self, ptr_other);
} else if (RTEST(rb_funcall(__mpfr_class__, eqq, 1, other))) {
MPFR *ptr_other;
r_mpfr_get_struct(ptr_other, other);
mpfi_div_fr(ptr_ret, ptr_self, ptr_other);
} else if (TYPE(other) == T_FIXNUM) {
mpfi_div_si(ptr_ret, ptr_self, FIX2LONG(other));
} else if (TYPE(other) == T_FLOAT) {
mpfi_div_d(ptr_ret, ptr_self, NUM2DBL(other));
} else {
MPFI *ptr_other;
volatile VALUE tmp_other = r_mpfi_new_fi_obj(other);
r_mpfi_get_struct(ptr_other, tmp_other);
mpfi_div(ptr_ret, ptr_self, ptr_other);
}
return val_ret;
}
|
#== ⇒ Object
Return true if self.right equals other.right and self.left equals other.right by mpfr_equal_p.
717 718 719 720 721 722 723 724 725 726 727 728 |
# File 'ext/mpfi/ruby_mpfi.c', line 717
static VALUE r_mpfi_equal_p (VALUE self, VALUE other)
{
MPFI *ptr_self, *ptr_other;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_get_struct(ptr_other, other);
if (mpfr_equal_p(r_mpfi_left_ptr(ptr_self), r_mpfi_left_ptr(ptr_other)) != 0 &&
mpfr_equal_p(r_mpfi_right_ptr(ptr_self), r_mpfi_right_ptr(ptr_other)) != 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#abs ⇒ Object
mpfi_abs(ret, self)
539 540 541 542 543 544 545 546 547 |
# File 'ext/mpfi/ruby_mpfi.c', line 539
static VALUE r_mpfi_abs (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self, *ptr_ret;
VALUE val_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
mpfi_abs(ptr_ret, ptr_self);
return val_ret;
}
|
#alea ⇒ Object
mpfi_alea(ret, self)
818 819 820 821 822 823 824 825 826 827 |
# File 'ext/mpfi/ruby_mpfi.c', line 818
static VALUE r_mpfi_alea (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self;
VALUE val_ret;
MPFR *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfr_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
mpfi_alea(ptr_ret, ptr_self);
return val_ret;
}
|
#bisect ⇒ Object
Return array [ret1, ret2] by mpfi_bisect(ret1, ret2, self).
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 |
# File 'ext/mpfi/ruby_mpfi.c', line 1087
static VALUE r_mpfi_bisect (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self, *ptr_ret1, *ptr_ret2;
int prec;
VALUE val_ret1, val_ret2;
r_mpfi_get_struct(ptr_self, self);
prec = r_mpfr_prec_from_optional_argument(0, 1, argc, argv);
r_mpfi_make_struct_init2(val_ret1, ptr_ret1, prec);
r_mpfi_make_struct_init2(val_ret2, ptr_ret2, prec);
r_mpfi_set_function_state(mpfi_bisect(ptr_ret1, ptr_ret2, ptr_self));
return rb_ary_new3(2, val_ret1, val_ret2);
}
|
#blow ⇒ Object
mpfi_blow(ret, self, p1)
1076 1077 1078 1079 1080 1081 1082 1083 1084 |
# File 'ext/mpfi/ruby_mpfi.c', line 1076
static VALUE r_mpfi_blow (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self, *ptr_ret;
VALUE val_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(1, 2, argc, argv));
r_mpfi_set_function_state(mpfi_blow(ptr_ret, ptr_self, NUM2DBL(argv[0])));
return val_ret;
}
|
#bounded_p ⇒ Object Also known as: bounded?
Return true if mpfi_bounded_p(self) != 0. Otherwise, nil.
702 703 704 705 706 707 708 709 710 711 |
# File 'ext/mpfi/ruby_mpfi.c', line 702
static VALUE r_mpfi_bounded_p (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_bounded_p(ptr_self) != 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#coerce ⇒ Object
Return array which have MPFI instance converted to from p1 and self.
192 193 194 195 196 197 198 199 200 |
# File 'ext/mpfi/ruby_mpfi.c', line 192
static VALUE r_mpfi_coerce (VALUE self, VALUE other)
{
VALUE val_other;
MPFI *ptr_self, *ptr_other;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init2(val_other, ptr_other, mpfi_get_prec(ptr_self));
r_mpfi_set_robj(ptr_other, other);
return rb_ary_new3(2, val_other, self);
}
|
#diam ⇒ Object
mpfi_diam(ret, self)
759 760 761 762 763 764 765 766 767 768 |
# File 'ext/mpfi/ruby_mpfi.c', line 759
static VALUE r_mpfi_diam (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self;
VALUE val_ret;
MPFR *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfr_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
r_mpfi_set_function_state(mpfi_diam(ptr_ret, ptr_self));
return val_ret;
}
|
#diam_abs ⇒ Object
mpfi_diam_abs(ret, self)
735 736 737 738 739 740 741 742 743 744 |
# File 'ext/mpfi/ruby_mpfi.c', line 735
static VALUE r_mpfi_diam_abs (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self;
VALUE val_ret;
MPFR *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfr_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
r_mpfi_set_function_state(mpfi_diam_abs(ptr_ret, ptr_self));
return val_ret;
}
|
#diam_rel ⇒ Object
mpfi_diam_rel(ret, self)
747 748 749 750 751 752 753 754 755 756 |
# File 'ext/mpfi/ruby_mpfi.c', line 747
static VALUE r_mpfi_diam_rel (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self;
VALUE val_ret;
MPFR *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfr_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
r_mpfi_set_function_state(mpfi_diam_rel(ptr_ret, ptr_self));
return val_ret;
}
|
#div_2si ⇒ Object
mpfi_div_2si(ret, self, p1)
506 507 508 509 510 511 512 513 514 |
# File 'ext/mpfi/ruby_mpfi.c', line 506
static VALUE r_mpfi_div_2si (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self, *ptr_ret;
VALUE val_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(1, 2, argc, argv));
mpfi_div_2si(ptr_ret, ptr_self, NUM2INT(argv[0]));
return val_ret;
}
|
#each_subdivision ⇒ Object
Yield MPFI instances obtained by subdividing.
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 |
# File 'ext/mpfi/ruby_mpfi.c', line 1101
static VALUE r_mpfi_each_subdivision (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self;
int i, num, prec, state = 0;
mpfr_t ptr_self_diam, step, endpoint;
VALUE ret;
RETURN_ENUMERATOR(self, argc, argv);
num = NUM2INT(argv[0]);
if (num <= 0) {
rb_raise(rb_eArgError, "Split number must be positive.");
}
prec = r_mpfr_prec_from_optional_argument(1, 2, argc, argv);
r_mpfi_get_struct(ptr_self, self);
mpfr_init2(ptr_self_diam, prec);
mpfr_init2(step, prec);
mpfr_init2(endpoint, prec);
mpfr_sub(step, r_mpfi_right_ptr(ptr_self), r_mpfi_left_ptr(ptr_self), GMP_RNDD);
mpfr_div_si(step, step, num, GMP_RNDD);
mpfi_diam_abs(ptr_self_diam, ptr_self);
if (mpfr_cmp(ptr_self_diam, step) > 0 && num > 1) {
{
volatile VALUE obj;
MPFI *ptr_obj;
r_mpfi_make_struct_init2(obj, ptr_obj, prec);
mpfr_set(r_mpfi_left_ptr(ptr_obj), r_mpfi_left_ptr(ptr_self), GMP_RNDD);
mpfr_add(endpoint, r_mpfi_left_ptr(ptr_self), step, GMP_RNDU);
mpfr_set(r_mpfi_right_ptr(ptr_obj), endpoint, GMP_RNDU);
ret = rb_protect(rb_yield, obj, &state);
}
if (state == 0) {
for (i = 1; i < num - 1; i++) {
volatile VALUE obj;
MPFI *ptr_obj;
r_mpfi_make_struct_init2(obj, ptr_obj, prec);
mpfr_set(r_mpfi_left_ptr(ptr_obj), endpoint, GMP_RNDD);
mpfr_add(endpoint, endpoint, step, GMP_RNDU);
mpfr_set(r_mpfi_right_ptr(ptr_obj), endpoint, GMP_RNDU);
ret = rb_protect(rb_yield, obj, &state);
if (state != 0) {
break;
}
}
if (state == 0) {
volatile VALUE obj;
MPFI *ptr_obj;
r_mpfi_make_struct_init2(obj, ptr_obj, prec);
mpfr_set(r_mpfi_left_ptr(ptr_obj), endpoint, GMP_RNDD);
mpfr_set(r_mpfi_right_ptr(ptr_obj), r_mpfi_right_ptr(ptr_self), GMP_RNDU);
ret = rb_protect(rb_yield, obj, &state);
}
}
} else {
volatile VALUE obj;
MPFI *ptr_obj;
r_mpfi_make_struct_init2(obj, ptr_obj, prec);
mpfr_set(r_mpfi_left_ptr(ptr_obj), r_mpfi_left_ptr(ptr_self), GMP_RNDD);
mpfr_set(r_mpfi_right_ptr(ptr_obj), r_mpfi_right_ptr(ptr_self), GMP_RNDU);
ret = rb_protect(rb_yield, obj, &state);
}
mpfr_clear(ptr_self_diam);
mpfr_clear(endpoint);
mpfr_clear(step);
if (state != 0) {
rb_jump_tag(state);
}
return ret;
}
|
#each_subdivision_by_size(size, &block) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/mpfi.rb', line 9 def each_subdivision_by_size(size, &block) if block_given? num = (self.diam_abs / size).ceil each_subdivision(num, &block) else to_enum(:each_subdivision_by_size, size) end end |
#endpoints ⇒ Object
Return array having two MPFR numbers which are endpoints.
939 940 941 942 943 944 945 946 947 948 949 950 |
# File 'ext/mpfi/ruby_mpfi.c', line 939
static VALUE r_mpfi_endpoints (VALUE self)
{
VALUE val_left, val_right;
MPFI *ptr_self;
MPFR *ptr_left, *ptr_right;
r_mpfi_get_struct(ptr_self, self);
r_mpfr_make_struct_init2(val_left, ptr_left, mpfi_get_prec(ptr_self));
r_mpfr_make_struct_init2(val_right, ptr_right, mpfi_get_prec(ptr_self));
mpfi_get_left(ptr_left, ptr_self);
mpfi_get_right(ptr_right, ptr_self);
return rb_ary_new3(2, val_left, val_right);
}
|
#equal_p ⇒ Object
Return true if self.right equals other.right and self.left equals other.right by mpfr_equal_p.
717 718 719 720 721 722 723 724 725 726 727 728 |
# File 'ext/mpfi/ruby_mpfi.c', line 717
static VALUE r_mpfi_equal_p (VALUE self, VALUE other)
{
MPFI *ptr_self, *ptr_other;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_get_struct(ptr_other, other);
if (mpfr_equal_p(r_mpfi_left_ptr(ptr_self), r_mpfi_left_ptr(ptr_other)) != 0 &&
mpfr_equal_p(r_mpfi_right_ptr(ptr_self), r_mpfi_right_ptr(ptr_other)) != 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#get_d ⇒ Object Also known as: to_f
Return float by mpfi_get_d(self).
834 835 836 837 838 839 |
# File 'ext/mpfi/ruby_mpfi.c', line 834
static VALUE r_mpfi_get_d (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
return rb_float_new(mpfi_get_d(ptr_self));
}
|
#get_fr ⇒ Object Also known as: to_fr
Return MPFR by mpfi_get_fr(ret, self).
842 843 844 845 846 847 848 849 850 851 |
# File 'ext/mpfi/ruby_mpfi.c', line 842
static VALUE r_mpfi_get_fr (VALUE self)
{
MPFI *ptr_self;
VALUE val_ret;
MPFR *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfr_make_struct_init2(val_ret, ptr_ret, mpfi_get_prec(ptr_self));
mpfi_get_fr(ptr_ret, ptr_self);
return val_ret;
}
|
#get_left ⇒ Object Also known as: left
mpfi_get_left(ret, self)
857 858 859 860 861 862 863 864 865 866 |
# File 'ext/mpfi/ruby_mpfi.c', line 857
static VALUE r_mpfi_get_left (VALUE self)
{
VALUE val_ret;
MPFI *ptr_self;
MPFR *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfr_make_struct_init2(val_ret, ptr_ret, mpfi_get_prec(ptr_self));
mpfi_get_left(ptr_ret, ptr_self);
return val_ret;
}
|
#get_prec ⇒ Object
Return precision of self.
296 297 298 299 300 301 |
# File 'ext/mpfi/ruby_mpfi.c', line 296
static VALUE r_mpfi_get_prec (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
return INT2NUM((int)mpfi_get_prec(ptr_self));
}
|
#get_right ⇒ Object Also known as: right
mpfi_get_right(ret, self)
869 870 871 872 873 874 875 876 877 878 |
# File 'ext/mpfi/ruby_mpfi.c', line 869
static VALUE r_mpfi_get_right (VALUE self)
{
VALUE val_ret;
MPFI *ptr_self;
MPFR *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfr_make_struct_init2(val_ret, ptr_ret, mpfi_get_prec(ptr_self));
mpfi_get_right(ptr_ret, ptr_self);
return val_ret;
}
|
#has_zero ⇒ Object Also known as: has_zero?
Return true if mpfi_has_zero(self) > 0. Otherwise, nil.
666 667 668 669 670 671 672 673 674 675 |
# File 'ext/mpfi/ruby_mpfi.c', line 666
static VALUE r_mpfi_has_zero (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_has_zero(ptr_self) > 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#include? ⇒ Boolean
This method corresponds to mpfi_is_inside.
970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
# File 'ext/mpfi/ruby_mpfi.c', line 970
static VALUE r_mpfi_include (VALUE self, VALUE other)
{
MPFI *ptr_self;
int result;
r_mpfi_get_struct(ptr_self, self);
if (RTEST(rb_funcall(__mpfi_class__, eqq, 1, other))) {
MPFI *ptr_other;
r_mpfi_get_struct(ptr_other, other);
result = mpfi_is_inside(ptr_other, ptr_self);
} else if (RTEST(rb_funcall(__mpfr_class__, eqq, 1, other))) {
MPFR *ptr_other;
r_mpfr_get_struct(ptr_other, other);
result = mpfi_is_inside_fr(ptr_other, ptr_self);
} else if (TYPE(other) == T_FIXNUM) {
result = mpfi_is_inside_si(FIX2LONG(other), ptr_self);
} else if (TYPE(other) == T_FLOAT) {
result = mpfi_is_inside_d(NUM2DBL(other), ptr_self);
} else {
MPFI *ptr_other;
volatile VALUE tmp_other = r_mpfi_new_fi_obj(other);
r_mpfi_get_struct(ptr_other, tmp_other);
result = mpfi_is_inside(ptr_other, ptr_self);
}
if (result > 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#increase ⇒ Object
mpfi_increase(self, p1)
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
# File 'ext/mpfi/ruby_mpfi.c', line 1063
static VALUE r_mpfi_increase (VALUE self, VALUE a0)
{
MPFI *ptr_self;
MPFR *ptr_a0;
volatile VALUE tmp_a0;
r_mpfi_get_struct(ptr_self, self);
tmp_a0 = r_mpfr_new_fr_obj(a0);
r_mpfr_get_struct(ptr_a0, tmp_a0);
r_mpfi_set_function_state(mpfi_increase(ptr_self, ptr_a0));
return self;
}
|
#inf_p ⇒ Object Also known as: inf?
Return true if mpfi_inf_p(self) != 0. Otherwise, nil.
690 691 692 693 694 695 696 697 698 699 |
# File 'ext/mpfi/ruby_mpfi.c', line 690
static VALUE r_mpfi_inf_p (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_inf_p(ptr_self) != 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#inspect ⇒ Object
String for inspect.
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'ext/mpfi/ruby_mpfi.c', line 317
static VALUE r_mpfi_inspect (VALUE self)
{
MPFI *ptr_s;
char *ret_str;
VALUE ret_val;
r_mpfi_get_struct(ptr_s, self);
if (!mpfr_asprintf(&ret_str, "#<MPFI:%lx,['%.Re %.Re'],%d>",
NUM2LONG(rb_funcall(self, object_id, 0)), r_mpfi_left_ptr(ptr_s),
r_mpfi_right_ptr(ptr_s), mpfi_get_prec(ptr_s))) {
rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
}
ret_val = rb_str_new2(ret_str);
mpfr_free_str(ret_str);
return ret_val;
}
|
#intersect ⇒ Object
If the intersection of two intervals is empty, this method returns nil. Otherwise, it returns the intersection.
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 |
# File 'ext/mpfi/ruby_mpfi.c', line 1016
static VALUE r_mpfi_intersect (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self, *ptr_a0, *ptr_ret;
VALUE val_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_get_struct(ptr_a0, argv[0]);
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(1, 2, argc, argv));
r_mpfi_set_function_state(mpfi_intersect(ptr_ret, ptr_self, ptr_a0));
if (mpfi_is_empty(ptr_ret) > 0) {
return Qnil;
} else {
return val_ret;
}
}
|
#intersect2 ⇒ Object
This method returns the intersection of two intervals. The returned value may be empty interval.
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
# File 'ext/mpfi/ruby_mpfi.c', line 1035
static VALUE r_mpfi_intersect2 (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self, *ptr_a0, *ptr_ret;
VALUE val_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_get_struct(ptr_a0, argv[0]);
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(1, 2, argc, argv));
r_mpfi_set_function_state(mpfi_intersect(ptr_ret, ptr_self, ptr_a0));
return val_ret;
}
|
#interv ⇒ Object
Change two endpoints so that it are the same as a1 and a2.
920 921 922 923 924 925 926 |
# File 'ext/mpfi/ruby_mpfi.c', line 920
static VALUE r_mpfi_interv (VALUE self, VALUE a1, VALUE a2)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_set_interv_from_robjs(ptr_self, a1, a2);
return self;
}
|
#inv ⇒ Object
mpfi_inv(ret, self)
528 529 530 531 532 533 534 535 536 |
# File 'ext/mpfi/ruby_mpfi.c', line 528
static VALUE r_mpfi_inv (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self, *ptr_ret;
VALUE val_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
mpfi_inv(ptr_ret, ptr_self);
return val_ret;
}
|
#is_empty ⇒ Object Also known as: empty?
Return true if mpfi_is_empty(self) > 0. Otherwise, nil.
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 |
# File 'ext/mpfi/ruby_mpfi.c', line 1001
static VALUE r_mpfi_is_empty (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_is_empty(ptr_self) > 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#is_neg ⇒ Object Also known as: neg?
Return true if mpfi_is_neg(self) > 0. Otherwise, nil.
618 619 620 621 622 623 624 625 626 627 |
# File 'ext/mpfi/ruby_mpfi.c', line 618
static VALUE r_mpfi_is_neg (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_is_neg(ptr_self) > 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#is_nonneg ⇒ Object Also known as: nonneg?
Return true if mpfi_is_nonneg(self) > 0. Otherwise, nil.
606 607 608 609 610 611 612 613 614 615 |
# File 'ext/mpfi/ruby_mpfi.c', line 606
static VALUE r_mpfi_is_nonneg (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_is_nonneg(ptr_self) > 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#is_nonpos ⇒ Object Also known as: nonpos?
Return true if mpfi_is_nonpos(self) > 0. Otherwise, nil.
642 643 644 645 646 647 648 649 650 651 |
# File 'ext/mpfi/ruby_mpfi.c', line 642
static VALUE r_mpfi_is_nonpos (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_is_nonpos(ptr_self) > 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#is_pos ⇒ Object Also known as: pos?
Return true if mpfi_is_pos(self) > 0. Otherwise, nil.
582 583 584 585 586 587 588 589 590 591 |
# File 'ext/mpfi/ruby_mpfi.c', line 582
static VALUE r_mpfi_is_pos (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_is_pos(ptr_self) > 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#is_strictly_neg ⇒ Object Also known as: strictly_neg?
Return true if mpfi_is_strictly_neg(self) > 0. Otherwise, nil.
630 631 632 633 634 635 636 637 638 639 |
# File 'ext/mpfi/ruby_mpfi.c', line 630
static VALUE r_mpfi_is_strictly_neg (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_is_strictly_neg(ptr_self) > 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#is_strictly_pos ⇒ Object Also known as: strictly_pos?
Return true if mpfi_is_strictly_pos(self) > 0. Otherwise, nil.
594 595 596 597 598 599 600 601 602 603 |
# File 'ext/mpfi/ruby_mpfi.c', line 594
static VALUE r_mpfi_is_strictly_pos (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_is_strictly_pos(ptr_self) > 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#is_zero ⇒ Object Also known as: zero?
Return true if mpfi_is_zero(self) > 0. Otherwise, nil.
654 655 656 657 658 659 660 661 662 663 |
# File 'ext/mpfi/ruby_mpfi.c', line 654
static VALUE r_mpfi_is_zero (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_is_zero(ptr_self) > 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#mag ⇒ Object
mpfi_mag(ret, self)
771 772 773 774 775 776 777 778 779 780 |
# File 'ext/mpfi/ruby_mpfi.c', line 771
static VALUE r_mpfi_mag (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self;
VALUE val_ret;
MPFR *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfr_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
r_mpfi_set_function_state(mpfi_mag(ptr_ret, ptr_self));
return val_ret;
}
|
#marshal_dump ⇒ Object
234 235 236 237 238 239 240 241 242 243 244 |
# File 'ext/mpfi/ruby_mpfi.c', line 234
static VALUE r_mpfi_marshal_dump (VALUE self)
{
MPFI *ptr_s;
char *ret_str;
VALUE ret_val;
r_mpfi_get_struct(ptr_s, self);
ret_str = r_mpfi_dump_to_string(ptr_s);
ret_val = rb_str_new2(ret_str);
mpfr_free_str(ret_str);
return ret_val;
}
|
#marshal_load ⇒ Object
263 264 265 266 267 268 269 270 271 272 |
# File 'ext/mpfi/ruby_mpfi.c', line 263
static VALUE r_mpfi_marshal_load (VALUE self, VALUE dump_string)
{
MPFI *ptr_s;
char *dump;
r_mpfi_get_struct(ptr_s, self);
Check_Type(dump_string, T_STRING);
dump = RSTRING_PTR(dump_string);
r_mpfi_load_string(ptr_s, dump);
return self;
}
|
#mid ⇒ Object
mpfi_mid(ret, self)
795 796 797 798 799 800 801 802 803 804 |
# File 'ext/mpfi/ruby_mpfi.c', line 795
static VALUE r_mpfi_mid (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self;
VALUE val_ret;
MPFR *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfr_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
r_mpfi_set_function_state(mpfi_mid(ptr_ret, ptr_self));
return val_ret;
}
|
#mid_interval ⇒ Object
Return MPFI instance of which value is middle of self.
807 808 809 810 811 812 813 814 815 |
# File 'ext/mpfi/ruby_mpfi.c', line 807
static VALUE r_mpfi_mid_interval (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self, *ptr_ret;
VALUE val_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
mpfi_mid_interval(ptr_ret, ptr_self);
return val_ret;
}
|
#mig ⇒ Object
mpfi_mig(ret, self)
783 784 785 786 787 788 789 790 791 792 |
# File 'ext/mpfi/ruby_mpfi.c', line 783
static VALUE r_mpfi_mig (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self;
VALUE val_ret;
MPFR *ptr_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfr_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
r_mpfi_set_function_state(mpfi_mig(ptr_ret, ptr_self));
return val_ret;
}
|
#mul_2si ⇒ Object
mpfi_mul_2si(ret, self, p1)
495 496 497 498 499 500 501 502 503 |
# File 'ext/mpfi/ruby_mpfi.c', line 495
static VALUE r_mpfi_mul_2si (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self, *ptr_ret;
VALUE val_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(1, 2, argc, argv));
mpfi_mul_2si(ptr_ret, ptr_self, NUM2INT(argv[0]));
return val_ret;
}
|
#nan_p ⇒ Object Also known as: nan?
Return true if mpfi_nan_p(self) != 0. Otherwise, nil.
678 679 680 681 682 683 684 685 686 687 |
# File 'ext/mpfi/ruby_mpfi.c', line 678
static VALUE r_mpfi_nan_p (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_nan_p(ptr_self) != 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#neg ⇒ Object
mpfi_neg(ret, self)
517 518 519 520 521 522 523 524 525 |
# File 'ext/mpfi/ruby_mpfi.c', line 517
static VALUE r_mpfi_neg (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self, *ptr_ret;
VALUE val_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(0, 1, argc, argv));
mpfi_neg(ptr_ret, ptr_self);
return val_ret;
}
|
#put ⇒ Object
Extend the interval so that it contains other.
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 |
# File 'ext/mpfi/ruby_mpfi.c', line 893
static VALUE r_mpfi_put (VALUE self, VALUE other)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (RTEST(rb_funcall(__mpfi_class__, eqq, 1, other))) {
MPFI *ptr_other;
r_mpfi_get_struct(ptr_other, other);
r_mpfi_set_function_state(mpfi_put(ptr_self, ptr_other));
} else if (RTEST(rb_funcall(__mpfr_class__, eqq, 1, other))) {
MPFR *ptr_other;
r_mpfr_get_struct(ptr_other, other);
r_mpfi_set_function_state(mpfi_put_fr(ptr_self, ptr_other));
} else if (TYPE(other) == T_FIXNUM) {
r_mpfi_set_function_state(mpfi_put_si(ptr_self, FIX2LONG(other)));
} else if (TYPE(other) == T_FLOAT) {
r_mpfi_set_function_state(mpfi_put_d(ptr_self, NUM2DBL(other)));
} else {
MPFI *ptr_other;
volatile VALUE tmp_other = r_mpfi_new_fi_obj(other);
r_mpfi_get_struct(ptr_other, tmp_other);
r_mpfi_set_function_state(mpfi_put(ptr_self, ptr_other));
}
return self;
}
|
#revert_if_needed ⇒ Object
Return true if mpfi_revert_if_needed(self) != 0. Otherwise, nil.
881 882 883 884 885 886 887 888 889 890 |
# File 'ext/mpfi/ruby_mpfi.c', line 881
static VALUE r_mpfi_revert_if_needed (VALUE self)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
if (mpfi_revert_if_needed(ptr_self) != 0) {
return Qtrue;
} else {
return Qnil;
};
}
|
#round_prec ⇒ Object
mpfi_round_prec(self, prec)
305 306 307 308 309 310 311 |
# File 'ext/mpfi/ruby_mpfi.c', line 305
static VALUE r_mpfi_round_prec (VALUE self, VALUE prec)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_set_function_state(mpfi_round_prec(ptr_self, NUM2INT(prec)));
return self;
}
|
#set ⇒ Object
Set the value.
203 204 205 206 207 208 209 |
# File 'ext/mpfi/ruby_mpfi.c', line 203
static VALUE r_mpfi_set (VALUE self, VALUE arg)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_set_robj(ptr_self, arg);
return self;
}
|
#set_prec ⇒ Object
Set the precision of self. Notice that mpfi_set_prec is different from reference manual. This is strange.
283 284 285 286 287 288 289 290 291 292 |
# File 'ext/mpfi/ruby_mpfi.c', line 283
static VALUE r_mpfi_set_prec (VALUE self, VALUE prec)
{
MPFI *ptr_self;
r_mpfi_get_struct(ptr_self, self);
/* if (mpfi_set_prec(ptr_self, NUM2INT(prec)) != 0) { */
/* rb_raise(rb_eRuntimeError, "Memory allocation failed for mpfi_set_prec."); */
/* } */
mpfi_set_prec(ptr_self, NUM2INT(prec));
return self;
}
|
#strictly_include? ⇒ Boolean
This method corresponds to mpfi_is_strictly_inside.
957 958 959 960 961 962 963 964 965 966 967 |
# File 'ext/mpfi/ruby_mpfi.c', line 957
static VALUE r_mpfi_strictly_include (VALUE self, VALUE other)
{
MPFI *ptr_self, *ptr_other;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_get_struct(ptr_other, other);
if (mpfi_is_strictly_inside(ptr_other, ptr_self) > 0) {
return Qtrue;
} else {
return Qnil;
}
}
|
#subdivision(num) ⇒ Object
5 6 7 |
# File 'lib/mpfi.rb', line 5 def subdivision(num) each_subdivision(num).to_a end |
#subdivision_by_size(size) ⇒ Object
18 19 20 |
# File 'lib/mpfi.rb', line 18 def subdivision_by_size(size) each_subdivision_by_size(size).to_a end |
#swap ⇒ Object
Swap value for other MPFI instance.
212 213 214 215 216 217 218 219 |
# File 'ext/mpfi/ruby_mpfi.c', line 212
static VALUE r_mpfi_swap (VALUE self, VALUE other)
{
MPFI *ptr_self, *ptr_other;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_get_struct(ptr_other, other);
mpfi_swap(ptr_self, ptr_other);
return self;
}
|
#to_str_ary ⇒ Object
Return array having two strings to which endpoints is converted.
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'ext/mpfi/ruby_mpfi.c', line 334
static VALUE r_mpfi_to_str_ary (VALUE self)
{
MPFI *ptr_self;
char *ret_str1, *ret_str2;
VALUE str1, str2;
r_mpfi_get_struct(ptr_self, self);
if (!mpfr_asprintf(&ret_str1, "%.Re", r_mpfi_left_ptr(ptr_self))) {
rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
}
if (!mpfr_asprintf(&ret_str2, "%.Re", r_mpfi_right_ptr(ptr_self))) {
rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
}
str1 = rb_str_new2(ret_str1);
str2 = rb_str_new2(ret_str2);
mpfr_free_str(ret_str1);
mpfr_free_str(ret_str2);
return rb_ary_new3(2, str1, str2);
}
|
#to_strf_ary ⇒ Object
Return array having two strings to which endpoints are converted by mpfr_asprintf with format_str.
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'ext/mpfi/ruby_mpfi.c', line 354
static VALUE r_mpfi_to_strf_ary (VALUE self, VALUE format_str)
{
MPFI *ptr_self;
char *format, *ret_str1, *ret_str2;
VALUE str1, str2;
r_mpfi_get_struct(ptr_self, self);
format = StringValuePtr(format_str);
if (!mpfr_asprintf(&ret_str1, format, r_mpfi_left_ptr(ptr_self))) {
rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
}
if (!mpfr_asprintf(&ret_str2, format, r_mpfi_right_ptr(ptr_self))) {
rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
}
str1 = rb_str_new2(ret_str1);
str2 = rb_str_new2(ret_str2);
mpfr_free_str(ret_str1);
mpfr_free_str(ret_str2);
return rb_ary_new3(2, str1, str2);
}
|
#union ⇒ Object
mpfi_union(ret, self, p1)
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 |
# File 'ext/mpfi/ruby_mpfi.c', line 1047
static VALUE r_mpfi_union (int argc, VALUE *argv, VALUE self)
{
MPFI *ptr_self, *ptr_a0, *ptr_ret;
VALUE val_ret;
r_mpfi_get_struct(ptr_self, self);
r_mpfi_get_struct(ptr_a0, argv[0]);
r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(1, 2, argc, argv));
r_mpfi_set_function_state(mpfi_union(ptr_ret, ptr_self, ptr_a0));
return val_ret;
}
|