DGtal 1.3.0
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node Struct Reference

#include <DGtal/arithmetic/LightSternBrocot.h>

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 134 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 169 of file LightSternBrocot.h.

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

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 177 of file LightSternBrocot.h.

177 {
178 return odd();
179 }

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 173 of file LightSternBrocot.h.

173 {
175 }
static bool odd(ParamType aT)
Check the parity of a number.
Definition: NumberTraits.h:183

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 158 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 162 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 166 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 150 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 152 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 154 of file LightSternBrocot.h.


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