pub struct ContinuedFraction<T> { /* private fields */ }Expand description
This struct represents a simple continued fraction a0 + 1/(a1 + 1/ (a2 + …)) Where a0, a1, a2 are positive integers It’s capable of representing rational numbers and quadratic surds REF: https://pi.math.cornell.edu/~gautam/ContinuedFractions.pdf https://crypto.stanford.edu/pbc/notes/contfrac/ http://www.numbertheory.org/continued_fractions.html http://www.numbertheory.org/php/cfrac.html
Implementations
pub fn aperiodic_coeffs(&self) -> &[T]ⓘ
pub fn periodic_coeffs(&self) -> &[T]ⓘ
impl<T: Integer + Clone + CheckedAdd + CheckedMul + WithSigned<Signed = U>, U: Integer + Clone + Signed> ContinuedFraction<T>
impl<T: Integer + Clone + CheckedAdd + CheckedMul + WithSigned<Signed = U>, U: Integer + Clone + Signed> ContinuedFraction<T>
Returns an iterator of the convergents
This method returns the corresponding rational number if it’s rational, returns the expansion until the first repeating occurence
TODO: implement from_float, from_rational, from_quad_surd as TryFrom traits
Return None if bit size of T is not enough
Convert the continued fraction to GeneralContinuedFraction TODO: change to Into/From traits, implement for each primitive type
Trait Implementations
impl<T: Integer + Clone + NumRef + CheckedAdd + CheckedMul + WithSigned<Signed = U>, U: QuadraticSurdBase> From<ContinuedFraction<T>> for QuadraticSurd<U> where
for<'r> &'r T: RefNum<T>,
for<'r> &'r U: RefNum<U>,
impl<T: Integer + Clone + NumRef + CheckedAdd + CheckedMul + WithSigned<Signed = U>, U: QuadraticSurdBase> From<ContinuedFraction<T>> for QuadraticSurd<U> where
for<'r> &'r T: RefNum<T>,
for<'r> &'r U: RefNum<U>,
Performs the conversion.
impl<T: QuadraticSurdBase + WithUnsigned<Unsigned = U>, U: Integer> From<QuadraticSurd<T>> for ContinuedFraction<U> where
for<'r> &'r T: RefNum<T>,
impl<T: QuadraticSurdBase + WithUnsigned<Unsigned = U>, U: Integer> From<QuadraticSurd<T>> for ContinuedFraction<U> where
for<'r> &'r T: RefNum<T>,
Performs the conversion.
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.
Auto Trait Implementations
impl<T> RefUnwindSafe for ContinuedFraction<T> where
T: RefUnwindSafe,
impl<T> Send for ContinuedFraction<T> where
T: Send,
impl<T> Sync for ContinuedFraction<T> where
T: Sync,
impl<T> Unpin for ContinuedFraction<T> where
T: Unpin,
impl<T> UnwindSafe for ContinuedFraction<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
