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>
117 Node* ascendant_left1,
Node* ascendant_right1,
118 Node* descendant_left1,
Node* descendant_right1,
156 typedef std::pair<Quotient, Quotient>
Value;
279 void push_back(
const std::pair<Quotient, Quotient> & quotient );
291 void pushBack(
const std::pair<Quotient, Quotient> & quotient );
320 void getCFrac( std::vector<Quotient> & quotients )
const;
519 #include "DGtal/arithmetic/SternBrocot.ih" 524 #endif // !defined SternBrocot_h 526 #undef SternBrocot_RECURSES 527 #endif // else defined(SternBrocot_RECURSES)
ConstIterator end() const
static Fraction fraction(Integer p, Integer q, Fraction ancestor=zeroOverOne())
void getSplit(Fraction &f1, Fraction &f2) const
bool equals(Integer p1, Integer q1) const
static SternBrocot & instance()
Node * ascendantLeft
the node that is the left ascendant.
void getSplitBerstel(Fraction &f1, Quotient &nb1, Fraction &f2, Quotient &nb2) const
SternBrocot< Integer, Quotient > Self
SternBrocot< TInteger, TQuotient > SternBrocotTree
Fraction reduced(Quotient i) const
bool operator==(const Fraction &other) const
static SternBrocot * singleton
Singleton class.
Quotient k
the depth (1+number of coefficients of its continued fraction).
InputIteratorWithRankOnSequence< CFracSequence, Quotient > ConstIterator
Quotient nbFractions
The total number of fractions in the current tree.
bool operator<(const Fraction &other) const
static Fraction oneOverZero()
bool operator!=(const Fraction &other) const
const value_type & const_reference
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Fraction median(const Fraction &g) const
Node * descendantLeft
the node that is the left descendant or 0 (if none exist).
This fraction is a model of CPositiveIrreducibleFraction.
static Fraction zeroOverOne()
Fraction partial(Quotient kp) const
SternBrocot & operator=(const SternBrocot &other)
Quotient u
the quotient (last coefficient of its continued fraction).
bool moreThan(Integer p1, Integer q1) const
std::pair< Quotient, Quotient > Value
BOOST_CONCEPT_ASSERT((concepts::CInteger< Integer >))
bool operator>(const Fraction &other) const
Aim: The traits class for all models of Cinteger.
Node * inverse
the node that is its inverse.
void getCFrac(std::vector< Quotient > "ients) const
void push_back(const std::pair< Quotient, Quotient > "ient)
std::vector< Quotient > CFracSequence
Fraction simplestFractionInBetween(const Fraction &other) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Self & operator=(const Self &other)
SternBrocotTree::Fraction Self
void selfDisplay(std::ostream &out) const
Node(Integer p1, Integer q1, Quotient u1, Quotient k1, Node *ascendant_left1, Node *ascendant_right1, Node *descendant_left1, Node *descendant_right1, Node *inverse1)
Node * descendantRight
the node that is the right descendant or 0 (if none exist).
Fraction previousPartial() const
NumberTraits< Integer >::UnsignedVersion UnsignedInteger
static void display(std::ostream &out, const Fraction &f)
Integer q
the denominator;
void pushBack(const std::pair< Quotient, Quotient > "ient)
ConstIterator begin() const
bool lessThan(Integer p1, Integer q1) const
Node * ascendantRight
the node that is the right ascendant.
ConstIterator const_iterator
Fraction(Integer aP, Integer aQ, Fraction ancestor=SternBrocotTree::zeroOverOne())
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...