DGtal  1.0.0
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
 the numerator; More...
 
Integer q
 the denominator; More...
 
Quotient u
 the quotient (last coefficient of its continued fraction). More...
 
Quotient k
 the depth (1+number of coefficients of its continued fraction). More...
 
Nodeascendant
 A pointer to the node that is the preceding principal convergent. More...
 
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

◆ Node()

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

◆ even()

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.

170  {
172  }
static bool even(ParamType aT)
Check the parity of a number.
Definition: NumberTraits.h:163
Quotient k
the depth (1+number of coefficients of its continued fraction).

References DGtal::NumberTraitsImpl< std::decay< T >::type >::even(), and DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::k.

◆ isSameDepthLeft()

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.

178  {
179  return odd();
180  }

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

◆ odd()

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.

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)
Check the parity of a number.
Definition: NumberTraits.h:173

References DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::k, and DGtal::NumberTraitsImpl< std::decay< T >::type >::odd().

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

Field Documentation

◆ ascendant

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.

◆ descendant

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.

◆ descendant2

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.

◆ k

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

◆ p

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.

◆ q

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.

◆ u

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: