33 #if defined(LighterSternBrocot_RECURSES)
34 #error Recursive header files inclusion detected in LighterSternBrocot.h
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 >
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;
600 #include "DGtal/arithmetic/LighterSternBrocot.ih"
607 #undef LighterSternBrocot_RECURSES
This fraction is a model of CPositiveIrreducibleFraction.
ConstIterator const_iterator
void getSplit(Fraction &f1, Fraction &f2) const
LighterSternBrocot< TInteger, TQuotient, TMap > SternBrocotTree
Self & operator=(const Self &other)
bool operator==(const Fraction &other) const
bool mySup1
When 'true', the fraction is greater or equal than 1/1 (to its right).
bool operator!=(const Fraction &other) const
Fraction(const Self &other)
NumberTraits< Integer >::UnsignedVersion UnsignedInteger
Fraction partial(Quotient kp) const
bool isAncestorDirect() const
bool operator<(const Fraction &other) const
Fraction father(Quotient m) const
Fraction child(Quotient v) const
Fraction next(Quotient v) const
ConstIterator end() const
ConstIterator begin() const
std::vector< Quotient > CFracSequence
void pushBack(const std::pair< Quotient, Quotient > "ient)
SternBrocotTree::Fraction Self
void selfDisplay(std::ostream &out) const
std::pair< Quotient, Quotient > Value
const value_type & const_reference
Fraction(Integer aP, Integer aQ, Fraction start=SternBrocotTree::zeroOverOne())
bool lessThan(Integer p1, Integer q1) const
void getSplitBerstel(Fraction &f1, Quotient &nb1, Fraction &f2, Quotient &nb2) const
Fraction(Node *sb_node=0, bool sup1=false)
void getCFrac(std::vector< Quotient > "ients) const
void push_back(const std::pair< Quotient, Quotient > "ient)
bool moreThan(Integer p1, Integer q1) const
Fraction reduced(Quotient i) const
Fraction previousPartial() const
InputIteratorWithRankOnSequence< CFracSequence, Quotient > ConstIterator
bool equals(Integer p1, Integer q1) const
bool operator>(const Fraction &other) const
Fraction ancestor() const
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
Quotient nbFractions
The total number of fractions in the current tree.
static LighterSternBrocot & instance()
static Fraction fraction(Integer p, Integer q, Fraction ancestor=oneOverZero())
BOOST_CONCEPT_ASSERT((concepts::CInteger< Integer >))
static Fraction zeroOverOne()
static LighterSternBrocot * singleton
Singleton class.
static void display(std::ostream &out, const Fraction &f)
TMap::template Rebinder< Quotient, Node * >::Type MapQuotientToNode
static Fraction oneOverOne()
LighterSternBrocot(const LighterSternBrocot &other)
static Fraction oneOverZero()
LighterSternBrocot & operator=(const LighterSternBrocot &other)
LighterSternBrocot< TInteger, TQuotient, TMap > Self
DGtal is the top-level namespace which contains all DGtal functions and types.
Node(Integer p1, Integer q1, Quotient u1, Quotient k1, Node *anOrigin)
Node * myOrigin
A pointer to the origin node [u_0,...,u_{n-1},1].
MapQuotientToNode myChildren
Integer q
the denominator;
bool isSameDepthLeft() const
Quotient u
the quotient (last coefficient of its continued fraction).
Quotient k
the depth (1+number of coefficients of its continued fraction).
std::decay< T >::type UnsignedVersion
Alias to the unsigned version of the number type.
static bool even(ParamType aT)
Check the parity of a number.
static bool odd(ParamType aT)
Check the parity of a number.
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...