Skip to main content

Valuation

Enum Valuation 

Source
pub enum Valuation<F>
where F: ValuationRing,
{ PosInf, Finite(F), }
Expand description

Represents valuations of ultrametric numbers

In the digital representation, this is the number of digits between decimal point and first nonzero digit, possibly negative. This struct can also be used to represent certainty. E.g.

let z = ZAdic::new_approx(5, 6, vec![0, 0, 3, 1, 2, 4]);
assert_eq!(Valuation::Finite(2), z.valuation());
assert_eq!(Valuation::Finite(6), z.certainty());
assert_eq!(Valuation::Finite(0), ZAdic::empty(5).valuation());
assert_eq!(Valuation::Finite(0), ZAdic::empty(5).certainty());
assert_eq!(Valuation::PosInf, UAdic::new(5, vec![]).valuation());
assert_eq!(Valuation::PosInf, UAdic::new(5, vec![]).certainty());
assert_eq!(Valuation::Finite(0), QAdic::new(UAdic::new(5, vec![1, 2]), 0).valuation());
assert_eq!(Valuation::Finite(2), QAdic::new(UAdic::new(5, vec![1, 2]), 2).valuation());
assert_eq!(Valuation::Finite(-2), QAdic::new(UAdic::new(5, vec![1, 2]), -2).valuation());
assert_eq!(Valuation::Finite(-1), QAdic::new(UAdic::new(5, vec![0, 2]), -2).valuation());
assert_eq!(Valuation::PosInf, QAdic::new(UAdic::zero(5), -2).valuation());

Variants§

§

PosInf

Positive infinity, e.g. for the size of zero

§

Finite(F)

Finite valuation

Implementations§

Source§

impl<F> Valuation<F>
where F: ValuationRing,

Source

pub fn finite(&self) -> Option<F>

Return finite value if Finite and None if PosInf

Source

pub fn is_finite(&self) -> bool

Is the valuation finite

Source

pub fn convert<G>(self) -> Result<Valuation<G>, G::Error>
where G: ValuationRing + TryFrom<F>,

Convert from one valuation to another

§Errors

Error if the conversion attempt fails

Trait Implementations§

Source§

impl<F> Add for Valuation<F>
where F: ValuationRing,

Source§

type Output = Valuation<F>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<F> Clone for Valuation<F>
where F: ValuationRing + Clone,

Source§

fn clone(&self) -> Valuation<F>

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<F> Copy for Valuation<F>
where F: ValuationRing + Copy,

Source§

impl<F> Debug for Valuation<F>
where F: ValuationRing + Debug,

Source§

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

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

impl<F> Default for Valuation<F>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<F> Display for Valuation<F>

Source§

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

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

impl<F> Div for Valuation<F>
where F: ValuationRing + Div<Output = F>,

Source§

type Output = Option<Valuation<F>>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl<F> Eq for Valuation<F>
where F: ValuationRing + Eq,

Source§

impl<F> From<F> for Valuation<F>
where F: ValuationRing,

Source§

fn from(value: F) -> Self

Converts to this type from the input type.
Source§

impl<F> Hash for Valuation<F>
where F: ValuationRing + Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<F> Mul for Valuation<F>
where F: ValuationRing,

Source§

type Output = Valuation<F>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<F> Neg for Valuation<F>
where F: ValuationRing + Neg<Output = F>,

Source§

type Output = Option<Valuation<F>>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<F> Ord for Valuation<F>
where F: ValuationRing,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl<F> PartialEq for Valuation<F>

Source§

fn eq(&self, other: &Valuation<F>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<F> PartialOrd for Valuation<F>
where F: ValuationRing,

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<F> StructuralPartialEq for Valuation<F>

Source§

impl<F> Sub for Valuation<F>
where F: ValuationRing + Sub<Output = F>,

Source§

type Output = Option<Valuation<F>>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<F> Zero for Valuation<F>
where F: ValuationRing,

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.

Auto Trait Implementations§

§

impl<F> Freeze for Valuation<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for Valuation<F>
where F: RefUnwindSafe,

§

impl<F> Send for Valuation<F>
where F: Send,

§

impl<F> Sync for Valuation<F>
where F: Sync,

§

impl<F> Unpin for Valuation<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for Valuation<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for Valuation<F>
where F: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> LocalZero for T
where T: Zero,

Source§

fn local_zero(&self) -> T

Returns a zero local to self
Source§

fn is_local_zero(&self) -> bool

Checks whether or not self is equivalent to its local zero
Source§

fn set_local_zero(&mut self)

Sets the object equal to its local zero
Source§

impl<A, N> PrimedInto<A> for N
where A: PrimedFrom<N>,

Source§

fn primed_into<P>(self, p: P) -> A
where P: Into<Prime>,

Convert from Self to A with Prime p Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<A, N> TryPrimedInto<A> for N
where A: TryPrimedFrom<N>,

Source§

type Error = <A as TryPrimedFrom<N>>::Error

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

fn try_primed_into<P>(self, p: P) -> Result<A, <N as TryPrimedInto<A>>::Error>
where P: Into<Prime>,

Convert from Self to A with Prime p Read more