33 #if defined(LightSternBrocot_RECURSES) 34 #error Recursive header files inclusion detected in LightSternBrocot.h 35 #else // defined(LightSternBrocot_RECURSES) 37 #define LightSternBrocot_RECURSES 39 #if !defined LightSternBrocot_h 41 #define LightSternBrocot_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" 105 template <
typename TInteger,
typename TQuotient,
106 typename TMap = StdMapRebinder>
118 typedef typename TMap:: template Rebinder<Quotient, Node*>::Type
MapQuotientToNode;
200 typedef std::pair<Quotient, Quotient>
Value;
353 void push_back(
const std::pair<Quotient, Quotient> & quotient );
365 void pushBack(
const std::pair<Quotient, Quotient> & quotient );
394 void getCFrac( std::vector<Quotient> & quotients )
const;
505 static void display ( std::ostream & out,
const Fraction & f );
579 #include "DGtal/arithmetic/LightSternBrocot.ih" 584 #endif // !defined LightSternBrocot_h 586 #undef LightSternBrocot_RECURSES 587 #endif // else defined(LightSternBrocot_RECURSES) Fraction ancestor() const
Quotient u
the quotient (last coefficient of its continued fraction).
static LightSternBrocot * singleton
Singleton class.
MyDigitalSurface::ConstIterator ConstIterator
NumberTraits< Integer >::UnsignedVersion UnsignedInteger
Quotient nbFractions
The total number of fractions in the current tree.
std::pair< Quotient, Quotient > Value
bool lessThan(Integer p1, Integer q1) const
static Fraction zeroOverOne()
LightSternBrocot< TInteger, TQuotient, TMap > SternBrocotTree
ConstIterator end() const
InputIteratorWithRankOnSequence< CFracSequence, Quotient > ConstIterator
Fraction(Integer aP, Integer aQ, Fraction start=SternBrocotTree::zeroOverOne())
Node(Integer p1, Integer q1, Quotient u1, Quotient k1, Node *ascendant)
bool operator>(const Fraction &other) const
static LightSternBrocot & instance()
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
void selfDisplay(std::ostream &out) const
Integer q
the denominator;
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
TMap::template Rebinder< Quotient, Node * >::Type MapQuotientToNode
LightSternBrocot< TInteger, TQuotient, TMap > Self
static Fraction fraction(Integer p, Integer q, Fraction ancestor=zeroOverOne())
void getSplit(Fraction &f1, Fraction &f2) const
ConstIterator begin() const
bool isSameDepthLeft() const
void getCFrac(std::vector< Quotient > "ients) const
Self & operator=(const Self &other)
Fraction partial(Quotient kp) const
Aim: The traits class for all models of Cinteger.
MapQuotientToNode descendant
ConstIterator const_iterator
bool mySup1
When 'true', the fraction is greater than 1/1 (to its right).
BOOST_CONCEPT_ASSERT((concepts::CInteger< Integer >))
static bool even(ParamType aT)
bool equals(Integer p1, Integer q1) const
DGtal is the top-level namespace which contains all DGtal functions and types.
std::vector< Quotient > CFracSequence
Fraction next(Quotient v) const
MapQuotientToNode descendant2
bool operator==(const Fraction &other) const
void getSplitBerstel(Fraction &f1, Quotient &nb1, Fraction &f2, Quotient &nb2) const
static void display(std::ostream &out, const Fraction &f)
const value_type & const_reference
Quotient k
the depth (1+number of coefficients of its continued fraction).
Fraction previousPartial() const
This fraction is a model of CPositiveIrreducibleFraction.
bool moreThan(Integer p1, Integer q1) const
LightSternBrocot & operator=(const LightSternBrocot &other)
bool isAncestorDirect() const
Fraction reduced(Quotient i) const
bool operator<(const Fraction &other) const
bool operator!=(const Fraction &other) const
void push_back(const std::pair< Quotient, Quotient > "ient)
SternBrocotTree::Fraction Self
Fraction next1(Quotient v) const
Node * ascendant
A pointer to the node that is the preceding principal convergent.
void pushBack(const std::pair< Quotient, Quotient > "ient)
static Fraction oneOverZero()
static bool odd(ParamType aT)