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