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

Returns an iterator of the coefficients in the continued fraction Note that for a negative number, the coefficients of it’s absolute value is returned

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

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Parse from standard format (like 355/113 = “[3; 7, 16]”, (1+sqrt(5))/2 = “[1:(1)]”)

The associated error which can be returned from parsing.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.