pub struct ConstructiveReal {
pub approx: Vec<i64>,
pub max_prec: usize,
}Expand description
A constructive real number represented as a function from precision k to a dyadic rational m * 2^{-k} such that |x - m*2^{-k}| < 2^{-k}.
Fields§
§approx: Vec<i64>approx(k) gives the numerator m such that the approximation is m * 2^{-k}.
max_prec: usizeImplementations§
Source§impl ConstructiveReal
impl ConstructiveReal
Sourcepub fn from_rational(p: i64, q: i64, max_prec: usize) -> Self
pub fn from_rational(p: i64, q: i64, max_prec: usize) -> Self
Construct a ConstructiveReal from a rational p/q.
Sourcepub fn add(&self, other: &ConstructiveReal) -> ConstructiveReal
pub fn add(&self, other: &ConstructiveReal) -> ConstructiveReal
Add two constructive reals.
Sourcepub fn get_approx(&self, k: usize) -> (i64, usize)
pub fn get_approx(&self, k: usize) -> (i64, usize)
Get rational approximation at precision k: returns (m, k) meaning m * 2^{-k}.
Sourcepub fn approx_eq(&self, other: &ConstructiveReal, k: usize) -> bool
pub fn approx_eq(&self, other: &ConstructiveReal, k: usize) -> bool
Check if |self - other| < 2^{-k} (approximate equality at precision k).
Trait Implementations§
Source§impl Clone for ConstructiveReal
impl Clone for ConstructiveReal
Source§fn clone(&self) -> ConstructiveReal
fn clone(&self) -> ConstructiveReal
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ConstructiveReal
impl RefUnwindSafe for ConstructiveReal
impl Send for ConstructiveReal
impl Sync for ConstructiveReal
impl Unpin for ConstructiveReal
impl UnsafeUnpin for ConstructiveReal
impl UnwindSafe for ConstructiveReal
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