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

Aim: Small class useful to compute 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/Simple2x2DetComputer.h>

Inheritance diagram for DGtal::Simple2x2DetComputer< TArgumentInteger, TResultInteger >:
[legend]

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 >))
 
 Simple2x2DetComputer ()
 
 Simple2x2DetComputer (const Simple2x2DetComputer &other)
 
Simple2x2DetComputeroperator= (const Simple2x2DetComputer &other)
 
 ~Simple2x2DetComputer ()
 
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 Attributes

ResultInteger myA
 
ResultInteger myB
 
ResultInteger myAY
 
ResultInteger myBX
 

Detailed Description

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

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

This class, which is a model of C2x2DetComputer, just computes the quantity \( ay - bx \).

In order to use Simple2x2DetComputer in its incremental form:

  • first, you must set the first column vector, ie. \( a \) and \( b \), using method Simple2x2DetComputer::init().
  • then, you must call method Simple2x2DetComputer::operator() on the second column vector, ie. \( x \) and \( y \).

Note that since a substantial part of the execution time comes from the allocation/desallocation of integers, we follow the same strategy used in IntegerComputer: the user instantiates once this object and computes the determinant several times with it.

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
AvnaimEtAl2x2DetSignComputer
Examples
geometry/tools/determinant/exampleInHalfPlane.cpp.

Definition at line 92 of file Simple2x2DetComputer.h.

Member Typedef Documentation

◆ argument_type

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

STL alias of type ArgumentInteger

Definition at line 108 of file Simple2x2DetComputer.h.

◆ ArgumentInteger

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

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

Definition at line 99 of file Simple2x2DetComputer.h.

◆ Integer

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

DGtal alias of type ArgumentInteger

Definition at line 104 of file Simple2x2DetComputer.h.

◆ result_type

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

STL alias of type ResultInteger

Definition at line 123 of file Simple2x2DetComputer.h.

◆ ResultInteger

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

Type of integer for the returned determinant

Definition at line 113 of file Simple2x2DetComputer.h.

◆ Value

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

DGtal alias type of ResultInteger

Definition at line 119 of file Simple2x2DetComputer.h.

Constructor & Destructor Documentation

◆ Simple2x2DetComputer() [1/2]

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

Default constructor.

◆ Simple2x2DetComputer() [2/2]

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

Copy constructor.

Parameters
otherthe object to clone.

◆ ~Simple2x2DetComputer()

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

Destructor.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/2]

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

◆ BOOST_CONCEPT_ASSERT() [2/2]

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

◆ init()

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
void DGtal::Simple2x2DetComputer< 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::Simple2x2DetComputer< 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::Simple2x2DetComputer< 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::Simple2x2DetComputer< 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. myAX . aY - myBY . aX

◆ operator=()

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

Assignment.

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

◆ selfDisplay()

template<typename TArgumentInteger , typename TResultInteger = TArgumentInteger>
void DGtal::Simple2x2DetComputer< 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::Simple2x2DetComputer< TArgumentInteger, TResultInteger >::myA
private

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

Definition at line 202 of file Simple2x2DetComputer.h.

◆ myAY

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

Data member used to store the product ay

Definition at line 211 of file Simple2x2DetComputer.h.

◆ myB

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

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

Definition at line 207 of file Simple2x2DetComputer.h.

◆ myBX

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

Data member used to store the product bx

Definition at line 215 of file Simple2x2DetComputer.h.


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