Skip to main content

Hypernatural

Struct Hypernatural 

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

An integer polynomial in the generator, by residue class. See the module documentation.

Implementations§

Source§

impl Hypernatural

Source

pub fn generator(ty: &ResidueType) -> Hypernatural

H itself.

Source

pub fn from_integer(n: BigInt, ty: &ResidueType) -> Hypernatural

A standard integer.

Source

pub fn from_polynomial(p: Poly, ty: &ResidueType) -> Option<Hypernatural>

The polynomial p in H as an infinite integer, when it is an integer on every class the type admits: a polynomial of degree d that is an integer at d + 1 consecutive integers is one at every integer, and likewise along one residue class.

Source

pub fn from_branches(value: Depends<Poly>) -> Option<Hypernatural>

The value p on each class, when each p is an integer on the admitted members of its class.

Source

pub fn floor_of( x: &Hyperreal, ty: &ResidueType, ) -> Result<Hypernatural, FloorError>

⌊x⌋ for a hyperreal x under the residue type ty. With x = P(H) + r — P its principal part with rational coefficients, r limited — and D the common denominator of P, the fractional part of P(H) is (D·P(H) mod D)/D on each class, so ⌊x⌋ = P(H) − frac + ⌊frac + r⌋ there.

Source

pub fn ceil_of( x: &Hyperreal, ty: &ResidueType, ) -> Result<Hypernatural, FloorError>

⌈x⌉ = −⌊−x⌋.

Source

pub fn depends(&self) -> &Depends<Poly>

Source

pub fn add(&self, o: &Hypernatural) -> Result<Hypernatural, ResidueError>

Source

pub fn sub(&self, o: &Hypernatural) -> Result<Hypernatural, ResidueError>

Source

pub fn mul(&self, o: &Hypernatural) -> Result<Hypernatural, ResidueError>

Source

pub fn degree(&self) -> usize

The highest degree in H over every class.

Source

pub fn pow(&self, k: u64) -> Result<Hypernatural, PowerError>

self^k by repeated squaring, refused when its degree would pass MAX_POWER_DEGREE.

Source

pub fn neg(&self) -> Hypernatural

Source

pub fn rem(&self, k: &BigInt) -> Result<Depends<BigInt>, ResidueError>

self mod k (in 0..k) on every residue class of H; refused when reading it needs more than MAX_MODULUS classes.

Source

pub fn scaled_floor(&self, t: &Rational) -> Result<Hypernatural, ResidueError>

⌊t·self⌋ for a rational t.

Source

pub fn scaled_ceil(&self, t: &Rational) -> Result<Hypernatural, ResidueError>

⌈t·self⌉ = −⌊−t·self⌋.

Source

pub fn compare( &self, o: &Hypernatural, ) -> Result<Depends<Ordering>, ResidueError>

The order against another value on every class (H exceeds every standard natural, so the leading coefficient of the difference decides).

Source

pub fn is_infinite(&self) -> Depends<bool>

Source

pub fn is_negative(&self) -> Depends<bool>

Source

pub fn eval_at(&self, h: u64) -> Option<BigInt>

The value at the standard point H = h, when the type admits it.

Source

pub fn to_hyperreal(&self) -> Depends<Hyperreal>

H ↦ 1/dt.

Source

pub fn render(&self, generator: &str) -> String

The value as a polynomial in generator, with its dependence on the residue when there is one.

Source

pub fn render_reciprocal(&self, inf: &str) -> String

The value written in the infinitesimal dt = 1/H: 2/dt + 1.

Trait Implementations§

Source§

impl Clone for Hypernatural

Source§

fn clone(&self) -> Hypernatural

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Hypernatural

Source§

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

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

impl ExactCodec for Hypernatural

Source§

fn write(&self, out: &mut Vec<u8>)

The residue-indexed polynomials in the generator.

Source§

fn read(buf: &[u8], pos: &mut usize) -> Option<Self>

Refused unless every branch is integer-valued on the admitted members of its class: a polynomial of degree d that is an integer at d + 1 consecutive members of an arithmetic progression is one at every member.

Source§

fn to_bytes(&self) -> Vec<u8> ⓘ

Source§

fn from_bytes(buf: &[u8]) -> Option<Self>

The value buf canonically encodes, with nothing left over.
Source§

impl Hash for Hypernatural

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 PartialEq for Hypernatural

Source§

fn eq(&self, other: &Hypernatural) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Hypernatural

Source§

impl StructuralPartialEq for Hypernatural

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, 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.