DGtal  1.5.beta
DGtal::AvnaimEtAl2x2DetSignComputer< TInteger > Class Template Reference

Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four coefficients, ie. More...

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

Public Types

typedef TInteger ArgumentInteger
 
typedef ArgumentInteger Integer
 
typedef ArgumentInteger argument_type
 
typedef Integer ResultInteger
 
typedef ResultInteger Value
 
typedef ResultInteger result_type
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CEuclideanRing< ArgumentInteger >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CBoundedNumber< ArgumentInteger >))
 
 BOOST_STATIC_CONSTANT (unsigned int, base=std::numeric_limits< Integer >::radix)
 
 BOOST_STATIC_CONSTANT (unsigned int, exponent=std::numeric_limits< Integer >::digits)
 
 AvnaimEtAl2x2DetSignComputer ()
 
void init (const ArgumentInteger &aA, const ArgumentInteger &aB)
 
ResultInteger operator() (const ArgumentInteger &aU, const ArgumentInteger &aV) 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

int quadrant (const Integer &aX, const Integer &aY) const
 
Integer computation (const Integer &aA, const Integer &aB, const Integer &aX, const Integer &aY) const
 
Integer recursiveComputation (const Integer &aA, const Integer &aB, const Integer &aX, const Integer &aY) const
 

Private Attributes

Integer myA
 
Integer myB
 
Integer myMax
 

Detailed Description

template<typename TInteger>
class DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >

Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four coefficients, ie.

\( \begin{vmatrix} a & x \\ b & y \end{vmatrix} \)

It returns:

  • 1 if \( ay - bx > 0\),
  • -1 if \( ay - bx < 0 \),
  • 0 if \( ay - bx = 0 \).

If the coefficients are coded with b bits, the computation only uses numbers coded with b bits too without any overflows [Avnaim et.al., 1997 : [8]].

This class is a model of C2x2DetComputer.

Template Parameters
TIntegerboth a model of CEuclideanRing (it has the usual arithmetic operators) and a model of CBoundedNumber. It can be DGtal::int8_t, DGtal::int16_t, DGtal::int32_t, DGtal::int64_t as well as float and double.
See also
Simple2x2DetComputer

Definition at line 144 of file AvnaimEtAl2x2DetSignComputer.h.

Member Typedef Documentation

◆ argument_type

template<typename TInteger >
typedef ArgumentInteger DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::argument_type

STL alias of type ArgumentInteger

Definition at line 162 of file AvnaimEtAl2x2DetSignComputer.h.

◆ ArgumentInteger

template<typename TInteger >
typedef TInteger DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::ArgumentInteger

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

Definition at line 151 of file AvnaimEtAl2x2DetSignComputer.h.

◆ Integer

template<typename TInteger >
typedef ArgumentInteger DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::Integer

DGtal alias of type ArgumentInteger

Definition at line 158 of file AvnaimEtAl2x2DetSignComputer.h.

◆ result_type

template<typename TInteger >
typedef ResultInteger DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::result_type

STL alias of type ResultInteger

Definition at line 176 of file AvnaimEtAl2x2DetSignComputer.h.

◆ ResultInteger

template<typename TInteger >
typedef Integer DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::ResultInteger

Type of integer for the returned determinant, which is an alias of type ArgumentInteger

Definition at line 168 of file AvnaimEtAl2x2DetSignComputer.h.

◆ Value

template<typename TInteger >
typedef ResultInteger DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::Value

DGtal alias type of ResultInteger

Definition at line 172 of file AvnaimEtAl2x2DetSignComputer.h.

Constructor & Destructor Documentation

◆ AvnaimEtAl2x2DetSignComputer()

template<typename TInteger >
DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::AvnaimEtAl2x2DetSignComputer ( )

Default constructor

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/2]

template<typename TInteger >
DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CBoundedNumber< ArgumentInteger >)  )

◆ BOOST_CONCEPT_ASSERT() [2/2]

template<typename TInteger >
DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CEuclideanRing< ArgumentInteger >)  )

◆ BOOST_STATIC_CONSTANT() [1/2]

template<typename TInteger >
DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::BOOST_STATIC_CONSTANT ( unsigned int  ,
base  = std::numeric_limits< Integer >::radix 
)

Data member storing the number of the base (radix) of the representation, 2 usually

◆ BOOST_STATIC_CONSTANT() [2/2]

template<typename TInteger >
DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::BOOST_STATIC_CONSTANT ( unsigned int  ,
exponent  = std::numeric_limits< Integer >::digits 
)

Data member storing the number of non-sign bits in the representation, eg. b-1 for signed integer coded with b bits.

◆ computation()

template<typename TInteger >
Integer DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::computation ( const Integer aA,
const Integer aB,
const Integer aX,
const Integer aY 
) const
private

Method that computes the sign of the determinant for strictly positive coefficients.

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
Precondition
aA, aB, aX, aY are strictly positive.
Returns
the sign of the determinant of the 2x2 matrix, ie. 1 if aA . aY - aB . aX is strictly positive, -1 if it is strictly negative, 0 otherwise
See also
recursiveComputation

◆ init()

template<typename TInteger >
void DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::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 TInteger >
bool DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::isValid ( ) const

Checks the validity/consistency of the object.

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

◆ operator()() [1/2]

template<typename TInteger >
ResultInteger DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::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
the sign of the determinant of the 2x2 matrix, ie. 1 if aA . aY - aB . aX is strictly positive, -1 if it is strictly negative, 0 otherwise

◆ operator()() [2/2]

template<typename TInteger >
ResultInteger DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::operator() ( const ArgumentInteger aU,
const ArgumentInteger aV 
) const

Incremental operator.

Precondition
init must be called before
Parameters
aU0-component of the second column vector
aV1-component of the second column vector
Returns
the sign of the determinant of the 2x2 matrix, ie. 1 if myA . aV - myB . aU is strictly positive, -1 if it is strictly negative, 0 otherwise

◆ quadrant()

template<typename TInteger >
int DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::quadrant ( const Integer aX,
const Integer aY 
) const
private

Returns the quadrant where a given vector lies

Parameters
aXx-component of the vector
aYy-component of the vector
Precondition
aX and aY must not be null
Returns
the quadrant where the vector of components aX , aY lies, ie. 0, 1, 2, or 3 in a counter-clockwise order with 0 if aX and aY are both positive.

◆ recursiveComputation()

template<typename TInteger >
Integer DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::recursiveComputation ( const Integer aA,
const Integer aB,
const Integer aX,
const Integer aY 
) const
private

Method that computes the sign of the determinant for strictly positive coefficients
aA, aB, aX, aY such that aB < aY.

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
Precondition
aA, aB, aX, aY are strictly positive and such that aB < aY
Returns
the sign of the determinant of the 2x2 matrix, ie. 1 if aA . aY - aB . aX is strictly positive, -1 if it is strictly negative, 0 otherwise

◆ selfDisplay()

template<typename TInteger >
void DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::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 TInteger >
Integer DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::myA
private

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

Definition at line 301 of file AvnaimEtAl2x2DetSignComputer.h.

◆ myB

template<typename TInteger >
Integer DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::myB
private

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

Definition at line 306 of file AvnaimEtAl2x2DetSignComputer.h.

◆ myMax

template<typename TInteger >
Integer DGtal::AvnaimEtAl2x2DetSignComputer< TInteger >::myMax
private

Data member storing the maximal representable integer, ie. 2 ^ b if the type of integer that is used is coded with b bits.

Definition at line 311 of file AvnaimEtAl2x2DetSignComputer.h.


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