DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions
DGtal::SimpleMatrixSpecializations< TMatrix, TM, TN > Struct Template Reference

#include <SimpleMatrixSpecializations.h>

Public Types

typedef TMatrix::Component Component
typedef TMatrix Matrix

Public Member Functions

 BOOST_STATIC_ASSERT (TM==TMatrix::M)
 BOOST_STATIC_ASSERT (TN==TMatrix::N)

Static Public Member Functions

static Component minorDeterminant (const Matrix &M, const DGtal::Dimension i, const DGtal::Dimension j)
static Component determinant (const Matrix &M)

Detailed Description

template<typename TMatrix, DGtal::Dimension TM, DGtal::Dimension TN>
struct DGtal::SimpleMatrixSpecializations< TMatrix, TM, TN >

Aim: Implement internal matrix services for specialized matrix size.

Description of template class 'SimpleMatrixSpecializations'

Deterimant of a matrix and the determinant of a minor of the matrix is specialized for 2x2 and 3x3 matrices.

Template Parameters:
TMatrixa type of matrix
TMnumber of rows
TNnumber of columns

Definition at line 68 of file SimpleMatrixSpecializations.h.


Member Typedef Documentation

template<typename TMatrix, DGtal::Dimension TM, DGtal::Dimension TN>
typedef TMatrix::Component DGtal::SimpleMatrixSpecializations< TMatrix, TM, TN >::Component

Matrix componenets type.

Definition at line 73 of file SimpleMatrixSpecializations.h.

template<typename TMatrix, DGtal::Dimension TM, DGtal::Dimension TN>
typedef TMatrix DGtal::SimpleMatrixSpecializations< TMatrix, TM, TN >::Matrix

Matrix type.

Definition at line 75 of file SimpleMatrixSpecializations.h.


Member Function Documentation

template<typename TMatrix, DGtal::Dimension TM, DGtal::Dimension TN>
DGtal::SimpleMatrixSpecializations< TMatrix, TM, TN >::BOOST_STATIC_ASSERT ( TM  = =TMatrix::M)
template<typename TMatrix, DGtal::Dimension TM, DGtal::Dimension TN>
DGtal::SimpleMatrixSpecializations< TMatrix, TM, TN >::BOOST_STATIC_ASSERT ( TN  = =TMatrix::N)
template<typename M >
DGtal::SimpleMatrixSpecializations< M, 3, 3 >::Component DGtal::SimpleMatrixSpecializations< M >::determinant ( const Matrix M)
inlinestatic

Returns the determinant of square matrix. Slow method for large matrices.

Precondition:
this must be NxN
Returns:
the determinant.

Definition at line 78 of file SimpleMatrixSpecializations.ih.

{
for(DGtal::Dimension i= 0; i< TM; ++i)
d += aM(i,0) * aM.cofactor(i,0);
return d;
}
template<typename M >
DGtal::SimpleMatrixSpecializations< M, 3, 3 >::Component DGtal::SimpleMatrixSpecializations< M >::minorDeterminant ( const Matrix M,
const DGtal::Dimension  i,
const DGtal::Dimension  j 
)
inlinestatic

Return the minor determinant (i,j) of the current matrix

Parameters:
irow index
jcolumn index
Returns:
the minor (i,j)

Definition at line 42 of file SimpleMatrixSpecializations.ih.

{
ASSERT(ai<TM);
ASSERT(aj<TN);
DGtal::Dimension indexR=0;
DGtal::Dimension indexC=0;
for (DGtal::Dimension i=0; i<TM; i++)
for (DGtal::Dimension j=0; j<TN; j++)
{
if (i!=ai && j!=aj)
{
ASSERT(indexR < TM -1);
ASSERT(indexC < TN -1);
mat.setComponent(indexR,indexC, aM(i,j));
indexC++;
}
if (indexC==TM-1)
{
indexC=0;
indexR++;
}
if (indexR==TM-1)
return mat.determinant();
}
return mat.determinant();
}

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