ContinuedFractions

Documentation for ContinuedFractions.

Function Index

This list is generated automatically, which may contain some internal unexported functions.

Function Docs

ContinuedFractions.ContinuedFractionType
struct ContinuedFraction{T}  where {T<:Integer} end

ContinuedFraction(qs::Vector{T}) where {T<:Integer}
ContinuedFraction(rat::Rational{T}) where {T<:Integer}
ContinuedFraction(x::AbstractFloat)
ContinuedFraction(x::Integer)

A type representing a continued fraction with integer quotients.

Fields

The fields of a structure are not part of the public API. Please use helper functions to access them, such as quotients.

Examples

julia> ContinuedFraction([1])
ContinuedFraction{Int64}([1])

julia> ContinuedFraction(1)
ContinuedFraction{Int64}([1])

julia> ContinuedFraction(10)
ContinuedFraction{Int64}([10])

julia> ContinuedFraction(3.14)
ContinuedFraction{Int64}([3, 7, 7])

julia> ContinuedFraction(big"1"/10)
ContinuedFraction{BigInt}(BigInt[0, 10])
source
ContinuedFractions.convergentsMethod
convergents(cf::ContinuedFraction) -> ConvergentIterator
convergents(qs::Vector{<:Integer}) -> ConvergentIterator
convergents(x::Real) -> ConvergentIterator

Compute the convergents of a input.

Returns

  • ConvergentIterator: An iterator over the convergents of the continued fraction.

Examples

julia> convergents([0])
ConvergentIterator{Int64}([0])

julia> convergents(3)
ConvergentIterator{Int64}([3])

julia> convergents(22/7)
ConvergentIterator{Int64}([3, 7])

julia> convergents(355/113)
ConvergentIterator{Int64}([3, 7, 16])

julia> convergents(3.1415926)
ConvergentIterator{Int64}([3, 7, 15, 1, 243, 1, 1, 9, 1, 1, 4])
source
ContinuedFractions.quotientsMethod
quotients(cf::ContinuedFraction) -> Vector{T}

Return the quotients of the given ContinuedFraction object cf.

Returns

  • A vector containing the quotients of the continued fraction.

Examples

julia> quotients(ContinuedFraction(10))
1-element Vector{Int64}:
 10

julia> quotients(ContinuedFraction(3.14))
3-element Vector{Int64}:
 3
 7
 7

julia> quotients(ContinuedFraction(big"1"/10))
2-element Vector{BigInt}:
  0
 10
source