Skip to main content

Interval

Struct Interval 

Source
pub struct Interval { /* private fields */ }
Expand description

A closed real interval [lo, hi] with Float endpoints.

Implementations§

Source§

impl Interval

Source

pub fn new(lo: Float, hi: Float, precision: u64) -> Interval

Builds [lo, hi] at the given working precision. The endpoints are used as given (assumed already correctly rounded outward).

Source

pub fn point(x: Float) -> Interval

Builds the degenerate interval [x, x].

Source

pub fn from_rational(r: &Rational, precision: u64) -> Interval

Builds the tightest interval enclosing a rational at precision bits.

Source

pub fn lower(&self) -> &Float

Returns the lower endpoint.

Source

pub fn upper(&self) -> &Float

Returns the upper endpoint.

Source

pub fn precision(&self) -> u64

Returns the working precision.

Source

pub fn contains_zero(&self) -> bool

Returns true if the interval contains zero.

Source

pub fn width(&self) -> Float

Returns an upper bound on the width hi − lo.

Source

pub fn midpoint(&self) -> Float

Returns the midpoint (rounded to nearest).

Source

pub fn add(&self, rhs: &Interval) -> Interval

Returns self + rhs.

Source

pub fn sub(&self, rhs: &Interval) -> Interval

Returns self - rhs.

Source

pub fn neg(&self) -> Interval

Returns -self.

Source

pub fn mul(&self, rhs: &Interval) -> Interval

Returns self · rhs.

Source

pub fn div(&self, rhs: &Interval) -> Interval

Returns self / rhs. Panics if rhs contains zero.

Source

pub fn sqrt(&self) -> Interval

Returns √self (requires lo >= 0).

Source

pub fn intersect(&self, rhs: &Interval) -> Option<Interval>

Returns the intersection, or None if the intervals are disjoint.

Source

pub fn hull(&self, rhs: &Interval) -> Interval

Returns the convex hull (smallest interval containing both).

Trait Implementations§

Source§

impl Add for Interval

Source§

type Output = Interval

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Interval) -> Interval

Performs the + operation. Read more
Source§

impl Add<&Interval> for &Interval

Source§

type Output = Interval

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Interval) -> Interval

Performs the + operation. Read more
Source§

impl AddAssign for Interval

Source§

fn add_assign(&mut self, rhs: Interval)

Performs the += operation. Read more
Source§

impl Clone for Interval

Source§

fn clone(&self) -> Interval

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Interval

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Interval

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Div for Interval

Source§

type Output = Interval

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Interval) -> Interval

Performs the / operation. Read more
Source§

impl Div<&Interval> for &Interval

Source§

type Output = Interval

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Interval) -> Interval

Performs the / operation. Read more
Source§

impl DivAssign for Interval

Source§

fn div_assign(&mut self, rhs: Interval)

Performs the /= operation. Read more
Source§

impl Mul for Interval

Source§

type Output = Interval

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Interval) -> Interval

Performs the * operation. Read more
Source§

impl Mul<&Interval> for &Interval

Source§

type Output = Interval

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Interval) -> Interval

Performs the * operation. Read more
Source§

impl MulAssign for Interval

Source§

fn mul_assign(&mut self, rhs: Interval)

Performs the *= operation. Read more
Source§

impl Neg for Interval

Source§

type Output = Interval

The resulting type after applying the - operator.
Source§

fn neg(self) -> Interval

Performs the unary - operation. Read more
Source§

impl Sub for Interval

Source§

type Output = Interval

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Interval) -> Interval

Performs the - operation. Read more
Source§

impl Sub<&Interval> for &Interval

Source§

type Output = Interval

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Interval) -> Interval

Performs the - operation. Read more
Source§

impl SubAssign for Interval

Source§

fn sub_assign(&mut self, rhs: Interval)

Performs the -= operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.