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