DGtal 1.4.0
Loading...
Searching...
No Matches
DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger > Class Template Reference

Aim: Small class useful to compute, in an incremental way, the determinant of a 2x2 matrix from its four coefficients, ie. \( \begin{vmatrix} a & x \\ b & y \end{vmatrix} \). More...

#include <DGtal/geometry/tools/determinant/SimpleIncremental2x2DetComputer.h>

Public Types

typedef TArgumentInteger ArgumentInteger
 
typedef ArgumentInteger Integer
 
typedef ArgumentInteger argument_type
 
typedef TResultInteger ResultInteger
 
typedef ResultInteger Value
 
typedef ResultInteger result_type
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CEuclideanRing< ArgumentInteger >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CEuclideanRing< ArgumentInteger >))
 
 SimpleIncremental2x2DetComputer ()
 
 SimpleIncremental2x2DetComputer (const SimpleIncremental2x2DetComputer &other)
 
SimpleIncremental2x2DetComputeroperator= (const SimpleIncremental2x2DetComputer &other)
 
 ~SimpleIncremental2x2DetComputer ()
 
void init (const ArgumentInteger &aA, const ArgumentInteger &aB)
 
ResultInteger operator() (const ArgumentInteger &aX, const ArgumentInteger &aY) const
 
ResultInteger operator() (const ArgumentInteger &aA, const ArgumentInteger &aB, const ArgumentInteger &aX, const ArgumentInteger &aY)
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Private Member Functions

void partialComputation () const
 

Private Attributes

ResultInteger myA
 
ResultInteger myB
 
ResultInteger myAY
 
ResultInteger myBX
 
ResultInteger myDet
 
ResultInteger myX
 
ResultInteger myY
 
ResultInteger myDX
 
ResultInteger myDY
 
ResultInteger myADY
 
ResultInteger myBDX
 
ResultInteger myDDet
 
const ResultInteger myZero
 

Detailed Description

template<typename TArgumentInteger, typename TResultInteger = TArgumentInteger>
class DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >

Aim: Small class useful to compute, in an incremental way, the determinant of a 2x2 matrix from its four coefficients, ie. \( \begin{vmatrix} a & x \\ b & y \end{vmatrix} \).

This class is a model of C2x2DetComputer.

It should be used to compute the determinant \( ay - bx \), for various \( x, y \) and given \( a \) and \( b \). Let us assume that the determinant \( \delta_i = ay_i - bx_i \) is computed. The determinant \( \delta_j = ay_j - bx_j \) is then computed incrementally as follows: \( \delta_j = a(y_j - y_i) - b(x_j - x_i) \). The computation is simplified if the differences \( (x_j - x_i) \) and \( (y_j - y_i) \) are equal to 0 or 1, as it may occur in digital geometry.

In order to use SimpleIncremental2x2DetComputer

  • first, you must set the first column vector, ie. \( a \) and \( b \), using method SimpleIncremental2x2DetComputer::init().
  • then, you must call method SimpleIncremental2x2DetComputer::operator() on the second column vector, ie. \( x \) and \( y \).
Template Parameters
TArgumentIntegera model of CEuclideanRing for the input coefficients of the 2x2 matrix
TResultIntegera model of CEuclideanRing for the result. It must be either unbounded or twice as big as TArgumentInteger, ie. if TArgumentInteger is a type coded on b bits, TResultInteger must be coded on 2b+1 bits

Note that if you use the same type for the arguments and the result, the code may fail to provide the exact result because of a possible overflow.

See also
Simple2x2DetComputer

Definition at line 93 of file SimpleIncremental2x2DetComputer.h.

Member Typedef Documentation

◆ argument_type

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
typedef ArgumentInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::argument_type

STL alias of type ArgumentInteger

Definition at line 109 of file SimpleIncremental2x2DetComputer.h.

◆ ArgumentInteger

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
typedef TArgumentInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::ArgumentInteger

Type of integer for the input coefficients of the 2x2 matrix

Definition at line 100 of file SimpleIncremental2x2DetComputer.h.

◆ Integer

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
typedef ArgumentInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::Integer

DGtal alias of type ArgumentInteger

Definition at line 105 of file SimpleIncremental2x2DetComputer.h.

◆ result_type

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
typedef ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::result_type

STL alias of type ResultInteger

Definition at line 124 of file SimpleIncremental2x2DetComputer.h.

◆ ResultInteger

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
typedef TResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::ResultInteger

Type of integer for the returned determinant

Definition at line 114 of file SimpleIncremental2x2DetComputer.h.

