33 #if defined(SternBrocot_RECURSES)
34 #error Recursive header files inclusion detected in SternBrocot.h
35 #else // defined(SternBrocot_RECURSES)
37 #define SternBrocot_RECURSES
39 #if !defined SternBrocot_h
47 #include "DGtal/base/Common.h"
48 #include "DGtal/base/InputIteratorWithRankOnSequence.h"
49 #include "DGtal/kernel/CInteger.h"
50 #include "DGtal/kernel/NumberTraits.h"
76 template <
typename TInteger,
typename TQuotient =
int32_t>
116 Node* ascendant_left1,
Node* ascendant_right1,
117 Node* descendant_left1,
Node* descendant_right1,
155 typedef std::pair<Quotient, Quotient>
Value;
278 void push_back(
const std::pair<Quotient, Quotient> & quotient );
290 void pushBack(
const std::pair<Quotient, Quotient> & quotient );
319 void getCFrac( std::vector<Quotient> & quotients )
const;
518 #include "DGtal/arithmetic/SternBrocot.ih"
523 #endif // !defined SternBrocot_h
525 #undef SternBrocot_RECURSES
526 #endif // else defined(SternBrocot_RECURSES)
Node * ascendantRight
the node that is the right ascendant.
static Fraction oneOverZero()
Fraction(const Self &other)
bool lessThan(Integer p1, Integer q1) const
Node * ascendantLeft
the node that is the left ascendant.
Fraction simplestFractionInBetween(const Fraction &other) const
static Fraction zeroOverOne()
SternBrocotTree::Fraction Self
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
SternBrocot(const SternBrocot &other)
Fraction father(Quotient m) const
Aim: The traits class for all models of Cinteger.
Quotient k
the depth (1+number of coefficients of its continued fraction).
SternBrocot & operator=(const SternBrocot &other)
void selfDisplay(std::ostream &out) const
Quotient nbFractions
The total number of fractions in the current tree.
bool equals(Integer p1, Integer q1) const
static SternBrocot & instance()
bool operator==(const Fraction &other) const
bool operator!=(const Fraction &other) const
Quotient u
the quotient (last coefficient of its continued fraction).
Node * descendantLeft
the node that is the left descendant or 0 (if none exist).
void pushBack(const std::pair< Quotient, Quotient > "ient)
static SternBrocot * singleton
Singleton class.
DGtal is the top-level namespace which contains all DGtal functions and types.
Fraction(Node *sb_node=0)
SternBrocot< Integer, Quotient > Self
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
ConstIterator end() const
bool moreThan(Integer p1, Integer q1) const
BOOST_CONCEPT_ASSERT((concepts::CInteger< Integer >))
Node * inverse
the node that is its inverse.
void push_back(const std::pair< Quotient, Quotient > "ient)
void getCFrac(std::vector< Quotient > "ients) const
SternBrocot< TInteger, TQuotient > SternBrocotTree
static void display(std::ostream &out, const Fraction &f)
Fraction(Integer aP, Integer aQ, Fraction ancestor=SternBrocotTree::zeroOverOne())
Fraction previousPartial() const
NumberTraits< Integer >::UnsignedVersion UnsignedInteger
Node(Integer p1, Integer q1, Quotient u1, Quotient k1, Node *ascendant_left1, Node *ascendant_right1, Node *descendant_left1, Node *descendant_right1, Node *inverse1)
Self & operator=(const Self &other)
void getSplit(Fraction &f1, Fraction &f2) const
ConstIterator const_iterator
Fraction median(const Fraction &g) const
Fraction reduced(Quotient i) const
Node * descendantRight
the node that is the right descendant or 0 (if none exist).
ConstIterator begin() const
static Fraction fraction(Integer p, Integer q, Fraction ancestor=zeroOverOne())
std::vector< Quotient > CFracSequence
Fraction partial(Quotient kp) const
Integer q
the denominator;
InputIteratorWithRankOnSequence< CFracSequence, Quotient > ConstIterator
const value_type & const_reference
bool operator<(const Fraction &other) const
void getSplitBerstel(Fraction &f1, Quotient &nb1, Fraction &f2, Quotient &nb2) const
bool operator>(const Fraction &other) const
This fraction is a model of CPositiveIrreducibleFraction.
std::pair< Quotient, Quotient > Value