33 #if defined(LighterSternBrocot_RECURSES) 34 #error Recursive header files inclusion detected in LighterSternBrocot.h 35 #else // defined(LighterSternBrocot_RECURSES) 37 #define LighterSternBrocot_RECURSES 39 #if !defined LighterSternBrocot_h 41 #define LighterSternBrocot_h 47 #include "DGtal/base/Common.h" 48 #include "DGtal/base/StdRebinders.h" 49 #include "DGtal/base/InputIteratorWithRankOnSequence.h" 50 #include "DGtal/kernel/CInteger.h" 51 #include "DGtal/kernel/NumberTraits.h" 106 template <
typename TInteger,
typename TQuotient,
107 typename TMap = StdMapRebinder >
119 typedef typename TMap:: template Rebinder<Quotient, Node*>::Type
MapQuotientToNode;
223 typedef std::pair<Quotient, Quotient>
Value;
378 void push_back(
const std::pair<Quotient, Quotient> & quotient );
390 void pushBack(
const std::pair<Quotient, Quotient> & quotient );
419 void getCFrac( std::vector<Quotient> & quotients )
const;
531 static void display ( std::ostream & out,
const Fraction & f );
600 #include "DGtal/arithmetic/LighterSternBrocot.ih" 605 #endif // !defined LighterSternBrocot_h 607 #undef LighterSternBrocot_RECURSES 608 #endif // else defined(LighterSternBrocot_RECURSES)
MapQuotientToNode myChildren
void getSplitBerstel(Fraction &f1, Quotient &nb1, Fraction &f2, Quotient &nb2) const
Quotient u
the quotient (last coefficient of its continued fraction).
MyDigitalSurface::ConstIterator ConstIterator
std::vector< Quotient > CFracSequence
Fraction reduced(Quotient i) const
void getSplit(Fraction &f1, Fraction &f2) const
This fraction is a model of CPositiveIrreducibleFraction.
bool operator!=(const Fraction &other) const
static void display(std::ostream &out, const Fraction &f)
Self & operator=(const Self &other)
void push_back(const std::pair< Quotient, Quotient > "ient)
TMap::template Rebinder< Quotient, Node * >::Type MapQuotientToNode
bool isSameDepthLeft() const
bool moreThan(Integer p1, Integer q1) const
LighterSternBrocot< TInteger, TQuotient, TMap > SternBrocotTree
static Fraction oneOverZero()
void pushBack(const std::pair< Quotient, Quotient > "ient)
Fraction partial(Quotient kp) const
LighterSternBrocot & operator=(const LighterSternBrocot &other)
static Fraction fraction(Integer p, Integer q, Fraction ancestor=oneOverZero())
Fraction(Integer aP, Integer aQ, Fraction start=SternBrocotTree::zeroOverOne())
static Fraction oneOverOne()
void getCFrac(std::vector< Quotient > "ients) const
Node(Integer p1, Integer q1, Quotient u1, Quotient k1, Node *anOrigin)
bool operator<(const Fraction &other) const
bool lessThan(Integer p1, Integer q1) const
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
bool operator==(const Fraction &other) const
Integer q
the denominator;
static LighterSternBrocot * singleton
Singleton class.
ConstIterator end() const
Aim: The traits class for all models of Cinteger.
Fraction previousPartial() const
std::pair< Quotient, Quotient > Value
Node * myOrigin
A pointer to the origin node [u_0,...,u_{n-1},1].
static bool even(ParamType aT)
bool isAncestorDirect() const
DGtal is the top-level namespace which contains all DGtal functions and types.
Quotient k
the depth (1+number of coefficients of its continued fraction).
Quotient nbFractions
The total number of fractions in the current tree.
const value_type & const_reference
void selfDisplay(std::ostream &out) const
LighterSternBrocot< TInteger, TQuotient, TMap > Self
static Fraction zeroOverOne()
static LighterSternBrocot & instance()
Fraction ancestor() const
BOOST_CONCEPT_ASSERT((concepts::CInteger< Integer >))
bool mySup1
When 'true', the fraction is greater or equal than 1/1 (to its right).
InputIteratorWithRankOnSequence< CFracSequence, Quotient > ConstIterator
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
ConstIterator begin() const
Fraction next(Quotient v) const
Fraction child(Quotient v) const
NumberTraits< Integer >::UnsignedVersion UnsignedInteger
bool equals(Integer p1, Integer q1) const
ConstIterator const_iterator
SternBrocotTree::Fraction Self
bool operator>(const Fraction &other) const
static bool odd(ParamType aT)