33 #if defined(LightSternBrocot_RECURSES)
34 #error Recursive header files inclusion detected in LightSternBrocot.h
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"
585 #undef LightSternBrocot_RECURSES
This fraction is a model of CPositiveIrreducibleFraction.
Fraction next1(Quotient v) const
std::pair< Quotient, Quotient > Value
LightSternBrocot< TInteger, TQuotient, TMap > SternBrocotTree
SternBrocotTree::Fraction Self
bool isAncestorDirect() const
Self & operator=(const Self &other)
bool mySup1
When 'true', the fraction is greater than 1/1 (to its right).
ConstIterator end() const
bool operator>(const Fraction &other) const
InputIteratorWithRankOnSequence< CFracSequence, Quotient > ConstIterator
Fraction partial(Quotient kp) const
Fraction(const Self &other)
bool equals(Integer p1, Integer q1) const
Fraction(Node *sb_node=0, bool sup1=false)
Fraction ancestor() const
bool moreThan(Integer p1, Integer q1) const
void getSplitBerstel(Fraction &f1, Quotient &nb1, Fraction &f2, Quotient &nb2) const
NumberTraits< Integer >::UnsignedVersion UnsignedInteger
Fraction reduced(Quotient i) const
bool lessThan(Integer p1, Integer q1) const
void pushBack(const std::pair< Quotient, Quotient > "ient)
bool operator<(const Fraction &other) const
void push_back(const std::pair< Quotient, Quotient > "ient)
Fraction next(Quotient v) const
std::vector< Quotient > CFracSequence
ConstIterator begin() const
void getCFrac(std::vector< Quotient > "ients) const
void selfDisplay(std::ostream &out) const
bool operator==(const Fraction &other) const
Fraction father(Quotient m) const
void getSplit(Fraction &f1, Fraction &f2) const
Fraction previousPartial() const
ConstIterator const_iterator
const value_type & const_reference
Fraction(Integer aP, Integer aQ, Fraction start=SternBrocotTree::zeroOverOne())
bool operator!=(const Fraction &other) const
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
LightSternBrocot< TInteger, TQuotient, TMap > Self
static Fraction fraction(Integer p, Integer q, Fraction ancestor=zeroOverOne())
static void display(std::ostream &out, const Fraction &f)
static LightSternBrocot * singleton
Singleton class.
TMap::template Rebinder< Quotient, Node * >::Type MapQuotientToNode
LightSternBrocot(const LightSternBrocot &other)
static LightSternBrocot & instance()
Quotient nbFractions
The total number of fractions in the current tree.
static Fraction oneOverZero()
BOOST_CONCEPT_ASSERT((concepts::CInteger< Integer >))
LightSternBrocot & operator=(const LightSternBrocot &other)
static Fraction zeroOverOne()
DGtal is the top-level namespace which contains all DGtal functions and types.
Integer q
the denominator;
Quotient k
the depth (1+number of coefficients of its continued fraction).
MapQuotientToNode descendant
Node * ascendant
A pointer to the node that is the preceding principal convergent.
bool isSameDepthLeft() const
Node(Integer p1, Integer q1, Quotient u1, Quotient k1, Node *ascendant)
Quotient u
the quotient (last coefficient of its continued fraction).
MapQuotientToNode descendant2
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...