◆ Value

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
typedef ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::Value

DGtal alias type of ResultInteger

Definition at line 120 of file SimpleIncremental2x2DetComputer.h.

Constructor & Destructor Documentation

◆ SimpleIncremental2x2DetComputer() [1/2]

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::SimpleIncremental2x2DetComputer ( )

Default constructor.

◆ SimpleIncremental2x2DetComputer() [2/2]

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::SimpleIncremental2x2DetComputer ( const SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger > & other)

Copy constructor.

Parameters
otherthe object to clone.

◆ ~SimpleIncremental2x2DetComputer()

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::~SimpleIncremental2x2DetComputer ( )

Destructor.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/2]

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CEuclideanRing< ArgumentInteger >) )

◆ BOOST_CONCEPT_ASSERT() [2/2]

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CEuclideanRing< ArgumentInteger >) )

◆ init()

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
void DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::init ( const ArgumentInteger & aA,
const ArgumentInteger & aB )

Initialisation.

Parameters
aA0-component of the first column vector
aB1-component of the first column vector
See also
operator()

◆ isValid()

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
bool DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

◆ operator()() [1/2]

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::operator() ( const ArgumentInteger & aA,
const ArgumentInteger & aB,
const ArgumentInteger & aX,
const ArgumentInteger & aY )

Operator.

Parameters
aA0-component of the first column vector
aB1-component of the first column vector
aX0-component of the second column vector
aY1-component of the second column vector
Returns
determinant of the 2x2 matrix that consists of the two above column vectors, ie. aA . aY - aB . aX

◆ operator()() [2/2]

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::operator() ( const ArgumentInteger & aX,
const ArgumentInteger & aY ) const

Incremental operator.

Precondition
init must be called before
Parameters
aX0-component of the second column vector
aY1-component of the second column vector
Returns
the 2x2 matrix determinant, ie. myAY . aY - myBX . aX

◆ operator=()

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
SimpleIncremental2x2DetComputer & DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::operator= ( const SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger > & other)

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

◆ partialComputation()

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
void DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::partialComputation ( ) const
private

Update myDet with respect to the new value of myDY.

Precondition
myDY should be updated first
See also
operator()

◆ selfDisplay()

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
void DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::selfDisplay ( std::ostream & out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Field Documentation

◆ myA

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myA
private

Data member used to store the 0-component of the first column vector, ie. a.

Definition at line 204 of file SimpleIncremental2x2DetComputer.h.

◆ myADY

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myADY
mutableprivate

Data member used to store the product a.dy.

Definition at line 245 of file SimpleIncremental2x2DetComputer.h.

◆ myAY

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myAY
mutableprivate

Data member used to store the product a.y

Definition at line 213 of file SimpleIncremental2x2DetComputer.h.

◆ myB

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myB
private

Data member used to store the 1-component of the first column vector, ie. b.

Definition at line 209 of file SimpleIncremental2x2DetComputer.h.

◆ myBDX

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myBDX
mutableprivate

Data member used to store the product b.dx.

Definition at line 249 of file SimpleIncremental2x2DetComputer.h.

◆ myBX

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myBX
mutableprivate

Data member used to store the product b.x

Definition at line 217 of file SimpleIncremental2x2DetComputer.h.

◆ myDDet

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myDDet
mutableprivate

Data member used to store the partial determinant, ie. a.dy - b.dx

Definition at line 253 of file SimpleIncremental2x2DetComputer.h.

◆ myDet

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myDet
mutableprivate

Data member used to store the determinant, ie. ay - bx

Definition at line 221 of file SimpleIncremental2x2DetComputer.h.

◆ myDX

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myDX
mutableprivate

Data member used to store the difference between the last 0-component of the second column vector and a new one.

Definition at line 236 of file SimpleIncremental2x2DetComputer.h.

◆ myDY

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myDY
mutableprivate

Data member used to store the difference between the last 1-component of the second column vector and a new one.

Definition at line 241 of file SimpleIncremental2x2DetComputer.h.

◆ myX

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myX
mutableprivate

Data member used to store the 0-component of the second column vector, ie. x.

Definition at line 226 of file SimpleIncremental2x2DetComputer.h.

◆ myY

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myY
mutableprivate

Data member used to store the 1-component of the second column vector, ie. y.

Definition at line 231 of file SimpleIncremental2x2DetComputer.h.

◆ myZero

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
const ResultInteger DGtal::SimpleIncremental2x2DetComputer< TArgumentInteger, TResultInteger >::myZero
private

Definition at line 255 of file SimpleIncremental2x2DetComputer.h.


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