pub struct Dyadic { /* private fields */ }Expand description
An exact dyadic rational, numerator · 2^-scale.
Implementations§
Source§impl Dyadic
impl Dyadic
Sourcepub fn new(n: Int, k: i64) -> Dyadic
pub fn new(n: Int, k: i64) -> Dyadic
Builds n · 2^-k, canonicalizing to an odd numerator (so a positive k
scales the value down, matching the n·2⁻ᵏ convention).
Sourcepub fn scale(&self) -> i64
pub fn scale(&self) -> i64
Returns the scale k, so that the value equals numerator · 2^-k. A
positive scale is the count of fractional binary digits.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Returns true if this value is an integer (scale <= 0).
Trait Implementations§
Source§impl AddAssign for Dyadic
impl AddAssign for Dyadic
Source§fn add_assign(&mut self, rhs: Dyadic)
fn add_assign(&mut self, rhs: Dyadic)
Performs the
+= operation. Read moreimpl Eq for Dyadic
Source§impl MulAssign for Dyadic
impl MulAssign for Dyadic
Source§fn mul_assign(&mut self, rhs: Dyadic)
fn mul_assign(&mut self, rhs: Dyadic)
Performs the
*= operation. Read moreSource§impl Ord for Dyadic
impl Ord for Dyadic
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Dyadic
impl PartialOrd for Dyadic
Source§impl Ring for Dyadic
Available on crate feature dyadic only.
impl Ring for Dyadic
Available on crate feature
dyadic only.Source§const REASSOCIATIVE: bool = false
const REASSOCIATIVE: bool = false
Whether this ring’s
+/−/× are exact and associative, so that a
re-associating fast matrix multiply (Strassen–Winograd, which forms
products of sums of blocks and recombines them in a different order) is
bit-identical to the naive triple loop. Read moreSource§const EXACT: bool = false
const EXACT: bool = false
Whether this ring’s arithmetic is exact (no rounding), so that an
algebraic algorithm whose mathematical result is unique — fast
polynomial division (Newton) and the Half-GCD — is bit-identical to
the schoolbook/Euclid reference it replaces. Read more
Source§fn poly_mul(_a: &[Self], _b: &[Self]) -> Option<Vec<Self>>
fn poly_mul(_a: &[Self], _b: &[Self]) -> Option<Vec<Self>>
Optional fast dense-polynomial multiply hook, keyed on the coefficient
type, letting
Poly::mul route to a specialized
algorithm that Rust’s coherence rules forbid expressing as a Poly<T>
override. The inputs are the two operands’ coefficient slices (low-to-high,
each trimmed with a nonzero leading term); the return value is the product
coefficient vector (low-to-high). Returning None — the default — falls
back to the generic Karatsuba/schoolbook path. Read moreSource§fn multiply_cost_hint(&self) -> u64
fn multiply_cost_hint(&self) -> u64
A cheap proxy for the cost of multiplying two ring elements of roughly
self’s magnitude — for the arbitrary-precision integers/rationals, the
operand’s bit length. Read moreimpl StructuralPartialEq for Dyadic
Auto Trait Implementations§
impl Freeze for Dyadic
impl RefUnwindSafe for Dyadic
impl Send for Dyadic
impl Sync for Dyadic
impl Unpin for Dyadic
impl UnsafeUnpin for Dyadic
impl UnwindSafe for Dyadic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more