Struct honestintervals::Interval
[−]
[src]
pub struct Interval<BOUND: PartialOrd> { pub lo: BOUND, pub hi: BOUND, }
Interval struct.
Represents a set where each element x
satisfies lo <= x && x <= hi
.
Fields
lo: BOUND
Inclusive lower bound.
hi: BOUND
Inclusive upper bound.
Methods
impl<BOUND: Float> Interval<BOUND>
[src]
fn new(lo: BOUND, hi: BOUND) -> Self
Constructs a new interval from given bounds.
Lower bound must be less than or equal to upper bound. Only exception is when they are both NaNs, in which case a NaN (empty) interval is created.
Cases where both bounds are negative infinity or positive infinity are not allowed as these
are empty sets. If you want to represent an empty set, use Interval::nan()
.
fn minimal_cover(intervals: Vec<Self>, precision: usize) -> Self
Constructs the minimal interval that covers all of the given intervals.
fn singleton(val: BOUND) -> Self
Constructs a singleton interval (an interval with only one element).
fn zero(precision: usize) -> Self
Constructs an interval that contains only zero.
fn one(precision: usize) -> Self
Constructs an interval that contains only one.
fn nan(precision: usize) -> Self
Constructs a NaN (empty) interval.
fn whole(precision: usize) -> Self
Constructs an interval that contains all numbers.
fn from_with_prec(val: f64, precision: usize) -> Self
Constructs an interval from a float with given precision.
fn from_str_with_prec(
s: &str,
precision: usize
) -> Result<Self, ParseIntervalError>
s: &str,
precision: usize
) -> Result<Self, ParseIntervalError>
Constructs an interval by parsing a string.
Accepts INTERVAL
according to the rule below.
INTERVAL = FLOAT | '<' FLOAT ',' FLOAT '>'
fn sign_class(&self) -> SignClass
Returns the sign class of self
.
fn precision(&self) -> usize
Returns the precision of self
.
fn size(&self) -> Self
Returns the difference between the upper bound and the lower bound of self
.
As the result is not always exactly representable as BOUND
, an interval is returned
instead.
fn is_singleton(&self) -> bool
Whether self
is a singleton interval (an interval containing only one element).
fn is_zero(&self) -> bool
Whether self
contains only zero.
fn is_nan(&self) -> bool
Whether self
is NaN (empty).
fn is_whole(&self) -> bool
Whether self
contains all numbers.
fn has_zero(&self) -> bool
Whether self
contains zero.
fn split(self, val: BOUND) -> (Self, Self)
Cuts self
into two at val
and returns the left and right pieces as a pair.
If self
lies on only one side of val
, the non-existent side will be a NaN interval.
impl<BOUND: Float> Interval<BOUND>
[src]
fn div_multi(self, rhs: Self) -> Vec<Self>
Divides self
by rhs
and returns a vector of intervals minimally covering the result.
impl<BOUND: Float> Interval<BOUND>
[src]
fn pow_multi(self, rhs: Self) -> Vec<Self>
Computes self
raised to the power rhs
and returns a vector of intervals minimally
covering the result.
Trait Implementations
impl<BOUND: Clone + PartialOrd> Clone for Interval<BOUND>
[src]
fn clone(&self) -> Interval<BOUND>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<BOUND: Debug + PartialOrd> Debug for Interval<BOUND>
[src]
impl<BOUND: Float> From<f64> for Interval<BOUND>
[src]
impl<BOUND: Float> FromStr for Interval<BOUND>
[src]
type Err = ParseIntervalError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses a string s
to return a value of this type. Read more
impl<BOUND: Float> Display for Interval<BOUND>
[src]
impl<BOUND: Float> Into<(BOUND, BOUND)> for Interval<BOUND>
[src]
impl<BOUND: Float> PartialEq for Interval<BOUND>
[src]
fn eq(&self, rhs: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<BOUND: Float> Neg for Interval<BOUND>
[src]
type Output = Self
The resulting type after applying the -
operator
fn neg(self) -> Self::Output
The method for the unary -
operator
impl<BOUND: Float> Add<Self> for Interval<BOUND>
[src]
type Output = Self
The resulting type after applying the +
operator
fn add(self, rhs: Self) -> Self::Output
The method for the +
operator
impl<BOUND: Float> Sub<Self> for Interval<BOUND>
[src]
type Output = Self
The resulting type after applying the -
operator
fn sub(self, rhs: Self) -> Self::Output
The method for the -
operator
impl<BOUND: Float> Mul<Self> for Interval<BOUND>
[src]
type Output = Self
The resulting type after applying the *
operator
fn mul(self, rhs: Self) -> Self::Output
The method for the *
operator
impl<BOUND: Float> Div<Self> for Interval<BOUND>
[src]
type Output = Self
The resulting type after applying the /
operator
fn div(self, rhs: Self) -> Self::Output
The method for the /
operator