DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Data Fields
DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node Struct Reference

#include <LightSternBrocot.h>

Collaboration diagram for DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node:
Collaboration graph
[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 137 of file LightSternBrocot.h.


Constructor & Destructor Documentation

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

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.

Definition at line 50 of file LightSternBrocot.ih.

: p( p1 ), q( q1 ), u( u1 ), k( k1 ),
ascendant( _ascendant )
{
// if ( k == 0 )
//std::cerr << "(" << p1 << "/" << q1 << "," << u1 << "," << k1 << ")";
}

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

References DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::k.

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

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

{
return odd();
}
template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
bool DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::odd ( ) const
inline

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

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

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

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

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

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

template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
Quotient DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::k
template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
Integer DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::p
template<typename TInteger, typename TQuotient, typename TMap = StdMapRebinder>
Integer DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::q
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 157 of file LightSternBrocot.h.


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