DGtal  0.9.4beta
Public Member Functions | Data Fields
DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node Struct Reference

#include <DGtal/arithmetic/LightSternBrocot.h>

Collaboration diagram for DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node:
[legend]

Public Member Functions

 Node (Integer p1, Integer q1, Quotient u1, Quotient k1, Node *ascendant)
 
bool even () const
 
bool odd () const
 
bool isSameDepthLeft () const
 

Data Fields

Integer p
 
Integer q
 
Quotient u
 
Quotient k
 
Nodeascendant
 
MapQuotientToNode descendant
 
MapQuotientToNode descendant2
 

Detailed Description

template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
struct DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node

Represents a node in the Stern-Brocot. The node stores information on the irreducible fraction itself (p/q, the partial quotient u, the depth k), but also pointers to ascendants, descendants and inverse in the Stern-Brocot tree. Nodes are constructed on demand, when the user ask for descendant or for a specific fraction.

See also
LightSternBrocot::fraction

Essentially a backport from ImaGene.

Definition at line 135 of file LightSternBrocot.h.

Constructor & Destructor Documentation

template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::Node ( Integer  p1,
Integer  q1,
Quotient  u1,
Quotient  k1,
Node ascendant 
)

Constructor for node.

Parameters
p1the numerator.
q1the denominator.
u1the quotient (last coefficient of its continued fraction).
k1the depth (1+number of coefficients of its continued fraction).
ascendantA pointer to the node that is the preceding principal convergent.

Member Function Documentation

template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
bool DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::even ( ) const
inline
Returns
'true' iff this node has an even depth.

Definition at line 170 of file LightSternBrocot.h.

References DGtal::NumberTraits< T >::even().

170  {
172  }
static bool even(ParamType aT)
Definition: NumberTraits.h:162
Quotient k
the depth (1+number of coefficients of its continued fraction).
template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
bool DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::isSameDepthLeft ( ) const
inline
Returns
'true' iff the descendant with the same depth is to the left.

Definition at line 178 of file LightSternBrocot.h.

References DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::odd().

178  {
179  return odd();
180  }
template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
bool DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::odd ( ) const
inline
Returns
'true' iff this node has an odd depth.

Definition at line 174 of file LightSternBrocot.h.

References DGtal::NumberTraits< T >::odd().

Referenced by DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::isSameDepthLeft().

174  {
175  return NumberTraits<Quotient>::odd( k );
176  }
Quotient k
the depth (1+number of coefficients of its continued fraction).
static bool odd(ParamType aT)
Definition: NumberTraits.h:170

Field Documentation

template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
Node* DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::ascendant

A pointer to the node that is the preceding principal convergent.

Definition at line 159 of file LightSternBrocot.h.

template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
MapQuotientToNode DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::descendant

a map which gives the descendant [..u_n, k] if k is the key. Note that they are left or right descendant according to the parity of the depth. (odd=left, even=right).

Definition at line 163 of file LightSternBrocot.h.

template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
MapQuotientToNode DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::descendant2

a map which gives the descendant [...u_n-1,1, k] if k is the key. Note that they are left or right descendant according to the parity of the depth. (even=left, odd=right).

Definition at line 167 of file LightSternBrocot.h.

template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
Quotient DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::k

the depth (1+number of coefficients of its continued fraction).

Definition at line 157 of file LightSternBrocot.h.

Referenced by DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Fraction::trueK().

template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
Integer DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::p

the numerator;

Definition at line 151 of file LightSternBrocot.h.

template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
Integer DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::q

the denominator;

Definition at line 153 of file LightSternBrocot.h.

template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
Quotient DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::u

the quotient (last coefficient of its continued fraction).

Definition at line 155 of file LightSternBrocot.h.


The documentation for this struct was generated from the following file: