Class: P1788::Interval
- Inherits:
-
Object
- Object
- P1788::Interval
- Defined in:
- ext/p1788/p1788.cc,
ext/p1788/p1788.cc
Overview
The set of mathematical intervals implemented by the Interval class is denoted πβ. It comprises those subsets [π] of the real line β that are closed and connected in the topological sense: that is, the empty set (β ) together with all the nonempty intervals, denoted [π, π], defined by
[π, π] = { π₯ β β | π β€ π₯ β€ π },
where π = inf([π]) β β βͺ {-β} and π = sup([π]) β β βͺ {+β} are extended-real numbers satisfying π β€ π, π < +β and π > -β.
Set operation methods
#& #| #bisect #overlapping_state #inflate
Boolean methods
#empty? #entire? #all_reals? #pos_reals? #neg_reals? #positive? #strictly_positive? #negative? #strictly_negative? #common? #bounded? #symmetric? #singleton? #eql? #== #less? #greater? #strictly_less? #strictly_greater? #precedes? #succeeds? #strictly_precedes? #strictly_succeeds? #disjoint_from? #intersect? #overlap? #subset_of? #strict_subset_of? #superset_of? #strict_superset_of? #interior_subset_of? #contain_interior_of? #include? #bisectable? #inclusion_test
Numeric methods
#inf #sup #midpoint #splitpoint #radius #mid_rad #width #magnitude #mignitude
Forward elementary function methods
#+@ #-@ #+ #- <em> #/ </em>* #pow #pown #recip #abs #sqr #sqrt #exp #exp2 #exp10 #log #log2 #log10 #sin #cos #tan #asin #acos #atan #sinh #cosh #tanh #asinh #acosh #atanh #sign #ceil #floor #floorceil #truncate #round_ties_to_even #round_ties_to_away #min #max #div_to_pair #cancel_plus #cancel_minus #fma
Reverse elementary functions methods
#mul_rev_to_pair #mul_rev #sqr_rev #abs_rev #pown_rev #pow_rev1 #pow_rev2 #sin_rev #cos_rev #tan_rev #cosh_rev
Ruby object methods
#inspect #coerce #=== #to_s #to_a #to_latex #dup #clone #hash
Constant Summary collapse
- EMPTY_SET =
β
empty_set
- ALL_REALS =
[-β, β]
all_reals
- POS_REALS =
[0, β]
pos_reals
- NEG_REALS =
[-β, 0]
neg_reals
- PI =
[βπβ, βπβ]
pi
- HALF_PI =
[βπ/2β, βπ/2β]
hpi
- TWO_PI =
[β2πβ, β2πβ]
pi2
- MINUS_PI_PI =
[β-πβ, βπβ]
minus_pi_pi
- MINUS_HPI_HPI =
[β-π/2β, βπ/2β]
minus_hpi_hpi
- MINUS_ONE_ONE =
[-1, 1]
minus_one_one
- E =
[βπβ, βπβ]
e
Class Method Summary collapse
-
.[](*args) ⇒ Interval
Create a new Interval.
Instance Method Summary collapse
-
#*(y) ⇒ Interval
Arithmetic multiplication.
-
#**(exponent) ⇒ Interval
Power operator.
-
#+(y) ⇒ Interval
Arithmetic addition.
-
#+@ ⇒ Interval
self
. -
#-(y) ⇒ Interval
Arithmetic subtraction.
-
#-@ ⇒ Interval
Opposite.
-
#/(y) ⇒ Interval
Arithmetic division.
-
#==(y) ⇒ Boolean
self = y.
-
#===(obj) ⇒ Boolean
Case subsumption operator.
-
#abs ⇒ Interval
Absolute value.
-
#abs_rev(x = ALL_REALS) ⇒ Interval
Reverse absolute value.
-
#acos ⇒ Interval
Arc cosine.
-
#acosh ⇒ Interval
Inverse hyperbolic cosine.
-
#asin ⇒ Interval
Arc sine.
-
#asinh ⇒ Interval
Inverse hyperbolic sine.
-
#atan ⇒ Interval
Arc tangent.
-
#atanh ⇒ Interval
Inverse hyperbolic tangent.
-
#bisect(ratio = 0.5) ⇒ Array[Interval]
(also: #split)
Split self into two intervals, according to ratio.
-
#bisectable? ⇒ Boolean
Tells if self can be bisected.
-
#bounded? ⇒ Boolean
self is empty or a bounded interval.
-
#cancel_minus(y) ⇒ Interval
Cancellative subtraction.
-
#cancel_plus(y) ⇒ Interval
Cancellative addition.
-
#ceil ⇒ Interval
Round towards +β.
-
#clone ⇒ Interval
Return a new Interval equal to
self
, also copying its singleton class. -
#coerce(other) ⇒ Array<Interval>
The coerce method provides support for Ruby type coercion.
-
#common? ⇒ Boolean
self is a bounded nonempty interval.
-
#contain_interior_of?(y) ⇒ Boolean
y is in the interior of self.
-
#convex_hull(y) ⇒ Interval
(also: #|)
Interval hull of the union of self and y.
-
#cos ⇒ Interval
Cosine.
-
#cos_rev(x = ALL_REALS) ⇒ Interval
Reverse cosine.
-
#cosh ⇒ Interval
Hyperbolic cosine.
-
#cosh_rev(x = ALL_REALS) ⇒ Interval
Reverse hyperbolic cosine.
-
#disjoint_from?(y) ⇒ Boolean
[ππππ] β© [π] = β .
-
#div_to_pair(y) ⇒ Array<Interval>
Two-output division.
-
#dup ⇒ Interval
Return a new Interval equal to
self
. -
#empty? ⇒ Boolean
[ππππ] = β ?.
-
#entire? ⇒ Boolean
(also: #all_reals?)
[ππππ] = β ?.
- #eql?(y) ⇒ Boolean
-
#exp ⇒ Interval
e raised to the power of self.
-
#exp10 ⇒ Interval
10 raised to the power of self.
-
#exp2 ⇒ Interval
2 raised to the power of self.
-
#floor ⇒ Interval
Round towards -β.
-
#floorceil ⇒ Interval
Inflate self towards nearest integer bounds.
-
#fma(x, y) ⇒ Interval
Fused multiply add.
-
#greater?(y) ⇒ Boolean
self is weakly greater than y.
- #hash ⇒ Integer
-
#include?(y) ⇒ Boolean
y is a member of self.
-
#inclusion_test(y) ⇒ Boolean?
Test if self is included in y, disjoint from y, or if self and y intersect.
-
#inf ⇒ Float?
(also: #lower_bound)
Lower bound of the interval.
-
#inflate(*args) ⇒ Interval
Inflate (or deflate) the interval.
-
#initialize(*args) ⇒ Interval
constructor
Create a new Interval.
- #inspect ⇒ String
-
#interior_subset_of?(y) ⇒ Boolean
self is in the interior of y.
-
#intersect?(y) ⇒ Boolean
[ππππ] β© [π] β β .
-
#intersection(y) ⇒ Interval
(also: #&)
Intersection.
-
#less?(y) ⇒ Boolean
self is weakly less than y.
-
#log ⇒ Interval
Natural logarithm.
-
#log10 ⇒ Interval
Base 10 logarithm.
-
#log2 ⇒ Interval
Base 2 logarithm.
-
#magnitude ⇒ Float?
Magnitude of self.
-
#max(b) ⇒ Interval
Maximum of two intervals.
-
#mid_rad ⇒ Array<Float,nil>
Midpoint and radius.
-
#midpoint ⇒ Float?
Midpoint of self.
-
#mignitude ⇒ Float?
Mignitude of self.
-
#min(b) ⇒ Interval
Minimum of two intervals.
-
#mul_rev(b, x = ALL_REALS) ⇒ Interval
Reverse multiplication.
-
#mul_rev_to_pair(y) ⇒ Array<Interval>
Two-output division.
-
#neg_reals? ⇒ Boolean
[ππππ] = ββ ?.
-
#negative? ⇒ Boolean
[ππππ] β [-β, 0].
-
#nonempty? ⇒ Boolean
[ππππ] β β ?.
-
#overlap?(y) ⇒ Boolean
Intersection of self and y is neither empty nor a singleton.
-
#overlapping_state(y) ⇒ Symbol
Overlapping state between self and y.
-
#pos_reals? ⇒ Boolean
[ππππ] = ββ ?.
-
#positive? ⇒ Boolean
[ππππ] β [0, +β].
-
#pow(y) ⇒ Interval
Power function.
-
#pow_rev1(b, x = ALL_REALS) ⇒ Interval
Reverse power function (base).
-
#pow_rev2(a, x = ALL_REALS) ⇒ Interval
Reverse power function (exponent).
-
#pown(n) ⇒ Interval
Power with integer exponent.
-
#pown_rev(n, x = ALL_REALS) ⇒ Interval
Reverse power with integer exponent.
-
#precedes?(y) ⇒ Boolean
self is to the left of but may touch y.
-
#radius ⇒ Float?
Radius of self.
-
#recip ⇒ Interval
Reciprocal.
-
#round_ties_to_away ⇒ Interval
Round, ties to away from zero.
-
#round_ties_to_even ⇒ Interval
(also: #round)
Round, ties to even.
-
#sign ⇒ Interval
Sign of self.
-
#sin ⇒ Interval
Sine.
-
#sin_rev(x = ALL_REALS) ⇒ Interval
Reverse sine.
-
#singleton? ⇒ Boolean
Tels if self contains only one value.
-
#sinh ⇒ Interval
Hyperbolic sine.
-
#splitpoint ⇒ Float?
Split point used to bisect.
-
#sqr ⇒ Interval
Square.
-
#sqr_rev(x = ALL_REALS) ⇒ Interval
Reverse square.
-
#sqrt ⇒ Interval
Square root.
-
#strict_subset_of?(y) ⇒ Boolean
self is a subset of but not equal to y.
-
#strict_superset_of?(y) ⇒ Boolean
self is a superset of but not equal to y.
-
#strictly_greater?(y) ⇒ Boolean
self is strictly greater than y.
-
#strictly_less?(y) ⇒ Boolean
self is strictly less than y.
-
#strictly_negative? ⇒ Boolean
[ππππ] β [-β, 0].
-
#strictly_positive? ⇒ Boolean
[ππππ] β [0, +β].
-
#strictly_precedes?(y) ⇒ Boolean
self is strictly to the left of y.
-
#strictly_succeeds?(y) ⇒ Boolean
self is strictly to the right of y.
-
#subset_of?(y) ⇒ Boolean
self is a subset of or equal to y.
-
#succeeds?(y) ⇒ Boolean
self is to the right of but may touch y.
-
#sup ⇒ Float?
(also: #upper_bound)
Upper bound of the interval.
-
#superset_of?(y) ⇒ Boolean
(also: #contain?)
self is a superset of or equal to y.
-
#symmetric? ⇒ Boolean
The lower bound of self is the opposite of the upper bound.
-
#tan ⇒ Interval
Tangent.
-
#tan_rev(x = ALL_REALS) ⇒ Interval
Reverse tangent.
-
#tanh ⇒ Interval
Hyperbolic tangent.
-
#to_a ⇒ Array<Float>
Returns a two element arrays containing the bounds of
self
. -
#to_latex(print_dollars = true) ⇒ String
Returns a LaTex representation as a string.
-
#to_s ⇒ String
Returns a unicode string representation of self.
-
#truncate ⇒ Interval
Round towards 0.
-
#unbounded? ⇒ Boolean
One of the bounds of self is infinite.
-
#width ⇒ Float?
Width of self.
Constructor Details
#new ⇒ Interval #new(numeric) ⇒ Interval #new(lower, upper) ⇒ Interval #new(range) ⇒ Interval #new(array) ⇒ Interval #new(str) ⇒ Interval #new(other_interval) ⇒ Interval
Create a new P1788::Interval
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 435 436 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/p1788/p1788.cc', line 408
static VALUE p1788_interval_initialize(int argc, VALUE *argv, VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
double lower, upper;
VALUE beg, end, a1, a2;
int i, arlen;
switch (rb_scan_args(argc, argv, "02", &a1, &a2)) {
case 0:
break;
case 1:
if (rb_obj_is_kind_of(a1, rb_cNumeric))
inter = p1788_rbnumeric2interval(a1);
else if (rb_obj_is_kind_of(a1, rb_cString))
inter = Interval(std::string(StringValueCStr(a1)));
else if (rb_obj_is_kind_of(a1, rb_cRange)) {
rb_range_values(a1, &beg, &end, &i);
lower = Interval::inf(p1788_rbnumeric2interval(beg));
upper = Interval::sup(p1788_rbnumeric2interval(end));
inter = Interval(lower, upper);
}
else if (rb_obj_is_kind_of(a1, rb_cArray)) {
arlen = rb_array_len(a1);
if (arlen == 0)
inter = Interval();
else if (arlen == 1)
inter = p1788_rbnumeric2interval(rb_ary_entry(a1, 0));
else if (arlen == 2) {
lower = Interval::inf(p1788_rbnumeric2interval(rb_ary_entry(a1, 0)));
upper = Interval::sup(p1788_rbnumeric2interval(rb_ary_entry(a1, 1)));
inter = Interval(lower, upper);
}
else
rb_raise(rb_eArgError, "the array must have 0, 1 or 2 elements, not %d", arlen);
}
else if (rb_obj_is_kind_of(a1, c_Interval)) {
inter = Interval(p1788_interval_rb2ref(a1));
}
else
rb_raise(rb_eArgError, "expecting Float, Integer, Rational, String, Range, Array or Interval, not %" PRIsVALUE, rb_class_name(rb_class_of(a1)));
break;
case 2:
if (rb_obj_is_kind_of(a1, rb_cNumeric) && rb_obj_is_kind_of(a2, rb_cNumeric)) {
lower = Interval::inf(p1788_rbnumeric2interval(a1));
upper = Interval::sup(p1788_rbnumeric2interval(a2));
inter = Interval(lower, upper);
}
else
rb_raise(rb_eArgError, "expecting two Numerics, or a [Numeric, Range or Array]");
break;
default:
rb_raise(rb_eArgError, "expecting 0 to 2 arguments, not %d", argc);
}
return self;
}
|
Class Method Details
.[](*args) ⇒ Interval
Create a new P1788::Interval
481 482 483 484 |
# File 'ext/p1788/p1788.cc', line 481
static VALUE p1788_interval_rb_new(int argc, VALUE *argv, VALUE self)
{
return rb_class_new_instance(argc, argv, c_Interval);
}
|
Instance Method Details
#*(y) ⇒ Interval
Arithmetic multiplication
[ππππ]*[π]Β Β =Β Β hull{ π₯β π¦ | π₯ β [ππππ], π¦ β [π] }Β Β βΒ Β β
Reverse function: #mul_rev
2112 2113 2114 2115 |
# File 'ext/p1788/p1788.cc', line 2112
static VALUE p1788_interval_mul(VALUE self, VALUE y)
{
P1788_INTERVAL_BINARY_OP(self, y, mul);
}
|
#**(exponent) ⇒ Interval
2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 |
# File 'ext/p1788/p1788.cc', line 2195
static VALUE p1788_interval_powop(VALUE self, VALUE exponent)
{
VALUE r;
int p;
double d;
if (rb_obj_is_kind_of(exponent, rb_cInteger)) {
p = NUM2INT(exponent);
if (p == 2)
P1788_NEW_RB_INTERVAL(r, Interval::sqr(p1788_interval_rb2ref(self)));
else
P1788_NEW_RB_INTERVAL(r, Interval::pown(p1788_interval_rb2ref(self), p));
}
else if (rb_obj_is_kind_of(exponent, rb_cNumeric)) {
d = NUM2DBL(exponent);
p = NUM2INT(exponent);
if (d >= 0.0 && d == (double)p) {
if (p == 2)
P1788_NEW_RB_INTERVAL(r, Interval::sqr(p1788_interval_rb2ref(self)));
else
P1788_NEW_RB_INTERVAL(r, Interval::pown(p1788_interval_rb2ref(self), p));
}
else
P1788_NEW_RB_INTERVAL(r, Interval::pow(p1788_interval_rb2ref(self), Interval(d, d)));
}
else if (is_an_interval_vector(exponent)) {
const Interval &inter = p1788_interval_rb2ref(self);
const IntervalVector &v = p1788_vector_rb2ref(exponent);
const int l = v.size();
IntervalVector *t = new IntervalVector(l);
for (int i = 0; i < l; i++)
(*t)[i] = Interval::pow(inter, v[i]);
return p1788_vector_alloc_from_pointer(t);
}
else {
P1788_NEW_RB_INTERVAL(r, Interval::pow(p1788_interval_rb2ref(self), p1788_rbobj2interval(exponent)));
}
return r;
}
|
#+(interval) ⇒ Interval #+(vector) ⇒ IntervalVector
Arithmetic addition
[ππππ] + [π]Β Β =Β Β hull{ π₯ + π¦ | π₯ β [ππππ], π¦ β [π] }Β Β βΒ Β β
Reverse function: #-
2088 2089 2090 2091 |
# File 'ext/p1788/p1788.cc', line 2088
static VALUE p1788_interval_add(VALUE self, VALUE y)
{
P1788_INTERVAL_BINARY_OP(self, y, add);
}
|
#+@ ⇒ Interval
Returns self
.
1623 1624 1625 1626 1627 1628 |
# File 'ext/p1788/p1788.cc', line 1623
static VALUE p1788_interval_pos(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::pos(p1788_interval_rb2ref(self)));
return r;
}
|
#-(y) ⇒ Interval
Arithmetic subtraction
[ππππ] - [π]Β Β =Β Β hull{ π₯ - π¦ | π₯ β [ππππ], π¦ β [π] }Β Β βΒ Β β
Reverse function: #+
2100 2101 2102 2103 |
# File 'ext/p1788/p1788.cc', line 2100
static VALUE p1788_interval_sub(VALUE self, VALUE y)
{
P1788_INTERVAL_BINARY_OP(self, y, sub);
}
|
#-@ ⇒ Interval
Opposite
[ππππ].negΒ Β =Β Β [-ππππ, -ππππ]
1635 1636 1637 1638 1639 1640 |
# File 'ext/p1788/p1788.cc', line 1635
static VALUE p1788_interval_neg(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::neg(p1788_interval_rb2ref(self)));
return r;
}
|
#/(y) ⇒ Interval
Arithmetic division
[ππππ] / [π]Β Β =Β Β hull{ π₯/π¦ | π₯ β [ππππ], π¦ β [π] }Β Β βΒ Β β
Reverse function: #*
2124 2125 2126 2127 |
# File 'ext/p1788/p1788.cc', line 2124
static VALUE p1788_interval_div(VALUE self, VALUE y)
{
P1788_INTERVAL_BINARY_OP(self, y, div);
}
|
#==(y) ⇒ Boolean
self = y
(β π₯ β [ππππ], β π¦ β [π], π₯ = π¦) β§ (β π¦ β [π], β π₯ β [ππππ], π¦ = π₯)
true if ([ππππ] = β
β§ [π] = β
) β¨ ([ππππ] β β
β§ [π] β β
β§ ππππ = π β§ ππππ = π)
false otherwise
936 937 938 939 940 941 |
# File 'ext/p1788/p1788.cc', line 936
static VALUE p1788_interval_equal(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
return Interval::equal(inter, iother) ? Qtrue : Qfalse;
}
|
#===(obj) ⇒ Boolean
Case subsumption operator.
Used to write case
expressions with intervals.
Returns true if obj can be converted to a P1788::Interval and obj is contained in self, false otherwise.
964 965 966 967 968 969 970 971 972 |
# File 'ext/p1788/p1788.cc', line 964
static VALUE p1788_interval_tripleequal(VALUE self, VALUE obj)
{
VALUE other = rb_rescue(p1788_casesubsumption_func, obj, p1788_casesubsumption_rescue, Qnil);
if (other == Qnil)
return Qfalse;
Interval &a = p1788_interval_rb2ref(self);
Interval &b = p1788_interval_rb2ref(other);
return Interval::subset(b, a) ? Qtrue : Qfalse;
}
|
#abs ⇒ Interval
Absolute value
[ππππ].absΒ Β =Β Β hull{ |π₯| οΏ¨ π₯ β [ππππ] }Β Β βΒ Β ββ
Reverse function: #abs_rev
2032 2033 2034 2035 2036 2037 |
# File 'ext/p1788/p1788.cc', line 2032
static VALUE p1788_interval_abs(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::abs(p1788_interval_rb2ref(self)));
return r;
}
|
#abs_rev(x = ALL_REALS) ⇒ Interval
Reverse absolute value.
abs_rev([π])Β Β =Β Β hull{ π₯ β [π] οΏ¨ |π₯| β [ππππ] }Β Β βΒ Β β
Reverse function: #abs
2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 |
# File 'ext/p1788/p1788.cc', line 2373
static VALUE p1788_interval_abs_rev(int argc, VALUE *argv, VALUE self)
{
VALUE x, r;
rb_scan_args(argc, argv, "01", &x);
if (x == Qnil) {
P1788_NEW_RB_INTERVAL(r, Interval::abs_rev(p1788_interval_rb2ref(self)));
}
else {
P1788_NEW_RB_INTERVAL(r, Interval::abs_rev(p1788_interval_rb2ref(self), p1788_rbobj2interval(x)));
}
return r;
}
|
#acos ⇒ Interval
Arc cosine
[ππππ].acosΒ Β =Β Β hull{ acos(π₯) | π₯ β [ππππ]β©[-1, 1] }Β Β βΒ Β [0, π]
Reverse function: #cos
1831 1832 1833 1834 1835 1836 |
# File 'ext/p1788/p1788.cc', line 1831
static VALUE p1788_interval_acos(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::acos(p1788_interval_rb2ref(self)));
return r;
}
|
#acosh ⇒ Interval
Inverse hyperbolic cosine
[ππππ].acoshΒ Β =Β Β hull{ acosh(π₯) | π₯ β [ππππ]β©[1,+β] }Β Β βΒ Β ββ
Reverse function: #cosh
1915 1916 1917 1918 1919 1920 |
# File 'ext/p1788/p1788.cc', line 1915
static VALUE p1788_interval_acosh(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::acosh(p1788_interval_rb2ref(self)));
return r;
}
|
#asin ⇒ Interval
Arc sine
[ππππ].asinΒ Β =Β Β hull{ asin(π₯) | π₯ β [ππππ]β©[-1, 1] }Β Β βΒ Β [-π/2, π/2]
Reverse function: #sin
1817 1818 1819 1820 1821 1822 |
# File 'ext/p1788/p1788.cc', line 1817
static VALUE p1788_interval_asin(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::asin(p1788_interval_rb2ref(self)));
return r;
}
|
#asinh ⇒ Interval
Inverse hyperbolic sine
[ππππ].asinhΒ Β =Β Β hull{ asinh(π₯) | π₯ β [ππππ] }Β Β βΒ Β β
Reverse function: #sinh
1901 1902 1903 1904 1905 1906 |
# File 'ext/p1788/p1788.cc', line 1901
static VALUE p1788_interval_asinh(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::asinh(p1788_interval_rb2ref(self)));
return r;
}
|
#atan ⇒ Interval
Arc tangent
[ππππ].atanΒ Β =Β Β hull{ atan(π₯) | π₯ β [ππππ] }Β Β βΒ Β [-π/2, π/2]Β
Reverse function: #tan
1845 1846 1847 1848 1849 1850 |
# File 'ext/p1788/p1788.cc', line 1845
static VALUE p1788_interval_atan(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::atan(p1788_interval_rb2ref(self)));
return r;
}
|
#atanh ⇒ Interval
Inverse hyperbolic tangent
[ππππ].atanhΒ Β =Β Β hull{ atanh(π₯) | π₯ β [ππππ]β©[-1,1] }Β Β βΒ Β β
Reverse function: #tanh
1929 1930 1931 1932 1933 1934 |
# File 'ext/p1788/p1788.cc', line 1929
static VALUE p1788_interval_atanh(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::atanh(p1788_interval_rb2ref(self)));
return r;
}
|
#bisect(ratio = 0.5) ⇒ Array[Interval] Also known as: split
Split self into two intervals, according to ratio. Raise an exception if self cannot be bisected into two nonempty non-singleton intervals (see #bisectable?).
1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 |
# File 'ext/p1788/p1788.cc', line 1498
static VALUE p1788_interval_bisect(int argc, VALUE *argv, VALUE self)
{
if (argc > 1)
rb_raise(rb_eArgError, "wrong number of arguments (given %d, expected 0..1)", argc);
VALUE r1, r2;
const Interval &inter = p1788_interval_rb2ref(self);
const double l = Interval::inf(inter);
const double m = Interval::mid(inter);
const double u = Interval::sup(inter);
if (Interval::is_empty(inter) || Interval::inf(inter) >= m || m >= Interval::sup(inter)) {
rb_raise(rb_eRuntimeError, "%" PRIsVALUE " cannot be bisected in two nonempty non-singleton intervals",
p1788_interval_inspect(self));
}
if (argc < 1 || l == -INF || u == INF) {
P1788_NEW_RB_INTERVAL(r1, Interval(l, m));
P1788_NEW_RB_INTERVAL(r2, Interval(m, u));
}
else {
double r = NUM2DBL(argv[0]);
if (r <= 0.0 || r >= 1.0)
rb_raise(rb_eRuntimeError, "the given bisection ratio must be > 0 and < 1");
double p;
if (r == 0.5)
p = m;
else {
p = l+r*Interval::wid(inter);
if (p >= u)
p = std::nextafter(l, INF);
if (p >= u)
rb_raise(rb_eRuntimeError, "%" PRIsVALUE " cannot be bisected in two nonempty non-singleton intervals",
p1788_interval_inspect(self));
}
P1788_NEW_RB_INTERVAL(r1, Interval(l, p));
P1788_NEW_RB_INTERVAL(r2, Interval(p, u));
}
return rb_ary_new_from_args(2, r1, r2);
}
|
#bisectable? ⇒ Boolean
Tells if self can be bisected. An interval is bisectable if it can be bisected into two nonempty non-singleton intervals. Example of non bisectable intervals are [3.0, 3.0.next_float] and [Float::MAX, +β].
1306 1307 1308 1309 |
# File 'ext/p1788/p1788.cc', line 1306
static VALUE p1788_interval_bisectable(VALUE self)
{
return p1788_interval_is_bisectable(p1788_interval_rb2ref(self)) ? Qtrue : Qfalse;
}
|
#bounded? ⇒ Boolean
An empty interval is always bounded
self is empty or a bounded interval
878 879 880 881 882 |
# File 'ext/p1788/p1788.cc', line 878
static VALUE p1788_interval_bounded(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
return (Interval::is_empty(inter) || Interval::is_common_interval(inter)) ? Qtrue : Qfalse;
}
|
#cancel_minus(y) ⇒ Interval
Cancellative subtraction
Cancellative subtraction solves the following problem: Recover interval [π] from intervals [ππππ] and [π], given that [ππππ] = [π] + [π].
For any two bounded intervals [ππππ] and [π], [ππππ].cancel_minus([π]) is the tightest interval [π] such that [π] + [π] β [ππππ].
2156 2157 2158 2159 |
# File 'ext/p1788/p1788.cc', line 2156
static VALUE p1788_interval_cancel_minus(VALUE self, VALUE y)
{
P1788_INTERVAL_BINARY_OP(self, y, cancel_minus);
}
|
#cancel_plus(y) ⇒ Interval
Cancellative addition
self.cancel_plux([π]) = self.cancel_minus(-[π])
2167 2168 2169 2170 |
# File 'ext/p1788/p1788.cc', line 2167
static VALUE p1788_interval_cancel_plus(VALUE self, VALUE y)
{
P1788_INTERVAL_BINARY_OP(self, y, cancel_plus);
}
|
#ceil ⇒ Interval
Round towards +β
[ππππ].ceilΒ Β =Β Β [ceil(ππππ), ceil(ππππ)]
1953 1954 1955 1956 1957 1958 |
# File 'ext/p1788/p1788.cc', line 1953
static VALUE p1788_interval_ceil(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::ceil(p1788_interval_rb2ref(self)));
return r;
}
|
#clone ⇒ Interval
Return a new P1788::Interval equal to self
, also copying its singleton class.
511 512 513 514 515 516 |
# File 'ext/p1788/p1788.cc', line 511
static VALUE p1788_interval_clone(VALUE self)
{
VALUE c = rb_call_super(0, NULL);
p1788_interval_rb2ref(c) = p1788_interval_rb2ref(self);
return c;
}
|
#coerce(other) ⇒ Array<Interval>
The coerce method provides support for Ruby type coercion. This coercion mechanism is used by Ruby to handle mixed-type numeric operations: it is intended to find a compatible common type between the two operands of the operator.
750 751 752 753 754 755 |
# File 'ext/p1788/p1788.cc', line 750
static VALUE p1788_interval_coerce(VALUE self, VALUE other)
{
VALUE rbo;
P1788_NEW_RB_INTERVAL(rbo, p1788_rbobj2interval(other));
return rb_ary_new_from_args(2, rbo, self);
}
|
#common? ⇒ Boolean
self is a bounded nonempty interval
867 868 869 870 |
# File 'ext/p1788/p1788.cc', line 867
static VALUE p1788_interval_common(VALUE self)
{
return Interval::is_common_interval(p1788_interval_rb2ref(self)) ? Qtrue : Qfalse;
}
|
#contain_interior_of?(y) ⇒ Boolean
y is in the interior of self
[ππππ] βͺΎ [π]
(β π¦ β [π], β π₯ β [ππππ] : π¦ < π₯) β§ (β π¦ β [π], β π₯ β [ππππ] : π¦ > π₯)
true if [π] = β
β¨ ([ππππ] β β
β§ ππππ < π β§ π < ππππ)
false otherwise
1267 1268 1269 1270 1271 1272 |
# File 'ext/p1788/p1788.cc', line 1267
static VALUE p1788_interval_contains_interior(VALUE self, VALUE y)
{
Interval &inter = p1788_interval_rb2ref(self);
Interval iother = p1788_rbobj2interval(y);
return Interval::contains_interior(inter, iother) ? Qtrue : Qfalse;
}
|
#convex_hull(y) ⇒ Interval Also known as: |
Interval hull of the union of self and y
[ππππ].convex_hull([π])Β Β =Β Β hull( [ππππ] βͺ [π] )
2070 2071 2072 2073 |
# File 'ext/p1788/p1788.cc', line 2070
static VALUE p1788_interval_convex_hull(VALUE self, VALUE y)
{
P1788_INTERVAL_BINARY_OP(self, y, convex_hull);
}
|
#cos ⇒ Interval
Cosine
[ππππ].cosΒ Β =Β Β hull{ cos(π₯) | π₯ β [ππππ] }Β Β βΒ Β [-1, 1]
Reverse function: #cos_rev
1789 1790 1791 1792 1793 1794 |
# File 'ext/p1788/p1788.cc', line 1789
static VALUE p1788_interval_cos(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::cos(p1788_interval_rb2ref(self)));
return r;
}
|
#cos_rev(x = ALL_REALS) ⇒ Interval
Reverse cosine
cos_rev([π])Β Β =Β Β hull{ π₯ β [π] | cos(π₯) β [ππππ] }Β Β βΒ Β β
Reverse function: #cos
2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 |
# File 'ext/p1788/p1788.cc', line 2489
static VALUE p1788_interval_cos_rev(int argc, VALUE *argv, VALUE self)
{
VALUE x, r;
rb_scan_args(argc, argv, "01", &x);
if (x == Qnil) {
P1788_NEW_RB_INTERVAL(r, Interval::cos_rev(p1788_interval_rb2ref(self)));
}
else {
P1788_NEW_RB_INTERVAL(r, Interval::cos_rev(p1788_interval_rb2ref(self), p1788_rbobj2interval(x)));
}
return r;
}
|
#cosh ⇒ Interval
Hyperbolic cosine
[ππππ].coshΒ Β =Β Β hull{ (ππ₯ + π-π₯) / 2 | π₯ β [ππππ] }Β Β βΒ Β [1, +β]
Reverse function: #cosh_rev
1873 1874 1875 1876 1877 1878 |
# File 'ext/p1788/p1788.cc', line 1873
static VALUE p1788_interval_cosh(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::cosh(p1788_interval_rb2ref(self)));
return r;
}
|
#cosh_rev(x = ALL_REALS) ⇒ Interval
Reverse hyperbolic cosine
cosh_rev([π])Β Β =Β Β hull{ π₯ β [π] | cosh(π₯) β [ππππ] }Β Β βΒ Β β
Reverse function: #cosh
2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 |
# File 'ext/p1788/p1788.cc', line 2531
static VALUE p1788_interval_cosh_rev(int argc, VALUE *argv, VALUE self)
{
VALUE x, r;
rb_scan_args(argc, argv, "01", &x);
if (x == Qnil) {
P1788_NEW_RB_INTERVAL(r, Interval::cosh_rev(p1788_interval_rb2ref(self)));
}
else {
P1788_NEW_RB_INTERVAL(r, Interval::cosh_rev(p1788_interval_rb2ref(self), p1788_rbobj2interval(x)));
}
return r;
}
|
#disjoint_from?(y) ⇒ Boolean
[ππππ] β© [π] = β
β π₯ β [ππππ], β π¦ β [π], π₯ β π¦
true if [ππππ] = β
β¨ [π] = β
β¨ ππππ < π β¨ π < ππππ
false otherwise
1128 1129 1130 1131 1132 1133 |
# File 'ext/p1788/p1788.cc', line 1128
static VALUE p1788_interval_disjoint(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
return Interval::disjoint(inter, iother) ? Qtrue : Qfalse;
}
|
#div_to_pair(y) ⇒ Array<Interval>
Two-output division
Returns a pair of intervals, ππππ / (π β© ββ) and ππππ / (π β© ββ)
2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 |
# File 'ext/p1788/p1788.cc', line 2178
static VALUE p1788_interval_div_to_pair(VALUE self, VALUE y)
{
VALUE r1, r2;
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
std::pair< Interval, Interval > p = Interval::mul_rev_to_pair(iother, inter);
P1788_NEW_RB_INTERVAL(r1, p.first);
P1788_NEW_RB_INTERVAL(r2, p.second);
return rb_ary_new_from_args(2, r1, r2);
}
|
#dup ⇒ Interval
Return a new P1788::Interval equal to self
.
502 503 504 505 |
# File 'ext/p1788/p1788.cc', line 502
static VALUE p1788_interval_dup(VALUE self)
{
return rb_class_new_instance(1, &self, c_Interval);
}
|
#empty? ⇒ Boolean
[ππππ] = β ?
764 765 766 767 |
# File 'ext/p1788/p1788.cc', line 764
static VALUE p1788_interval_empty(VALUE self)
{
return Interval::is_empty(p1788_interval_rb2ref(self)) ? Qtrue : Qfalse;
}
|
#entire? ⇒ Boolean Also known as: all_reals?
[ππππ] = β ?
782 783 784 785 |
# File 'ext/p1788/p1788.cc', line 782
static VALUE p1788_interval_entire(VALUE self)
{
return Interval::is_entire(p1788_interval_rb2ref(self)) ? Qtrue : Qfalse;
}
|
#eql?(y) ⇒ Boolean
self #== y and y is an P1788::Interval
920 921 922 923 924 925 |
# File 'ext/p1788/p1788.cc', line 920
static VALUE p1788_interval_eql(VALUE self, VALUE y)
{
if (!rb_obj_is_kind_of(y, c_Interval))
return Qfalse;
return Interval::equal(p1788_interval_rb2ref(self), p1788_interval_rb2ref(y)) ? Qtrue : Qfalse;
}
|
#exp ⇒ Interval
e raised to the power of self
[ππππ].expΒ Β =Β Β hull{ ππ₯ | π₯ β [ππππ] }Β Β βΒ Β ββ
Reverse function: #log
1691 1692 1693 1694 1695 1696 |
# File 'ext/p1788/p1788.cc', line 1691
static VALUE p1788_interval_exp(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::exp(p1788_interval_rb2ref(self)));
return r;
}
|
#exp10 ⇒ Interval
10 raised to the power of self
[ππππ].exp10Β Β =Β Β hull{ 10π₯ | π₯ β [ππππ] }Β Β βΒ Β ββ
Reverse function: #log10
1719 1720 1721 1722 1723 1724 |
# File 'ext/p1788/p1788.cc', line 1719
static VALUE p1788_interval_exp10(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::exp10(p1788_interval_rb2ref(self)));
return r;
}
|
#exp2 ⇒ Interval
2 raised to the power of self
[ππππ].exp2Β Β =Β Β hull{ 2π₯ | π₯ β [ππππ] }Β Β βΒ Β ββ
Reverse function: #log2
1705 1706 1707 1708 1709 1710 |
# File 'ext/p1788/p1788.cc', line 1705
static VALUE p1788_interval_exp2(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::exp2(p1788_interval_rb2ref(self)));
return r;
}
|
#floor ⇒ Interval
Round towards -β
[ππππ].floorΒ Β =Β Β [floor(ππππ), floor(ππππ)]
1965 1966 1967 1968 1969 1970 |
# File 'ext/p1788/p1788.cc', line 1965
static VALUE p1788_interval_floor(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::floor(p1788_interval_rb2ref(self)));
return r;
}
|
#floorceil ⇒ Interval
Inflate self towards nearest integer bounds
[ππππ].floorceilΒ Β =Β Β [floor(ππππ), ceil(ππππ)]
1977 1978 1979 1980 1981 1982 1983 |
# File 'ext/p1788/p1788.cc', line 1977
static VALUE p1788_interval_floorceil(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval(std::floor(Interval::inf(inter)), std::ceil(Interval::sup(inter))));
return r;
}
|
#fma(x, y) ⇒ Interval
Fused multiply add
fma([π], [π])Β Β =Β Β hull{ π₯β π¦ + π§ | π₯ β [π], π¦ β [π], π§ β [ππππ] }Β Β βΒ Β β
2279 2280 2281 2282 2283 2284 2285 2286 2287 |
# File 'ext/p1788/p1788.cc', line 2279
static VALUE p1788_interval_fma(VALUE self, VALUE x, VALUE y)
{
Interval ix = p1788_rbobj2interval(x);
Interval iy = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::fma(ix, iy, inter));
return r;
}
|
#greater?(y) ⇒ Boolean
self is weakly greater than y
(β π₯ β [ππππ], β π¦ β [π], π₯ β₯ π¦) β§ (β π¦ β [π], β π₯ β [ππππ], π₯ β₯ π¦)
true if ([ππππ] = β
β§ [π] = β
) β¨ ([ππππ] β β
β§ [π] β β
β§ ππππ β₯ π β§ ππππ β₯ π)
false otherwise
1015 1016 1017 1018 1019 1020 |
# File 'ext/p1788/p1788.cc', line 1015
static VALUE p1788_interval_greater(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
return Interval::greater(inter, iother) ? Qtrue : Qfalse;
}
|
#hash ⇒ Integer
977 978 979 980 981 982 983 984 985 986 987 988 |
# File 'ext/p1788/p1788.cc', line 977
static VALUE p1788_interval_hash(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
st_index_t v, h[2];
VALUE n;
n = rb_hash(DBL2NUM(Interval::inf(inter)));
h[0] = NUM2LONG(n);
n = rb_hash(DBL2NUM(Interval::sup(inter)));
h[1] = NUM2LONG(n);
v = rb_memhash(h, sizeof(h));
return ST2FIX(v);
}
|
#include?(y) ⇒ Boolean
y is a member of self
π¦ β [ππππ]
true if [ππππ] β β
β§ ππππ β€ π¦ β§ π¦ β€ ππππ β§ π¦ β Β±β
false otherwise
1284 1285 1286 1287 1288 1289 |
# File 'ext/p1788/p1788.cc', line 1284
static VALUE p1788_interval_include(VALUE self, VALUE y)
{
Interval &inter = p1788_interval_rb2ref(self);
double od = NUM2DBL(y);
return Interval::is_member(od, inter) ? Qtrue : Qfalse;
}
|
#inclusion_test(y) ⇒ Boolean?
Test if self is included in y, disjoint from y, or if self and y intersect.
Returns:
flase if self and y are disjoint; else
true if self is included in y; else
nil : self and y intersect.
1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 |
# File 'ext/p1788/p1788.cc', line 1321
static VALUE p1788_interval_inclusion_test(VALUE self, VALUE y)
{
VALUE r = Qnil;
Interval &inter = p1788_interval_rb2ref(self);
Interval iother = p1788_rbobj2interval(y);
if (Interval::disjoint(inter, iother))
r = Qfalse;
else if (Interval::subset(inter, iother))
r = Qtrue;
return r;
}
|
#inf ⇒ Float? Also known as: lower_bound
Lower bound of the interval. Returns nil if the interval is empty.
1341 1342 1343 1344 1345 1346 1347 |
# File 'ext/p1788/p1788.cc', line 1341
static VALUE p1788_interval_inf(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
if (Interval::is_empty(inter))
return Qnil;
return DBL2NUM(Interval::inf(inter));
}
|
#inflate(rad) ⇒ Interval #inflate(delta, chi) ⇒ Interval
Inflate (or deflate) the interval.
1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 |
# File 'ext/p1788/p1788.cc', line 1596
static VALUE p1788_interval_inflate(int argc, VALUE *argv, VALUE self)
{
VALUE r;
if (argc == 1) {
double rad = NUM2DBL(argv[0]);
P1788_NEW_RB_INTERVAL(r, Interval::add(p1788_interval_rb2ref(self), Interval(-rad, rad)));
}
else if (argc == 2) {
double delta = NUM2DBL(argv[0]);
double chi = NUM2DBL(argv[1]);
const Interval &inter = p1788_interval_rb2ref(self);
double mid = Interval::mid(inter);
Interval m(mid, mid);
Interval d(delta, delta);
P1788_NEW_RB_INTERVAL(r, m + d*(inter-m) + Interval(-chi, chi));
}
else
rb_raise(rb_eArgError, "wrong number of arguments (given %d, expected 1..2)", argc);
return r;
}
|
#inspect ⇒ String
633 634 635 636 637 638 |
# File 'ext/p1788/p1788.cc', line 633
static VALUE p1788_interval_inspect(VALUE self)
{
return rb_sprintf("#<%" PRIsVALUE " %" PRIsVALUE ">",
rb_class_name(c_Interval),
p1788_interval_to_s(self));
}
|
#interior_subset_of?(y) ⇒ Boolean
β βͺ½ β and β βͺ½ β
self is in the interior of y
[ππππ] βͺ½ [π]
(β π₯ β [ππππ], β π¦ β [π] : π₯ > π¦) β§ (β π₯ β [ππππ], β π¦ β [π] : π₯ < π¦ )
true if [ππππ] = β
β¨ ([π] β β
β§ π < ππππ β§ ππππ < π)
false otherwise
1249 1250 1251 1252 1253 1254 |
# File 'ext/p1788/p1788.cc', line 1249
static VALUE p1788_interval_interior(VALUE self, VALUE y)
{
Interval &inter = p1788_interval_rb2ref(self);
Interval iother = p1788_rbobj2interval(y);
return Interval::interior(inter, iother) ? Qtrue : Qfalse;
}
|
#intersect?(y) ⇒ Boolean
[ππππ] β© [π] β β
β π₯ β [ππππ], β π¦ β [π], π₯ = π¦
true if [ππππ] β β
β§ [π] β β
β§ ππππ β₯ π β§ ππππ β€ π
false otherwise
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 |
# File 'ext/p1788/p1788.cc', line 1145
static VALUE p1788_interval_intersect(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
#if 1
return Interval::disjoint(inter, iother) ? Qfalse : Qtrue ;
#else
if (Interval::is_empty(inter) || Interval::is_empty(iother))
return Qfalse;
double al = Interval::inf(inter);
double au = Interval::sup(inter);
double bl = Interval::inf(iother);
double bu = Interval::sup(iother);
return (au >= bl && al <= bu) ? Qtrue : Qfalse;
#endif
}
|
#intersection(y) ⇒ Interval Also known as: &
Intersection
[ππππ].intersection([π])Β Β =Β Β [ππππ] β© [π]
2060 2061 2062 2063 |
# File 'ext/p1788/p1788.cc', line 2060
static VALUE p1788_interval_intersection(VALUE self, VALUE y)
{
P1788_INTERVAL_BINARY_OP(self, y, intersection);
}
|
#less?(y) ⇒ Boolean
self is weakly less than y
(β π₯ β [ππππ], β π¦ β [π], π₯ β€ π¦) β§ (β π¦ β [π], β π₯ β [ππππ], π₯ β€ π¦)
true if ([ππππ] = β
β§ [π] = β
) β¨ ([ππππ] β β
β§ [π] β β
β§ ππππ β€ π β§ ππππ β€ π)
false otherwise
999 1000 1001 1002 1003 1004 |
# File 'ext/p1788/p1788.cc', line 999
static VALUE p1788_interval_less(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
return Interval::less(inter, iother) ? Qtrue : Qfalse;
}
|
#log ⇒ Interval
Natural logarithm
[ππππ].logΒ Β =Β Β hull{ ln(π₯) | π₯ β [ππππ]β©ββ }Β Β βΒ Β β
Reverse function: #exp
1733 1734 1735 1736 1737 1738 |
# File 'ext/p1788/p1788.cc', line 1733
static VALUE p1788_interval_log(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::log(p1788_interval_rb2ref(self)));
return r;
}
|
#log10 ⇒ Interval
Base 10 logarithm
[ππππ].log10Β Β =Β Β hull{ ln(π₯)/ln(10) | π₯ β [ππππ]β©ββ }Β Β βΒ Β β
Reverse function: #exp10
1761 1762 1763 1764 1765 1766 |
# File 'ext/p1788/p1788.cc', line 1761
static VALUE p1788_interval_log10(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::log10(p1788_interval_rb2ref(self)));
return r;
}
|
#log2 ⇒ Interval
Base 2 logarithm
[ππππ].log2Β Β =Β Β hull{ ln(π₯)/ln(2) | π₯ β [ππππ]β©ββ }Β Β βΒ Β β
Reverse function: #exp2
1747 1748 1749 1750 1751 1752 |
# File 'ext/p1788/p1788.cc', line 1747
static VALUE p1788_interval_log2(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::log2(p1788_interval_rb2ref(self)));
return r;
}
|
#magnitude ⇒ Float?
Magnitude of self
[ππππ].mignitudeΒ Β =Β Β sup{ |π₯| οΏ¨ π₯ β [ππππ] } if [ππππ] β β , nil if [ππππ] = β
1468 1469 1470 1471 1472 1473 1474 |
# File 'ext/p1788/p1788.cc', line 1468
static VALUE p1788_interval_mag(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
if (Interval::is_empty(inter))
return Qnil;
return DBL2NUM(Interval::mag(inter));
}
|
#max(b) ⇒ Interval
Maximum of two intervals
[ππππ].max([π])Β Β =Β Β [max(ππππ, π), max(ππππ, π)]
2144 2145 2146 2147 |
# File 'ext/p1788/p1788.cc', line 2144
static VALUE p1788_interval_max(VALUE self, VALUE b)
{
P1788_INTERVAL_BINARY_OP(self, b, max);
}
|
#mid_rad ⇒ Array<Float,nil>
Midpoint and radius
1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 |
# File 'ext/p1788/p1788.cc', line 1435
static VALUE p1788_interval_mid_rad(VALUE self)
{
std::pair< double, double > p = Interval::mid_rad(p1788_interval_rb2ref(self));
VALUE r1 = DBL2NUM(p.first);
VALUE r2 = DBL2NUM(p.second);
if (std::isnan(p.first))
r1 = Qnil;
if (std::isnan(p.second))
r2 = Qnil;
return rb_ary_new_from_args(2, r1, r2);
}
|
#midpoint ⇒ Float?
Midpoint of self
Midpoint is (ππππ + ππππ)/2 if [ππππ] β β and [ππππ] is bounded, nil otherwise
1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 |
# File 'ext/p1788/p1788.cc', line 1406
static VALUE p1788_interval_mid(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
if (Interval::is_empty(inter) || Interval::wid(inter) == INF)
return Qnil;
double mid = Interval::mid(inter);
if (std::isnan(mid))
return Qnil;
return DBL2NUM(mid);
}
|
#mignitude ⇒ Float?
Mignitude of self
[ππππ].mignitudeΒ Β =Β Β inf{ |π₯| οΏ¨ π₯ β [ππππ] } if [ππππ] β β , nil if [ππππ] = β
1482 1483 1484 1485 1486 1487 1488 |
# File 'ext/p1788/p1788.cc', line 1482
static VALUE p1788_interval_mig(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
if (Interval::is_empty(inter))
return Qnil;
return DBL2NUM(Interval::mig(inter));
}
|
#min(b) ⇒ Interval
Minimum of two intervals
[ππππ].min([π])Β Β =Β Β [min(ππππ, π), min(ππππ, π)]
2134 2135 2136 2137 |
# File 'ext/p1788/p1788.cc', line 2134
static VALUE p1788_interval_min(VALUE self, VALUE b)
{
P1788_INTERVAL_BINARY_OP(self, b, min);
}
|
#mul_rev(b, x = ALL_REALS) ⇒ Interval
Reverse multiplication
mul_rev([π], [π])Β Β =Β Β hull{ π₯ β [π] | β π β [π] : π₯β π β [ππππ] }Β Β βΒ Β β
Reverse function P1788.mul
2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 |
# File 'ext/p1788/p1788.cc', line 2331
static VALUE p1788_interval_mul_rev(int argc, VALUE *argv, VALUE self)
{
VALUE b, x, r;
rb_scan_args(argc, argv, "11", &b, &x);
if (x == Qnil) {
P1788_NEW_RB_INTERVAL(r, Interval::mul_rev(p1788_rbobj2interval(b), p1788_interval_rb2ref(self)));
}
else {
P1788_NEW_RB_INTERVAL(r, Interval::mul_rev(p1788_rbobj2interval(b), p1788_interval_rb2ref(self), p1788_rbobj2interval(x)));
}
return r;
}
|
#mul_rev_to_pair(y) ⇒ Array<Interval>
Two-output division
[ππππ]/[π] = { π₯ β β | β π β [π] : π₯β π β [ππππ] }
2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 |
# File 'ext/p1788/p1788.cc', line 2312
static VALUE p1788_interval_mul_rev_to_pair(VALUE self, VALUE y)
{
VALUE r1, r2;
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
std::pair< Interval, Interval > p = Interval::mul_rev_to_pair(inter, iother);
P1788_NEW_RB_INTERVAL(r1, p.first);
P1788_NEW_RB_INTERVAL(r2, p.second);
return rb_ary_new_from_args(2, r1, r2);
}
|
#neg_reals? ⇒ Boolean
[ππππ] = ββ ?
801 802 803 804 805 |
# File 'ext/p1788/p1788.cc', line 801
static VALUE p1788_interval_neg_reals(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
return ((Interval::inf(inter) == -INF) && (Interval::sup(inter) == 0.0)) ? Qtrue : Qfalse;
}
|
#negative? ⇒ Boolean
[ππππ] β [-β, 0]
true if [ππππ] = β
β¨ ππππ β€ 0
false otherwise
841 842 843 844 845 |
# File 'ext/p1788/p1788.cc', line 841
static VALUE p1788_interval_negative(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
return (Interval::is_empty(inter) || Interval::sup(inter) <= 0.0) ? Qtrue : Qfalse;
}
|
#nonempty? ⇒ Boolean
[ππππ] β β ?
773 774 775 776 |
# File 'ext/p1788/p1788.cc', line 773
static VALUE p1788_interval_nonempty(VALUE self)
{
return Interval::is_empty(p1788_interval_rb2ref(self)) ? Qfalse : Qtrue;
}
|
#overlap?(y) ⇒ Boolean
Intersection of self and y is neither empty nor a singleton.
1166 1167 1168 1169 1170 |
# File 'ext/p1788/p1788.cc', line 1166
static VALUE p1788_interval_overlap(VALUE self, VALUE y)
{
Interval inter = Interval::intersection(p1788_rbobj2interval(y), p1788_interval_rb2ref(self));
return (Interval::is_empty(inter) || Interval::is_singleton(inter)) ? Qfalse : Qtrue;
}
|
#overlapping_state(y) ⇒ Symbol
Overlapping state between self and y
1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 |
# File 'ext/p1788/p1788.cc', line 1540
static VALUE p1788_interval_overlapping_state(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
p1788::overlapping::overlapping_state ovlps = Interval::overlap(inter, iother);
VALUE r;
switch (ovlps) {
case p1788::overlapping::overlapping_state::both_empty:
r = ID2SYM(id_both_empty); break;
case p1788::overlapping::overlapping_state::first_empty:
r = ID2SYM(id_first_empty); break;
case p1788::overlapping::overlapping_state::second_empty:
r = ID2SYM(id_second_empty); break;
case p1788::overlapping::overlapping_state::before:
r = ID2SYM(id_before); break;
case p1788::overlapping::overlapping_state::meets:
r = ID2SYM(id_meets); break;
case p1788::overlapping::overlapping_state::overlaps:
r = ID2SYM(id_overlaps); break;
case p1788::overlapping::overlapping_state::starts:
r = ID2SYM(id_starts); break;
case p1788::overlapping::overlapping_state::contained_by:
r = ID2SYM(id_contained_by); break;
case p1788::overlapping::overlapping_state::finishes:
r = ID2SYM(id_finishes); break;
case p1788::overlapping::overlapping_state::equal:
r = ID2SYM(id_equal); break;
case p1788::overlapping::overlapping_state::finished_by:
r = ID2SYM(id_finished_by); break;
case p1788::overlapping::overlapping_state::contains:
r = ID2SYM(id_contains); break;
case p1788::overlapping::overlapping_state::started_by:
r = ID2SYM(id_started_by); break;
case p1788::overlapping::overlapping_state::overlapped_by:
r = ID2SYM(id_overlapped_by); break;
case p1788::overlapping::overlapping_state::met_by:
r = ID2SYM(id_met_by); break;
case p1788::overlapping::overlapping_state::after:
r = ID2SYM(id_after); break;
default:
r = ID2SYM(id_undefined);
}
return r;
}
|
#pos_reals? ⇒ Boolean
[ππππ] = ββ ?
791 792 793 794 795 |
# File 'ext/p1788/p1788.cc', line 791
static VALUE p1788_interval_pos_reals(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
return ((Interval::inf(inter) == 0.0) && (Interval::sup(inter) == INF)) ? Qtrue : Qfalse;
}
|
#positive? ⇒ Boolean
[ππππ] β [0, +β]
true if [ππππ] = β
β¨ ππππ β₯ 0
false otherwise
814 815 816 817 818 |
# File 'ext/p1788/p1788.cc', line 814
static VALUE p1788_interval_positive(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
return (Interval::is_empty(inter) || Interval::inf(inter) >= 0.0) ? Qtrue : Qfalse;
}
|
#pow(y) ⇒ Interval
2241 2242 2243 2244 2245 2246 2247 2248 2249 |
# File 'ext/p1788/p1788.cc', line 2241
static VALUE p1788_interval_pow(VALUE self, VALUE y)
{
if (rb_obj_is_kind_of(y, rb_cNumeric) && NUM2DBL(y) == 2.0) {
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::sqr(p1788_interval_rb2ref(self)));
return r;
}
P1788_INTERVAL_BINARY_OP(self, y, cancel_plus);
}
|
#pow_rev1(b, x = ALL_REALS) ⇒ Interval
Reverse power function (base)
pow_rev1([π], [π])Β Β =Β Β hull{ π₯ β [π] | β π β [π] : π₯π β [ππππ] }Β Β βΒ Β ββ
Reverse function: #pow
2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 |
# File 'ext/p1788/p1788.cc', line 2419
static VALUE p1788_interval_pow_rev1(int argc, VALUE *argv, VALUE self)
{
VALUE rbb, rbx, rbr;
rb_scan_args(argc, argv, "11", &rbb, &rbx);
Interval b = p1788_rbobj2interval(rbb);
Interval x = (rbx == Qnil) ? Interval(-INF, INF) : p1788_rbobj2interval(rbx);
Interval &c = p1788_interval_rb2ref(self);
Interval lnx = Interval::log(x);
Interval m = Interval::intersection(Interval::log(c), Interval::mul(b, lnx));
Interval l = Interval::mul_rev(b, m, lnx);
Interval r = Interval::intersection(Interval::exp(l), x);
P1788_NEW_RB_INTERVAL(rbr, r);
return rbr;
}
|
#pow_rev2(a, x = ALL_REALS) ⇒ Interval
Reverse power function (exponent)
pow_rev2([π], [π])Β Β =Β Β hull{ π₯ β [π] | β π β [π] : ππ₯ β [ππππ] }Β Β βΒ Β β
Reverse function: #pow
2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 |
# File 'ext/p1788/p1788.cc', line 2444
static VALUE p1788_interval_pow_rev2(int argc, VALUE *argv, VALUE self)
{
VALUE rba, rbx, rbr;
rb_scan_args(argc, argv, "11", &rba, &rbx);
Interval a = p1788_rbobj2interval(rba);
Interval x = (rbx == Qnil) ? Interval(-INF, INF) : p1788_rbobj2interval(rbx);
Interval &c = p1788_interval_rb2ref(self);
Interval lna = Interval::log(a);
Interval m = Interval::intersection(Interval::log(c), Interval::mul(x, lna));
Interval r = Interval::mul_rev(lna, m, x);
P1788_NEW_RB_INTERVAL(rbr, r);
return rbr;
}
|
#pown(n) ⇒ Interval
Power with integer exponent
[ππππ].pow(n)Β Β =Β Β hull{ π₯βΏ | π₯ β [ππππ] }Β Β βΒ Β β if n odd, ββ if n even, {1} if n = 0
Reverse function #pown_rev
2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 |
# File 'ext/p1788/p1788.cc', line 2259
static VALUE p1788_interval_pown(VALUE self, VALUE n)
{
VALUE r;
int p;
if (!RB_INTEGER_TYPE_P(n))
rb_raise(rb_eTypeError, "expecting an integer as exponent, not a %" PRIsVALUE, rb_class_name(rb_class_of(n)));
p = NUM2INT(n);
if (p == 2) {
P1788_NEW_RB_INTERVAL(r, Interval::sqr(p1788_interval_rb2ref(self)));
} else {
P1788_NEW_RB_INTERVAL(r, Interval::pown(p1788_interval_rb2ref(self), p));
}
return r;
}
|
#pown_rev(n, x = ALL_REALS) ⇒ Interval
Reverse power with integer exponent
pown_rev(π, [π])Β Β =Β Β hull{ π₯ β [π] | π₯βΏ β [ππππ] }Β Β βΒ Β β
Reverse function: #pown
2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 |
# File 'ext/p1788/p1788.cc', line 2396
static VALUE p1788_interval_pown_rev(int argc, VALUE *argv, VALUE self)
{
VALUE x, r, n;
int p;
rb_scan_args(argc, argv, "11", &n, &x);
p = NUM2INT(n);
if (x == Qnil) {
P1788_NEW_RB_INTERVAL(r, Interval::pown_rev(p1788_interval_rb2ref(self), p));
}
else {
P1788_NEW_RB_INTERVAL(r, Interval::pown_rev(p1788_interval_rb2ref(self), p1788_rbobj2interval(x), p));
}
return r;
}
|
#precedes?(y) ⇒ Boolean
self is to the left of but may touch y
β π₯ β [ππππ], β π¦ β [π], π₯ β€ π¦
true if [ππππ] = β
β¨ [π] = β
β¨ ππππ β€ π
false otherwise
1063 1064 1065 1066 1067 1068 |
# File 'ext/p1788/p1788.cc', line 1063
static VALUE p1788_interval_precedes(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
return Interval::precedes(inter, iother) ? Qtrue : Qfalse;
}
|
#radius ⇒ Float?
Radius of self
Radius is (ππππ - ππππ)/2 if [ππππ] β β , nil if [ππππ] = β
1423 1424 1425 1426 1427 1428 1429 |
# File 'ext/p1788/p1788.cc', line 1423
static VALUE p1788_interval_rad(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
if (Interval::is_empty(inter))
return Qnil;
return DBL2NUM(Interval::rad(inter));
}
|
#recip ⇒ Interval
Reciprocal
[ππππ].recipΒ Β =Β Β hull{ 1/π₯ | π₯ β [ππππ] }Β Β βΒ Β β
Reverse function: #recip
1649 1650 1651 1652 1653 1654 |
# File 'ext/p1788/p1788.cc', line 1649
static VALUE p1788_interval_recip(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::recip(p1788_interval_rb2ref(self)));
return r;
}
|
#round_ties_to_away ⇒ Interval
Round, ties to away from zero
Round bounds of self to their nearest integer values, rounding halfway cases away from zero.
[ππππ].round_ties_to_awayΒ Β =Β Β [round_ties_to_away(ππππ), round_ties_to_away(ππππ)]
2018 2019 2020 2021 2022 2023 |
# File 'ext/p1788/p1788.cc', line 2018
static VALUE p1788_interval_round_ties_to_away(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::round_ties_to_away(p1788_interval_rb2ref(self)));
return r;
}
|
#round_ties_to_even ⇒ Interval Also known as: round
Round, ties to even
Round bounds of self to their nearest integer values, rounding halfway cases to nearest even.
[ππππ].round_ties_to_evenΒ Β =Β Β [round_ties_to_even(ππππ), round_ties_to_even(ππππ)]
2004 2005 2006 2007 2008 2009 |
# File 'ext/p1788/p1788.cc', line 2004
static VALUE p1788_interval_round_ties_to_even(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::round_ties_to_even(p1788_interval_rb2ref(self)));
return r;
}
|
#sign ⇒ Interval
Sign of self
[ππππ].signΒ Β βΒ Β [-1, 1]Β Β ({-1} if ππππ < 0, {1} if ππππ > 0, {0} if [ππππ] = {0})
1941 1942 1943 1944 1945 1946 |
# File 'ext/p1788/p1788.cc', line 1941
static VALUE p1788_interval_sign(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::sign(p1788_interval_rb2ref(self)));
return r;
}
|
#sin ⇒ Interval
Sine
[ππππ].sinΒ Β =Β Β hull{ sin(π₯) | π₯ β [ππππ] }Β Β βΒ Β [-1, 1]
Reverse function: #sin_rev
1775 1776 1777 1778 1779 1780 |
# File 'ext/p1788/p1788.cc', line 1775
static VALUE p1788_interval_sin(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::sin(p1788_interval_rb2ref(self)));
return r;
}
|
#sin_rev(x = ALL_REALS) ⇒ Interval
Reverse sine
sin_rev([π])Β Β =Β Β hull{ π₯ β [π] | sin(π₯) β [ππππ] }Β Β βΒ Β β
Reverse function: #sin
2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 |
# File 'ext/p1788/p1788.cc', line 2468
static VALUE p1788_interval_sin_rev(int argc, VALUE *argv, VALUE self)
{
VALUE x, r;
rb_scan_args(argc, argv, "01", &x);
if (x == Qnil) {
P1788_NEW_RB_INTERVAL(r, Interval::sin_rev(p1788_interval_rb2ref(self)));
}
else {
P1788_NEW_RB_INTERVAL(r, Interval::sin_rev(p1788_interval_rb2ref(self), p1788_rbobj2interval(x)));
}
return r;
}
|
#singleton? ⇒ Boolean
Tels if self contains only one value.
911 912 913 914 |
# File 'ext/p1788/p1788.cc', line 911
static VALUE p1788_interval_singleton(VALUE self)
{
return Interval::is_singleton(p1788_interval_rb2ref(self)) ? Qtrue : Qfalse;
}
|
#sinh ⇒ Interval
Hyperbolic sine
[ππππ].sinhΒ Β =Β Β hull{ (ππ₯ - π-π₯) / 2 | π₯ β [ππππ] }Β Β βΒ Β β
Reverse function: #asinh
1859 1860 1861 1862 1863 1864 |
# File 'ext/p1788/p1788.cc', line 1859
static VALUE p1788_interval_sinh(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::sinh(p1788_interval_rb2ref(self)));
return r;
}
|
#splitpoint ⇒ Float?
Split point used to bisect
Split point is:
(ππππ + ππππ)/2 if [ππππ] is nonempty and bounded,
0
if [ππππ] = β,
-Float::MAX
if ππππ = -β
Float::MAX
if ππππ = +β
nil
if [ππππ] = β
1391 1392 1393 1394 1395 1396 1397 1398 |
# File 'ext/p1788/p1788.cc', line 1391
static VALUE p1788_interval_splitpoint(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
double sp = p1788_interval_splitpoint_double(inter);
if (std::isnan(sp))
return Qnil;
return DBL2NUM(sp);
}
|
#sqr ⇒ Interval
Square
[ππππ].sqrΒ Β =Β Β hull{ π₯Β² | π₯ β [ππππ] }Β Β βΒ Β ββ
Reverse function: #sqr_rev
1663 1664 1665 1666 1667 1668 |
# File 'ext/p1788/p1788.cc', line 1663
static VALUE p1788_interval_sqr(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::sqr(p1788_interval_rb2ref(self)));
return r;
}
|
#sqr_rev(x = ALL_REALS) ⇒ Interval
Reverse square
sqr_rev([π])Β Β =Β Β hull{ π₯ β [π] | π₯Β² β [ππππ] }Β Β βΒ Β β
Reverse function: #sqr
2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 |
# File 'ext/p1788/p1788.cc', line 2352
static VALUE p1788_interval_sqr_rev(int argc, VALUE *argv, VALUE self)
{
VALUE x, r;
rb_scan_args(argc, argv, "01", &x);
if (x == Qnil) {
P1788_NEW_RB_INTERVAL(r, Interval::sqr_rev(p1788_interval_rb2ref(self)));
}
else {
P1788_NEW_RB_INTERVAL(r, Interval::sqr_rev(p1788_interval_rb2ref(self), p1788_rbobj2interval(x)));
}
return r;
}
|
#sqrt ⇒ Interval
Square root
[ππππ].sqrtΒ Β =Β Β hull{ π₯Β½ | π₯ β [ππππ]β©ββ }Β Β βΒ Β ββ
Reverse function: #sqr
1677 1678 1679 1680 1681 1682 |
# File 'ext/p1788/p1788.cc', line 1677
static VALUE p1788_interval_sqrt(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::sqrt(p1788_interval_rb2ref(self)));
return r;
}
|
#strict_subset_of?(y) ⇒ Boolean
self is a subset of but not equal to y
[ππππ] β [π] β§ [ππππ] β [π]
1197 1198 1199 1200 1201 1202 |
# File 'ext/p1788/p1788.cc', line 1197
static VALUE p1788_interval_strict_subset(VALUE self, VALUE y)
{
Interval &inter = p1788_interval_rb2ref(self);
Interval iother = p1788_rbobj2interval(y);
return (Interval::subset(inter, iother) && !Interval::equal(inter, iother)) ? Qtrue : Qfalse;
}
|
#strict_superset_of?(y) ⇒ Boolean
self is a superset of but not equal to y
[ππππ] β [π] β§ [π] β [ππππ]
1229 1230 1231 1232 1233 1234 |
# File 'ext/p1788/p1788.cc', line 1229
static VALUE p1788_interval_strict_superset(VALUE self, VALUE y)
{
Interval &inter = p1788_interval_rb2ref(self);
Interval iother = p1788_rbobj2interval(y);
return (Interval::superset(inter, iother) && !Interval::equal(inter, iother)) ? Qtrue : Qfalse;
}
|
#strictly_greater?(y) ⇒ Boolean
self is strictly greater than y
(β π₯ β [ππππ], β π¦ β [π], π₯ > π¦) β§ (β π¦ β [π], β π₯ β [ππππ], π₯ > π¦)
true if ([ππππ] = β
β§ [π] = β
) β¨ ([ππππ] β β
β§ [π] β β
β§ ππππ > π β§ ππππ > π)
false otherwise
1047 1048 1049 1050 1051 1052 |
# File 'ext/p1788/p1788.cc', line 1047
static VALUE p1788_interval_strictly_greater(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
return Interval::strictly_greater(inter, iother) ? Qtrue : Qfalse;
}
|
#strictly_less?(y) ⇒ Boolean
self is strictly less than y
(β π₯ β [ππππ], β π¦ β [π], π₯ < π¦) β§ (β π¦ β [π], β π₯ β [ππππ], π₯ < π¦)
true if ([ππππ] = β
β§ [π] = β
) β¨ ([ππππ] β β
β§ [π] β β
β§ ππππ < π β§ ππππ < π)
false otherwise
1031 1032 1033 1034 1035 1036 |
# File 'ext/p1788/p1788.cc', line 1031
static VALUE p1788_interval_strictly_less(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
return Interval::strictly_less(inter, iother) ? Qtrue : Qfalse;
}
|
#strictly_negative? ⇒ Boolean
[ππππ] β [-β, 0]
true if [ππππ] = β
β¨ ππππ < 0
false otherwise
855 856 857 858 859 |
# File 'ext/p1788/p1788.cc', line 855
static VALUE p1788_interval_strictly_negative(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
return (Interval::is_empty(inter) || Interval::sup(inter) < 0.0) ? Qtrue : Qfalse;
}
|
#strictly_positive? ⇒ Boolean
[ππππ] β [0, +β]
true if [ππππ] = β
β¨ ππππ > 0
false otherwise
828 829 830 831 832 |
# File 'ext/p1788/p1788.cc', line 828
static VALUE p1788_interval_strictly_positive(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
return (Interval::is_empty(inter) || Interval::inf(inter) > 0.0) ? Qtrue : Qfalse;
}
|
#strictly_precedes?(y) ⇒ Boolean
self is strictly to the left of y
β π₯ β [ππππ], β π¦ β [π], π₯ < π¦
true if [ππππ] = β
β¨ [π] = β
β¨ ππππ < π
false otherwise
1095 1096 1097 1098 1099 1100 |
# File 'ext/p1788/p1788.cc', line 1095
static VALUE p1788_interval_strictly_precedes(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
return Interval::strictly_precedes(inter, iother) ? Qtrue : Qfalse;
}
|
#strictly_succeeds?(y) ⇒ Boolean
self is strictly to the right of y
β π₯ β [ππππ], β π¦ β [π], π₯ > π¦
true if [ππππ] = β
β¨ [π] = β
β¨ ππππ > π
false otherwise
1111 1112 1113 1114 1115 1116 |
# File 'ext/p1788/p1788.cc', line 1111
static VALUE p1788_interval_strictly_succeeds(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
return Interval::strictly_succeeds(inter, iother) ? Qtrue : Qfalse;
}
|
#subset_of?(y) ⇒ Boolean
self is a subset of or equal to y
[ππππ] β [π]
β π₯ β [ππππ], β π¦ β [π] : π₯ = π¦
true if [ππππ] = β
β¨ ([π] β β
β§ π β€ ππππ β§ ππππ β€ π)
false otherwise
1183 1184 1185 1186 1187 1188 |
# File 'ext/p1788/p1788.cc', line 1183
static VALUE p1788_interval_subset(VALUE self, VALUE y)
{
Interval &inter = p1788_interval_rb2ref(self);
Interval iother = p1788_rbobj2interval(y);
return Interval::subset(inter, iother) ? Qtrue : Qfalse;
}
|
#succeeds?(y) ⇒ Boolean
self is to the right of but may touch y
β π₯ β [ππππ], β π¦ β [π], π₯ β₯ π¦
true if [ππππ] = β
β¨ [π] = β
β¨ ππππ β₯ π
false otherwise
1079 1080 1081 1082 1083 1084 |
# File 'ext/p1788/p1788.cc', line 1079
static VALUE p1788_interval_succeeds(VALUE self, VALUE y)
{
Interval iother = p1788_rbobj2interval(y);
Interval &inter = p1788_interval_rb2ref(self);
return Interval::succeeds(inter, iother) ? Qtrue : Qfalse;
}
|
#sup ⇒ Float? Also known as: upper_bound
Upper bound of the interval. Returns nil if the interval is empty.
1354 1355 1356 1357 1358 1359 1360 |
# File 'ext/p1788/p1788.cc', line 1354
static VALUE p1788_interval_sup(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
if (Interval::is_empty(inter))
return Qnil;
return DBL2NUM(Interval::sup(inter));
}
|
#superset_of?(y) ⇒ Boolean Also known as: contain?
self is a superset of or equal to y
[ππππ] β [π]
β π¦ β [π], β π₯ β [ππππ] : π¦ = π₯
true if [π] = β
β¨ ([ππππ] β β
β§ ππππ β€ π β§ π β€ ππππ)
false otherwise
1215 1216 1217 1218 1219 1220 |
# File 'ext/p1788/p1788.cc', line 1215
static VALUE p1788_interval_superset(VALUE self, VALUE y)
{
Interval &inter = p1788_interval_rb2ref(self);
Interval iother = p1788_rbobj2interval(y);
return Interval::superset(inter, iother) ? Qtrue : Qfalse;
}
|
#symmetric? ⇒ Boolean
The lower bound of self is the opposite of the upper bound. An empty interval is not symmetric.
901 902 903 904 905 |
# File 'ext/p1788/p1788.cc', line 901
static VALUE p1788_interval_symmetric(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
return (Interval::is_empty(inter) || Interval::inf(inter) != -Interval::sup(inter)) ? Qfalse : Qtrue;
}
|
#tan ⇒ Interval
Tangent
[ππππ].tanΒ Β =Β Β hull{ tan(π₯) | π₯ β [ππππ] }Β Β βΒ Β β
Reverse function: #tan_rev
1803 1804 1805 1806 1807 1808 |
# File 'ext/p1788/p1788.cc', line 1803
static VALUE p1788_interval_tan(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::tan(p1788_interval_rb2ref(self)));
return r;
}
|
#tan_rev(x = ALL_REALS) ⇒ Interval
Reverse tangent
tan_rev([π])Β Β =Β Β hull{ π₯ β [π] | tan(π₯) β [ππππ] }Β Β βΒ Β β
Reverse function: #tan
2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 |
# File 'ext/p1788/p1788.cc', line 2510
static VALUE p1788_interval_tan_rev(int argc, VALUE *argv, VALUE self)
{
VALUE x, r;
rb_scan_args(argc, argv, "01", &x);
if (x == Qnil) {
P1788_NEW_RB_INTERVAL(r, Interval::tan_rev(p1788_interval_rb2ref(self)));
}
else {
P1788_NEW_RB_INTERVAL(r, Interval::tan_rev(p1788_interval_rb2ref(self), p1788_rbobj2interval(x)));
}
return r;
}
|
#tanh ⇒ Interval
Hyperbolic tangent
[ππππ].tanhΒ Β =Β Β hull{ sinh(π₯) / cosh(π₯) | π₯ β [ππππ] }Β Β βΒ Β [-1, 1]
Reverse function: #atanh
1887 1888 1889 1890 1891 1892 |
# File 'ext/p1788/p1788.cc', line 1887
static VALUE p1788_interval_tanh(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::tanh(p1788_interval_rb2ref(self)));
return r;
}
|
#to_a ⇒ Array<Float>
Returns a two element arrays containing the bounds of self
.
522 523 524 525 526 527 528 529 530 531 |
# File 'ext/p1788/p1788.cc', line 522
static VALUE p1788_interval_to_a(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
if (Interval::is_empty(inter))
return rb_ary_new_capa(0);
VALUE r = rb_ary_new_capa(2);
rb_ary_store(r, 0, DBL2NUM(Interval::inf(inter)));
rb_ary_store(r, 1, DBL2NUM(Interval::sup(inter)));
return r;
}
|
#to_latex(print_dollars = true) ⇒ String
Returns a LaTex representation as a string.
733 734 735 736 737 738 739 740 741 |
# File 'ext/p1788/p1788.cc', line 733
static VALUE p1788_interval_to_latex(int argc, VALUE *argv, VALUE self)
{
VALUE arg;
if (rb_scan_args(argc, argv, "01", &arg) > 0) {
if (arg == Qnil || arg == Qfalse)
return p1788_interval_to_tex(self);
}
return rb_sprintf("$$ %" PRIsVALUE " $$", p1788_interval_to_tex(self));
}
|
#to_s ⇒ String
Returns a unicode string representation of self.
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
# File 'ext/p1788/p1788.cc', line 587
static VALUE p1788_interval_to_s(VALUE self)
{
double lb, ub;
VALUE lbc, ubc;
Interval &inter = p1788_interval_rb2ref(self);
if (Interval::is_empty(inter))
return rb_utf8_str_new_cstr("β
");
if (Interval::is_entire(inter))
return rb_utf8_str_new_cstr("β");
lb = Interval::inf(inter);
ub = Interval::sup(inter);
if ((lb == 0.0) && (ub == INF))
return rb_utf8_str_new_cstr("ββ");
if ((lb == -INF) && (ub == 0.0))
return rb_utf8_str_new_cstr("ββ");
if (lb == -INF)
lbc = rb_utf8_str_new_cstr("-β");
else if (lb == INF)
lbc = rb_utf8_str_new_cstr("+β");
else if ((double)((int)(lb)) == lb)
lbc = rb_funcallv(INT2NUM((int)lb), id_to_s, 0, NULL);
else
lbc = rb_funcallv(DBL2NUM(lb), id_to_s, 0, NULL);
if (Interval::is_singleton(inter))
return rb_sprintf("{%" PRIsVALUE "}", lbc);
if (ub == -INF)
ubc = rb_utf8_str_new_cstr("-β");
else if (ub == INF)
ubc = rb_utf8_str_new_cstr("+β");
else if ((double)((int)(ub)) == ub)
ubc = rb_funcallv(INT2NUM((int)ub), id_to_s, 0, NULL);
else
ubc = rb_funcallv(DBL2NUM(ub), id_to_s, 0, NULL);
return rb_sprintf("[%" PRIsVALUE ", %" PRIsVALUE "]", lbc, ubc);
}
|
#truncate ⇒ Interval
Round towards 0
[ππππ].truncΒ Β =Β Β [trunc(ππππ), trunc(ππππ)]
1990 1991 1992 1993 1994 1995 |
# File 'ext/p1788/p1788.cc', line 1990
static VALUE p1788_interval_trunc(VALUE self)
{
VALUE r;
P1788_NEW_RB_INTERVAL(r, Interval::trunc(p1788_interval_rb2ref(self)));
return r;
}
|
#unbounded? ⇒ Boolean
An empty interval is always bounded
One of the bounds of self is infinite
890 891 892 893 894 |
# File 'ext/p1788/p1788.cc', line 890
static VALUE p1788_interval_unbounded(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
return (Interval::is_empty(inter) || Interval::is_common_interval(inter)) ? Qfalse : Qtrue;
}
|
#width ⇒ Float?
Width of self
Width is ππππ - ππππ if [ππππ] β β , nil if [ππππ] = β
1454 1455 1456 1457 1458 1459 1460 |
# File 'ext/p1788/p1788.cc', line 1454
static VALUE p1788_interval_wid(VALUE self)
{
Interval &inter = p1788_interval_rb2ref(self);
if (Interval::is_empty(inter))
return Qnil;
return DBL2NUM(Interval::wid(inter));
}
|