pub struct Hypernatural { /* private fields */ }Expand description
An integer polynomial in the generator, by residue class. See the module documentation.
Implementations§
Source§impl Hypernatural
impl Hypernatural
Sourcepub fn generator(ty: &ResidueType) -> Hypernatural
pub fn generator(ty: &ResidueType) -> Hypernatural
H itself.
Sourcepub fn from_integer(n: BigInt, ty: &ResidueType) -> Hypernatural
pub fn from_integer(n: BigInt, ty: &ResidueType) -> Hypernatural
A standard integer.
Sourcepub fn from_polynomial(p: Poly, ty: &ResidueType) -> Option<Hypernatural>
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.
Sourcepub fn from_branches(value: Depends<Poly>) -> Option<Hypernatural>
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.
Sourcepub fn floor_of(
x: &Hyperreal,
ty: &ResidueType,
) -> Result<Hypernatural, FloorError>
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.
Sourcepub fn ceil_of(
x: &Hyperreal,
ty: &ResidueType,
) -> Result<Hypernatural, FloorError>
pub fn ceil_of( x: &Hyperreal, ty: &ResidueType, ) -> Result<Hypernatural, FloorError>
⌈x⌉ = −⌊−x⌋.
pub fn depends(&self) -> &Depends<Poly>
pub fn add(&self, o: &Hypernatural) -> Result<Hypernatural, ResidueError>
pub fn sub(&self, o: &Hypernatural) -> Result<Hypernatural, ResidueError>
pub fn mul(&self, o: &Hypernatural) -> Result<Hypernatural, ResidueError>
Sourcepub fn pow(&self, k: u64) -> Result<Hypernatural, PowerError>
pub fn pow(&self, k: u64) -> Result<Hypernatural, PowerError>
self^k by repeated squaring, refused when its degree would pass
MAX_POWER_DEGREE.
pub fn neg(&self) -> Hypernatural
Sourcepub fn rem(&self, k: &BigInt) -> Result<Depends<BigInt>, ResidueError>
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.
Sourcepub fn scaled_floor(&self, t: &Rational) -> Result<Hypernatural, ResidueError>
pub fn scaled_floor(&self, t: &Rational) -> Result<Hypernatural, ResidueError>
⌊t·self⌋ for a rational t.
Sourcepub fn scaled_ceil(&self, t: &Rational) -> Result<Hypernatural, ResidueError>
pub fn scaled_ceil(&self, t: &Rational) -> Result<Hypernatural, ResidueError>
⌈t·self⌉ = −⌊−t·self⌋.
Sourcepub fn compare(
&self,
o: &Hypernatural,
) -> Result<Depends<Ordering>, ResidueError>
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).
pub fn is_infinite(&self) -> Depends<bool>
pub fn is_negative(&self) -> Depends<bool>
Sourcepub fn eval_at(&self, h: u64) -> Option<BigInt>
pub fn eval_at(&self, h: u64) -> Option<BigInt>
The value at the standard point H = h, when the type admits it.
Sourcepub fn to_hyperreal(&self) -> Depends<Hyperreal>
pub fn to_hyperreal(&self) -> Depends<Hyperreal>
H ↦ 1/dt.
Sourcepub fn render(&self, generator: &str) -> String
pub fn render(&self, generator: &str) -> String
The value as a polynomial in generator, with its dependence on the residue when there is
one.
Sourcepub fn render_reciprocal(&self, inf: &str) -> String
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
impl Clone for Hypernatural
Source§fn clone(&self) -> Hypernatural
fn clone(&self) -> Hypernatural
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Hypernatural
impl Debug for Hypernatural
Source§impl ExactCodec for Hypernatural
impl ExactCodec for Hypernatural
Source§fn read(buf: &[u8], pos: &mut usize) -> Option<Self>
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.
fn to_bytes(&self) -> Vec<u8> ⓘ
Source§fn from_bytes(buf: &[u8]) -> Option<Self>
fn from_bytes(buf: &[u8]) -> Option<Self>
buf canonically encodes, with nothing left over.