pub struct IntExtSternBrocot {
pub p: i64,
pub q: i64,
}Expand description
Stern-Brocot tree node: a rational number p/q in lowest terms.
Fields§
§p: i64Numerator.
q: i64Denominator (positive).
Implementations§
Source§impl IntExtSternBrocot
impl IntExtSternBrocot
Sourcepub fn left_child(self) -> Self
pub fn left_child(self) -> Self
The left child (mediant with 0/1).
Sourcepub fn right_child(self) -> Self
pub fn right_child(self) -> Self
The right child (mediant with 1/0 ancestor).
Sourcepub fn approximate(target_num: i64, target_den: i64, steps: usize) -> Self
pub fn approximate(target_num: i64, target_den: i64, steps: usize) -> Self
Approximate pi/4 using the Stern-Brocot tree (returns p/q < target or p/q > target). Steps from root, going left if current > target_num/target_den, right otherwise.
Trait Implementations§
Source§impl Clone for IntExtSternBrocot
impl Clone for IntExtSternBrocot
Source§fn clone(&self) -> IntExtSternBrocot
fn clone(&self) -> IntExtSternBrocot
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 moreSource§impl Debug for IntExtSternBrocot
impl Debug for IntExtSternBrocot
Source§impl PartialEq for IntExtSternBrocot
impl PartialEq for IntExtSternBrocot
impl Copy for IntExtSternBrocot
impl Eq for IntExtSternBrocot
impl StructuralPartialEq for IntExtSternBrocot
Auto Trait Implementations§
impl Freeze for IntExtSternBrocot
impl RefUnwindSafe for IntExtSternBrocot
impl Send for IntExtSternBrocot
impl Sync for IntExtSternBrocot
impl Unpin for IntExtSternBrocot
impl UnsafeUnpin for IntExtSternBrocot
impl UnwindSafe for IntExtSternBrocot
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