CVR-Lib last update 20 Sep 2009

cvr::lattice2D< T > Class Template Reference
[Linear AlgebraAggregate Data Types]

Container class for two dimensional lattices with arithmetical operations. More...

#include <cvrLattice2D.h>

Inheritance diagram for cvr::lattice2D< T >:

Inheritance graph
[legend]
Collaboration diagram for cvr::lattice2D< T >:

Collaboration graph
[legend]

List of all members.

Public Types

Internal classes and types
typedef genericLattice2D< T >
::value_type 
value_type
typedef genericLattice2D< T >
::size_type 
size_type
typedef lattice1D< T > row_type
typedef genericLattice2D< T >
::pointer 
pointer
typedef genericLattice2D< T >
::const_pointer 
const_pointer
typedef genericLattice2D< T >
::reference 
reference
typedef genericLattice2D< T >
::const_reference 
const_reference
typedef genericLattice2D< T >
::iterator 
iterator
typedef genericLattice2D< T >
::const_iterator 
const_iterator

Public Member Functions

 lattice2D ()
 lattice2D (const int fromRow, const int fromCol, const int toRow, const int toCol)
 lattice2D (const size_type &from, const size_type &to)
 lattice2D (const iinterval &rows, const iinterval &columns)
 lattice2D (const int fromRow, const int fromCol, const int toRow, const int toCol, const T &value)
 lattice2D (const size_type &from, const size_type &to, const T &value)
 lattice2D (const iinterval &rows, const iinterval &columns, const T &value)
 lattice2D (const int fromRow, const int fromCol, const int toRow, const int toCol, const T data[])
 lattice2D (const size_type &from, const size_type &to, const T data[])
 lattice2D (const iinterval &rows, const iinterval &columns, const T data[])
 lattice2D (const int fromRow, const int fromCol, const int toRow, const int toCol, T data[], const eConstantReference constRef)
 lattice2D (const size_type &from, const size_type &to, T data[], const eConstantReference constRef)
 lattice2D (const iinterval &rows, const iinterval &columns, T data[], const eConstantReference constRef)
 lattice2D (const genericLattice2D< T > &other)
 lattice2D (const genericLattice2D< T > &other, const int fromRow, const int fromCol, const int toRow=container::MaxIndex, const int toCol=container::MaxIndex)
 lattice2D (const genericLattice2D< T > &other, const size_type &from, const size_type &to)
 lattice2D (const genericLattice2D< T > &other, const iinterval &rows, const iinterval &columns)
 lattice2D (const genericLattice2D< T > &other, const genericLattice1D< int > &rows)
virtual ~lattice2D ()
row_typegetRow (const int row)
const row_typegetRow (const int row) const
row_typeoperator[] (const int row)
const row_typeoperator[] (const int row) const
row_type getRowCopy (const int row) const
void getRowCopy (const int row, row_type &theRow) const
row_type getColumnCopy (const int col) const
void getColumnCopy (const int col, row_type &theCol) const
lattice2D< T > & copy (const genericLattice2D< T > &other)
lattice2D< T > & copy (const genericLattice2D< T > &other, const int fromRow, const int fromCol, const int toRow=container::MaxIndex, const int toCol=container::MaxIndex)
lattice2D< T > & copy (const genericLattice2D< T > &other, const size_type &from, const size_type &to)
lattice2D< T > & copy (const genericLattice2D< T > &other, const iinterval &r, const iinterval &c)
lattice2D< T > & copy (const genericLattice2D< T > &other, const irectangle &window)
lattice2D< T > & copyRows (const genericLattice2D< T > &other, const genericLattice1D< int > &idx)
lattice2D< T > & copyColumns (const genericLattice2D< T > &other, const genericLattice1D< int > &idx)
template<typename U >
lattice2D< T > & castFrom (const genericLattice2D< U > &other)
lattice2D< T > & castFrom (const genericLattice2D< T > &other)
template<typename U >
lattice2D< T > & castFrom (const genericLattice2D< U > &other, const int fromRow, const int fromCol, const int toRow=container::MaxIndex, const int toCol=container::MaxIndex)
lattice2D< T > & castFrom (const genericLattice2D< T > &other, const int fromRow, const int fromCol, const int toRow=container::MaxIndex, const int toCol=container::MaxIndex)
const std::string & name () const
virtual lattice2D< T > * clone () const
virtual lattice2D< T > * newInstance () const
bool prettyCloseTo (const genericLattice2D< T > &other, const T &tolerance) const
lattice2D< T > & operator= (const genericLattice2D< T > &other)
Apply Methods.
Following methods are used to apply simple functions to each element of the vector.

lattice2D< T > & apply (T(*function)(T))
lattice2D< T > & apply (const genericLattice2D< T > &other, T(*function)(T))
lattice2D< T > & apply (T(*function)(const T &))
lattice2D< T > & apply (const genericLattice2D< T > &other, T(*function)(const T &))
lattice2D< T > & apply (const genericLattice2D< T > &other, T(*function)(const T &, const T &))
lattice2D< T > & apply (const genericLattice2D< T > &other, T(*function)(T, T))
lattice2D< T > & apply (const genericLattice2D< T > &a, const genericLattice2D< T > &b, T(*function)(const T &, const T &))
lattice2D< T > & apply (const genericLattice2D< T > &a, const genericLattice2D< T > &b, T(*function)(T, T))
Arithmetical Operations
lattice2D< T > & add (const genericLattice2D< T > &other)
lattice2D< T > & add (const genericLattice2D< T > &a, const genericLattice2D< T > &b)
lattice2D< T > & add (const T value)
lattice2D< T > & add (const genericLattice2D< T > &other, const T value)
lattice2D< T > & operator+= (const T value)
lattice2D< T > & operator+= (const genericLattice2D< T > &other)
lattice2D< T > operator+ (const genericLattice2D< T > &other) const
lattice2D< T > operator+ (const T value) const
lattice2D< T > operator- (const genericLattice2D< T > &other) const
lattice2D< T > operator- (const T value) const
lattice2D< T > & addScaled (const T b, const genericLattice2D< T > &other)
lattice2D< T > & addScaled (const genericLattice2D< T > &matA, const T b, const genericLattice2D< T > &matB)
lattice2D< T > & addScaled (const T a, const genericLattice2D< T > &first, const T b, const genericLattice2D< T > &second)
lattice2D< T > & subtract (const genericLattice2D< T > &other)
lattice2D< T > & subtract (const genericLattice2D< T > &a, const genericLattice2D< T > &b)
lattice2D< T > & subtract (const T value)
lattice2D< T > & subtract (const genericLattice2D< T > &other, const T value)
lattice2D< T > & operator-= (const T value)
lattice2D< T > & operator-= (const genericLattice2D< T > &other)
lattice2D< T > & multiply (const T value)
lattice2D< T > & multiply (const genericLattice2D< T > &other, const T value)
lattice2D< T > & operator*= (const T value)
lattice2D< T > & divide (const T value)
lattice2D< T > & divide (const genericLattice2D< T > &other, const T value)
lattice2D< T > & operator/= (const T value)
lattice2D< T > & emultiply (const genericLattice2D< T > &other)
lattice2D< T > & emultiply (const genericLattice2D< T > &a, const genericLattice2D< T > &b)
lattice2D< T > & edivide (const genericLattice2D< T > &other)
lattice2D< T > & edivide (const genericLattice2D< T > &a, const genericLattice2D< T > &b)
lattice2D< T > & outerProduct (const row_type &a, const row_type &b)
lattice2D< T > & transpose ()
template<typename U >
lattice2D< T > & transpose (const genericLattice2D< U > &other)
computeSumOfElements () const
computeProductOfElements () const
Find extreme values
findMinimum () const
size_type findIndexOfMinimum () const
findMaximum () const
size_type findIndexOfMaximum () const
void findExtremes (T &theMinimum, T &theMaximum) const
void findIndexOfExtremes (size_type &theIdxMinimum, size_type &theIdxMaximum) const

Protected Member Functions

Memory allocation and deallocation
Restrict all memory allocation and deallocation to these functions.

virtual row_typeallocNewRows (const int fromRow, const int toRow)


Detailed Description

template<typename T>
class cvr::lattice2D< T >

Container class for two dimensional lattices with arithmetical operations.

The cvr::lattice2D class is a container class implemented as a template, but explicitelly instantiated to a set of commonly used types:

If you need a container for other type, use cvr::genericLattice2D instead.

The cvr::genericLattice2D class allows the representation of two dimensional lattice, containing an element at each point of the lattice. The points are inidicated with an ordered pair n x m, where n and m can be taken from intervals selected at construction time, that may include negative values.

This class is similar to a cvr::matrix, but allows indexing with negative values as well, a feature useful in the representation of filter kernels or image masks. It can also be seen as a special type of cvr::genericLattice2D to which a set of arithmetical and simple linear algebra operations has been added.


Member Typedef Documentation

template<typename T>
typedef genericLattice2D<T>::const_iterator cvr::lattice2D< T >::const_iterator

Const iterator.

Reimplemented from cvr::genericLattice2D< T >.

Reimplemented in cvr::kernel2D< T >.

template<typename T>
typedef genericLattice2D<T>::const_pointer cvr::lattice2D< T >::const_pointer

Const pointer to value_type.

Reimplemented from cvr::genericLattice2D< T >.

Reimplemented in cvr::kernel2D< T >.

template<typename T>
typedef genericLattice2D<T>::const_reference cvr::lattice2D< T >::const_reference

Const reference to value_type.

Reimplemented from cvr::genericLattice2D< T >.

Reimplemented in cvr::kernel2D< T >.

template<typename T>
typedef genericLattice2D<T>::iterator cvr::lattice2D< T >::iterator

Iterator.

Reimplemented from cvr::genericLattice2D< T >.

Reimplemented in cvr::kernel2D< T >.

template<typename T>
typedef genericLattice2D<T>::pointer cvr::lattice2D< T >::pointer

Pointer to value_type.

Reimplemented from cvr::genericLattice2D< T >.

Reimplemented in cvr::kernel2D< T >.

template<typename T>
typedef genericLattice2D<T>::reference cvr::lattice2D< T >::reference

Reference to value_type.

Reimplemented from cvr::genericLattice2D< T >.

Reimplemented in cvr::kernel2D< T >.

template<typename T>
typedef lattice1D<T> cvr::lattice2D< T >::row_type

The row type of a cvr::lattice2D is a cvr::vector.

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
typedef genericLattice2D<T>::size_type cvr::lattice2D< T >::size_type

Return type of the size() member.

Reimplemented from cvr::genericLattice2D< T >.

Reimplemented in cvr::kernel2D< T >.

template<typename T>
typedef genericLattice2D<T>::value_type cvr::lattice2D< T >::value_type

Type of the contained data.

Reimplemented from cvr::genericLattice2D< T >.

Reimplemented in cvr::kernel2D< T >.


Constructor & Destructor Documentation

template<typename T>
cvr::lattice2D< T >::lattice2D (  ) 

Default constructor creates an empty lattice2D.

template<typename T>
cvr::lattice2D< T >::lattice2D ( const int  fromRow,
const int  fromCol,
const int  toRow,
const int  toCol 
)

Create a lattice2D with uninitialized elements.

Parameters:
fromRow lowest row index
fromCol lowest column index
toRow highest row index (inclusive)
toCol highest column index (inclusive)

template<typename T>
cvr::lattice2D< T >::lattice2D ( const size_type from,
const size_type to 
)

Create a rows x cols lattice2D with uninitialized elements.

Parameters:
from lowest index
to highest index (inclusive)

template<typename T>
cvr::lattice2D< T >::lattice2D ( const iinterval rows,
const iinterval columns 
)

Create a lattice2D with uninitialized elements.

Parameters:
rows interval used for the rows
columns interval used for the columns

template<typename T>
cvr::lattice2D< T >::lattice2D ( const int  fromRow,
const int  fromCol,
const int  toRow,
const int  toCol,
const T &  value 
)

Create a lattice2D and initialize all elements with the given value.

Parameters:
fromRow lowest row index
fromCol lowest column index
toRow highest row index (inclusive)
toCol highest column index (inclusive)
value value used for initializing the elements

template<typename T>
cvr::lattice2D< T >::lattice2D ( const size_type from,
const size_type to,
const T &  value 
)

Create a lattice2D and initialize all elements with the given value.

Parameters:
from lowest index
to highest index (inclusive)
value value used for initializing the elements

template<typename T>
cvr::lattice2D< T >::lattice2D ( const iinterval rows,
const iinterval columns,
const T &  value 
)

Create a lattice2D and initialize all elements with the given value.

Parameters:
rows interval used for the rows
columns interval used for the columns
value value used for initializing the elements

template<typename T>
cvr::lattice2D< T >::lattice2D ( const int  fromRow,
const int  fromCol,
const int  toRow,
const int  toCol,
const T  data[] 
)

Create a lattice2D and initialize all elements with the data pointed by data.

The first elements of the data will be copied on the first row, the next ones on the second row and so on.

Parameters:
fromRow lowest row index
fromCol lowest column index
toRow highest row index (inclusive)
toCol highest column index (inclusive)
data pointer to the memory block with the data to be initialized with.

template<typename T>
cvr::lattice2D< T >::lattice2D ( const size_type from,
const size_type to,
const T  data[] 
)

Create a lattice2D and initialize all elements with the data pointed by data.

The first elements of the data will be copied on the first row, the next ones on the second row and so on.

Parameters:
from lowest index
to highest index (inclusive)
data pointer to the memory block with the data to be initialized with.

template<typename T>
cvr::lattice2D< T >::lattice2D ( const iinterval rows,
const iinterval columns,
const T  data[] 
)

Create a lattice2D and initialize all elements with the data pointed by data.

The first elements of the data will be copied on the first row, the next ones on the second row and so on.

Parameters:
rows interval used for the rows
columns interval used for the columns
data pointer to the memory block with the data to be initialized with.

template<typename T>
cvr::lattice2D< T >::lattice2D ( const int  fromRow,
const int  fromCol,
const int  toRow,
const int  toCol,
data[],
const eConstantReference  constRef 
)

Create a lattice2D and use the given data as if it was given through the useExternData().

See also:
useExternData()
The first elements of the data will be copied on the first row, the next ones on the second row and so on.

Note:
Please observe that the last argument makes a huge difference to the constructors that do not have it. Here the data is not copied, just a reference is kept. Without the last argument, the data is always copied.
Parameters:
fromRow lowest row index
fromCol lowest column index
toRow highest row index (inclusive)
toCol highest column index (inclusive)
data pointer to the memory block with the data to be initialized with.
constRef usually you want this value to be ConstantReference.

template<typename T>
cvr::lattice2D< T >::lattice2D ( const size_type from,
const size_type to,
data[],
const eConstantReference  constRef 
)

Create a lattice2D and use the given data as if it was given through the useExternData().

See also:
useExternData()
The first elements of the data will be copied on the first row, the next ones on the second row and so on.

Note:
Please observe that the last argument makes a huge difference to the constructors that do not have it. Here the data is not copied, just a reference is kept. Without the last argument, the data is always copied.
Parameters:
from lowest index
to highest index (inclusive)
data pointer to the memory block with the data to be initialized with.
constRef usually you want this value to be ConstantReference.

template<typename T>
cvr::lattice2D< T >::lattice2D ( const iinterval rows,
const iinterval columns,
data[],
const eConstantReference  constRef 
)

Create a lattice2D and use the given data as if it was given through the useExternData().

See also:
useExternData()
The first elements of the data will be copied on the first row, the next ones on the second row and so on.

Note:
Please observe that the last argument makes a huge difference to the constructors that do not have it. Here the data is not copied, just a reference is kept. Without the last argument, the data is always copied.
Parameters:
rows interval for rows
columns interval for columns
data pointer to the memory block with the data to be initialized with.
constRef usually you want this value to be ConstantReference.

template<typename T>
cvr::lattice2D< T >::lattice2D ( const genericLattice2D< T > &  other  ) 

Copy constructor.

Create this lattice2D as a copy of another lattice2D.

Parameters:
other the lattice2D to be copied.

template<typename T>
cvr::lattice2D< T >::lattice2D ( const genericLattice2D< T > &  other,
const int  fromRow,
const int  fromCol,
const int  toRow = container::MaxIndex,
const int  toCol = container::MaxIndex 
)

Copy constructor.

Create this lattice2D as a copy of another lattice2D for this const version, the data will be always copied!

Parameters:
other the genericLattice2D to be copied.
fromRow initial row of the other genericLattice2D to be copied
fromCol initial column of the other genericLattice2D to be copied
toRow last row to be copied of the other genericLattice2D
toCol last column to be copied of the other genericLattice2D

template<typename T>
cvr::lattice2D< T >::lattice2D ( const genericLattice2D< T > &  other,
const size_type from,
const size_type to 
)

Copy constructor.

Create this lattice2D as a copy of a section of another lattice2D

Parameters:
other the genericLattice2D to be copied.
from initial position in the other genericLattice2D to be copied
to last position to be copied of the other genericLattice2D

template<typename T>
cvr::lattice2D< T >::lattice2D ( const genericLattice2D< T > &  other,
const iinterval rows,
const iinterval columns 
)

Copy constructor.

Create this lattice2D as a copy of a sublattice2D of another genericLattice2D.

Parameters:
other the genericLattice2D to be copied.
rows interval of rows to be copied.
columns interval of columns to be copied.

template<typename T>
cvr::lattice2D< T >::lattice2D ( const genericLattice2D< T > &  other,
const genericLattice1D< int > &  rows 
)

Copy constructor.

Create this lattice2D as a copy of another genericLattice2D taking only the rows indicated by the vector.

The data will be always copied! Multiple occurence of one row index in rows is allowed.

Parameters:
other the genericLattice2D to be copied.
rows indices of the rows to be copied

template<typename T>
virtual cvr::lattice2D< T >::~lattice2D (  )  [virtual]

Destructor.


Member Function Documentation

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::add ( const genericLattice2D< T > &  other,
const T  value 
)

Add constant value to the other lattice2D and leave result here.

Parameters:
other the other lattice2D
value a constant value to be added to all lattice2D elements
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::add ( const T  value  ) 

Add constant value to this lattice2D, and leave result here.

Parameters:
value a constant value to be added to all lattice2D elements
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::add ( const genericLattice2D< T > &  a,
const genericLattice2D< T > &  b 
)

Add matrices a and b and write the result in this lattice2D.

Parameters:
a the first lattice2D
b the second lattice2D
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::add ( const genericLattice2D< T > &  other  ) 

Add other lattice2D to this lattice2D, and leave result here.

Parameters:
other the lattice2D to be added with
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::addScaled ( const T  a,
const genericLattice2D< T > &  first,
const T  b,
const genericLattice2D< T > &  second 
)

Leave the scaled sum of two matrices in this lattice2D.

The matrices must be of the same types and dimensions. Let $A$ be the first lattice2D and $B$ the second lattice2D with corresponding scaling factors $a$ and $b$, further $C$ this lattice2D, then this method performs:

$C=a\cdot A+b\cdot B$

Parameters:
a scaling factor for first
first the first lattice2D to be added after scaling
b scaling factor for second
second the second lattice2D to be added after scaling
Returns:
a reference to this lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::addScaled ( const genericLattice2D< T > &  matA,
const T  b,
const genericLattice2D< T > &  matB 
)

Add a lattice2D A with a lattice2D B scaled by $b$, and leave the result in this lattice2D.

The matrices must be of the same types and dimensions. This method performs:

$A+b\cdot B$

Parameters:
matA the first lattice2D
b scaling factor for matB
matB the lattice2D to be added after scaling
Returns:
a reference to this lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::addScaled ( const T  b,
const genericLattice2D< T > &  other 
)

Add another lattice2D scaled by $b$ to this lattice2D.

The matrices must be of the same types and dimensions. Let $A$ be this lattice2D and $B$ the other lattice2D, then this method performs:

$A=A+b\cdot B$

Parameters:
b scaling factor for other
other the lattice2D to be added after scaling
Returns:
a reference to this lattice2D

template<typename T>
virtual row_type* cvr::lattice2D< T >::allocNewRows ( const int  fromRow,
const int  toRow 
) [inline, protected, virtual]

Allocate n number of rows or the appropriate type.

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::apply ( const genericLattice2D< T > &  a,
const genericLattice2D< T > &  b,
T(*)(T, T)  function 
) [inline]

A two-parameter C-function receives the i-th elements of both given matrices and leaves the result here.

Note that both matrices must have the same size!

Parameters:
a the first lattice2D
b the second lattice2D
function a pointer to C-function with two parameters
Returns:
a reference to the actual lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::apply ( const genericLattice2D< T > &  a,
const genericLattice2D< T > &  b,
T(*)(const T &, const T &)  function 
) [inline]

A two-parameter C-function receives the i-th elements of both given matrices and leaves the result here.

Note that both matrices must have the same size!

Parameters:
a the first lattice2D
b the second lattice2D
function a pointer to C-function with two parameters
Returns:
a reference to the actual lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::apply ( const genericLattice2D< T > &  other,
T(*)(T, T)  function 
) [inline]

A two-parameter C-function receives the i-th elements of this and the given lattice2D and the result will be left in this lattice2D.

Note that both matrices must have the same size!

Parameters:
other the second lattice2D to be considered (the first lattice2D will be this object!)
function a pointer to C-function with two parameters
Returns:
a reference to the actual lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::apply ( const genericLattice2D< T > &  other,
T(*)(const T &, const T &)  function 
) [inline]

A two-parameter C-function receives the i-th elements of this and the given lattice2D and the result will be left in this lattice2D.

Note that both matrices must have the same size!

Parameters:
other the second lattice2D to be considered (the first lattice2D will be this object!)
function a pointer to C-function with two parameters
Returns:
a reference to the actual lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::apply ( const genericLattice2D< T > &  other,
T(*)(const T &)  function 
) [inline]

Applies a C-function to each element of the other lattice2D.

Parameters:
other the lattice2D which elements will go through the given function.
function a pointer to a C-function
Returns:
a reference to the actual lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::apply ( T(*)(const T &)  function  )  [inline]

Applies a C-function to each element of the lattice2D.

Parameters:
function a pointer to a C-function
Returns:
a reference to the actual lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::apply ( const genericLattice2D< T > &  other,
T(*)(T)  function 
) [inline]

Applies a C-function to each element of the other lattice2D.

Parameters:
other the lattice2D which elements will go through the given function.
function a pointer to a C-function
Returns:
a reference to the actual lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::apply ( T(*)(T)  function  )  [inline]

Applies a C-function to each element of the lattice2D.

Parameters:
function a pointer to a C-function
Returns:
a reference to the actual lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::castFrom ( const genericLattice2D< T > &  other,
const int  fromRow,
const int  fromCol,
const int  toRow = container::MaxIndex,
const int  toCol = container::MaxIndex 
)

This is just an alias for copy(const genericLattice2D<T>&, const int fromRow, const int fromCol, const int toRow, const int toCol) to facilitate generic programming.

Parameters:
other The genericLattice2D to be copied.
fromRow initial row of the other genericLattice2D to be copied
fromCol initial column of the other genericLattice2D to be copied
toRow last row to be copied of the other genericLattice2D
toCol last column to be copied of the other genericLattice2D
Returns:
a reference to the current casted lattice2D.

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
template<typename U >
lattice2D<T>& cvr::lattice2D< T >::castFrom ( const genericLattice2D< U > &  other,
const int  fromRow,
const int  fromCol,
const int  toRow = container::MaxIndex,
const int  toCol = container::MaxIndex 
) [inline]

Copy a sublattice2D of the other genericLattice2D by casting each of its elements.

Parameters:
other The genericLattice2D to be casted
fromRow initial row of the other genericLattice2D to be copied
fromCol initial column of the other genericLattice2D to be copied
toRow last row to be copied of the other genericLattice2D
toCol last column to be copied of the other genericLattice2D
Returns:
a reference to the current casted lattice2D.

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::castFrom ( const genericLattice2D< T > &  other  )  [inline]

Copy the other lattice2D by casting each of its elements.

This 'specialization' ensures that the copy() method is used when U==T.

Parameters:
other The lattice2D to be casted (copied)

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
template<typename U >
lattice2D<T>& cvr::lattice2D< T >::castFrom ( const genericLattice2D< U > &  other  )  [inline]

Copy the other lattice2D by casting each of its elements Example:.

   cvr::lattice2D<int> matA(10,10,1);// a lattice2D of integers
   cvr::lattice2D<double> matB;      // a lattice2D of doubles

   matB.castFrom(matA);          // this will copy matA in matB!!

Parameters:
other The lattice2D to be casted
Returns:
reference to this lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
virtual lattice2D<T>* cvr::lattice2D< T >::clone (  )  const [virtual]

Create a clone of this lattice2D.

Returns:
a pointer to a copy of this lattice2D

Reimplemented from cvr::genericLattice2D< T >.

Reimplemented in cvr::kernel2D< T >.

template<typename T>
T cvr::lattice2D< T >::computeProductOfElements (  )  const

Calculate the product of all elements of the vector.

This member can be used with classes which define the operator '*='

template<typename T>
T cvr::lattice2D< T >::computeSumOfElements (  )  const

Calculate the sum of all elements of the lattice2D.

This member can be used with classes which define the operator '+='

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::copy ( const genericLattice2D< T > &  other,
const irectangle window 
) [inline]

Assigment operator.

Copy the contents of other in this object.

The result of the copy is always a connected lattice2D. I.e. you cannot copy the sub-lattice2D property of another lattice2D.

Parameters:
other the other lattice2D to be copied
window rectangle define the copy area

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::copy ( const genericLattice2D< T > &  other,
const iinterval r,
const iinterval c 
) [inline]

Assigment operator.

copy the contents of other in this object.

The result of the copy is always a connected lattice2D. I.e. you cannot copy the sub-lattice2D property of another lattice2D.

Parameters:
other the other lattice2D to be copied
r interval used for the rows
c interval used for the columns

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::copy ( const genericLattice2D< T > &  other,
const size_type from,
const size_type to 
) [inline]

Assigment operator.

copy the contents of other in this object.

The result of the copy is always a connected lattice2D. I.e. you cannot copy the sub-lattice2D property of another lattice2D.

Parameters:
other the other lattice2D to be copied
from initial indices of sublattice2D to be copied
to final indices of sublattice2D to be copied (included)

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::copy ( const genericLattice2D< T > &  other,
const int  fromRow,
const int  fromCol,
const int  toRow = container::MaxIndex,
const int  toCol = container::MaxIndex 
) [inline]

Assigment operator.

copy the contents of other in this object.

The result of the copy is always a connected lattice2D. I.e. you cannot copy the sub-lattice2D property of another lattice2D.

Parameters:
other the other lattice2D to be copied
fromRow initial row of the other lattice2D to be copied
fromCol initial column of the other lattice2D to be copied
toRow last row to be copied of the other lattice2D
toCol last column to be copied of the other lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::copy ( const genericLattice2D< T > &  other  )  [inline]

Assigment operator.

Copy the contents of other in this object.

The result of the copy is always a connected lattice2D. I.e. you cannot copy the sub-lattice2D property of another lattice2D.

Parameters:
other the other lattice2D to be copied

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::copyColumns ( const genericLattice2D< T > &  other,
const genericLattice1D< int > &  idx 
) [inline]

Assigment operator.

Copy the contents of the specified columns of other into this object. Multiple occurence of one column index in idx is allowed.

Parameters:
other the other lattice2D to be copied
idx indices of the rows to be copied.

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::copyRows ( const genericLattice2D< T > &  other,
const genericLattice1D< int > &  idx 
) [inline]

Assigment operator.

Copy the contents of the specified rows of other into this object. Multiple occurence of one row index in idx is allowed.

Parameters:
other the other lattice2D to be copied
idx indices of the rows to be copied.

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::divide ( const genericLattice2D< T > &  other,
const T  value 
)

Divide the elements of the other lattice2D by a constant value and leave the result here.

Parameters:
other the other lattice2D
value the constant value (divisor)
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::divide ( const T  value  ) 

Divide the elements of the lattice2D by a constant value, and leave the result here.

Parameters:
value the constant value (divisor)
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::edivide ( const genericLattice2D< T > &  a,
const genericLattice2D< T > &  b 
)

Element-wise division of a and b.

Parameters:
a the first lattice2D
b the second lattice2D (with same dimensions of a)
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::edivide ( const genericLattice2D< T > &  other  ) 

Element-wise division with other lattice2D.

Parameters:
other the other lattice2D. It should have the same dimensions of this lattice2D.
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::emultiply ( const genericLattice2D< T > &  a,
const genericLattice2D< T > &  b 
)

Element-wise multiplication of a and b.

Parameters:
a the first lattice2D
b the second lattice2D (with same dimensions of a)
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::emultiply ( const genericLattice2D< T > &  other  ) 

Element-wise multiplication with other lattice2D.

Parameters:
other the other lattice2D. It should have the same dimensions of this lattice2D.
Returns:
a reference to the actual lattice2D

template<typename T>
void cvr::lattice2D< T >::findExtremes ( T &  theMinimum,
T &  theMaximum 
) const

Get the extremes of the lattice2D (smallest and biggest elements).

template<typename T>
void cvr::lattice2D< T >::findIndexOfExtremes ( size_type theIdxMinimum,
size_type theIdxMaximum 
) const

Get the indices of the extremes of the lattice2D (smallest and biggest elements).

template<typename T>
size_type cvr::lattice2D< T >::findIndexOfMaximum (  )  const

Get the index of the biggest element of the lattice2D.

template<typename T>
size_type cvr::lattice2D< T >::findIndexOfMinimum (  )  const

Get the index of the smallest element of the lattice2D.

template<typename T>
T cvr::lattice2D< T >::findMaximum (  )  const

Get the biggest element of the lattice2D.

template<typename T>
T cvr::lattice2D< T >::findMinimum (  )  const

Get the smallest element of the lattice2D.

template<typename T>
void cvr::lattice2D< T >::getColumnCopy ( const int  col,
row_type theCol 
) const [inline]

Return genericLattice2D-column as a vector.

This method copies the data of the genericLattice2D, therefore is not as fast as getRow()

Parameters:
col the number of the column to be copied
theCol a vector, where the column vector of the genericLattice2D should be copied.

template<typename T>
row_type cvr::lattice2D< T >::getColumnCopy ( const int  col  )  const [inline]

Return lattice2D-column as a vector.

This method copies the data of the lattice2D, therefore is not as fast as getRow()

Parameters:
col the number of the column to be copied
Returns:
a vector with the contents of the column of the lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
const row_type& cvr::lattice2D< T >::getRow ( const int  row  )  const [inline]

Return lattice2D-row as a const vector.

This method works fast, since it returns a reference to the row vector. The data will NOT be copied.

Parameters:
row the row to be accessed
Returns:
a const reference to the vector row

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
row_type& cvr::lattice2D< T >::getRow ( const int  row  )  [inline]

Return lattice2D-row as a vector.

This method works fast, since it returns a reference to the row vector. The data will NOT be copied.

Parameters:
row the row to be accessed
Returns:
a reference to the vector row

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
void cvr::lattice2D< T >::getRowCopy ( const int  row,
row_type theRow 
) const [inline]

Copy a row vector in the given parameter.

This method copies the data of a given row of the genericLattice2D in the given vector.

Parameters:
row the number of the row to be copied
theRow the vector, where the data will be copied
See also:
getRow()

template<typename T>
row_type cvr::lattice2D< T >::getRowCopy ( const int  row  )  const [inline]

Return lattice2D-row as a vector.

This method copies the data of the lattice2D, therefore is not as fast as getRow()

Parameters:
row the number of tthe row to be copied
Returns:
a vector with the contents of the row of the lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::multiply ( const genericLattice2D< T > &  other,
const T  value 
)

Multiply constant value with the other lattice2D and leave result here.

Parameters:
other the other lattice2D
value the constant value to be multiplied with
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::multiply ( const T  value  ) 

Multiply constant value with this lattice2D, and leave result here.

Parameters:
value the constant value to be multiplied with
Returns:
a reference to the actual lattice2D

template<typename T>
const std::string& cvr::lattice2D< T >::name (  )  const [virtual]

Returns the name of this class.

Reimplemented from cvr::genericLattice2D< T >.

Reimplemented in cvr::kernel2D< T >.

template<typename T>
virtual lattice2D<T>* cvr::lattice2D< T >::newInstance (  )  const [virtual]

Create a new empty lattice2D.

Returns:
a pointer to a copy of this lattice2D

Reimplemented from cvr::genericLattice2D< T >.

Reimplemented in cvr::kernel2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::operator*= ( const T  value  )  [inline]

Alias for multiply(const T& value).

Parameters:
value the constant value to be multiplied with
Returns:
a reference to this lattice2D.

template<typename T>
lattice2D<T> cvr::lattice2D< T >::operator+ ( const T  value  )  const

Add constant value to this lattice2D, and leave result in a new lattice2D.

This object is not changed.

Parameters:
value a constant value to be added to all lattice2D elements
Returns:
a new lattice2D with the result

template<typename T>
lattice2D<T> cvr::lattice2D< T >::operator+ ( const genericLattice2D< T > &  other  )  const

Add other lattice2D to this lattice2D and leave the result in a new lattice2D.

This object is not changed.

Parameters:
other the other lattice2D to be added with.
Returns:
a lattice2D with the sum of this lattice2D and other
Warning:
Note that the use of this operator is not as efficient as the use of the add() methods, in which the programmer can decide when to use temporal and when not...

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::operator+= ( const genericLattice2D< T > &  other  )  [inline]

Alias for add(const lattice2D).

Parameters:
other the lattice2D to be added with
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::operator+= ( const T  value  )  [inline]

Alias for add(const T value).

Parameters:
value a constant value to be added to all lattice2D elements
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T> cvr::lattice2D< T >::operator- ( const T  value  )  const

Subtract constant value from this lattice2D, and leave result in a new lattice2D.

This object is not changed.

Parameters:
value a constant value to be added to all lattice2D elements
Returns:
a new lattice2D with the result

template<typename T>
lattice2D<T> cvr::lattice2D< T >::operator- ( const genericLattice2D< T > &  other  )  const

Subtract other lattice2D from this lattice2D and leave the result in a new lattice2D.

This object is not changed.

Parameters:
other the other lattice2D to be added with.
Returns:
a lattice2D with the sum of this lattice2D and other
Warning:
Note that the use of this operator is not as efficient as the use of the add() methods, in which the programmer can decide when to use temporal and when not...

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::operator-= ( const genericLattice2D< T > &  other  )  [inline]

Alias for subtract(const lattice2D).

Parameters:
other the lattice2D to be subtracted
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::operator-= ( const T  value  )  [inline]

Alias for subtract(const T value).

Parameters:
value a constant value to be subtracted from all lattice2D elements
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::operator/= ( const T  value  ) 

Alias for divide(const T& value).

Parameters:
value the constant value to be divided by
Returns:
a reference to this lattice2D.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::operator= ( const genericLattice2D< T > &  other  )  [inline]

Assigment operator (alias for copy(other)).

Parameters:
other the lattice2D to be copied
Returns:
a reference to the actual lattice2D

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
const row_type& cvr::lattice2D< T >::operator[] ( const int  row  )  const [inline]

Alias for getRow().

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
row_type& cvr::lattice2D< T >::operator[] ( const int  row  )  [inline]

Alias for getRow().

Reimplemented from cvr::genericLattice2D< T >.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::outerProduct ( const row_type a,
const row_type b 
)

Outer-product of two vectors.

The result will be left in this lattice2D. The dimensions of this lattice2D will change if needed. The outer product of two column vectors is defined as $a \cdot b^T$

Parameters:
a first vector (will determine the number of rows)
b second vector (will determine the number of columns)
Returns:
a reference to the actual lattice2D

template<typename T>
bool cvr::lattice2D< T >::prettyCloseTo ( const genericLattice2D< T > &  other,
const T &  tolerance 
) const

Compare this lattice2D with other, and use the given tolerance to determine if the value of each element of the other lattice2D approximately equals the values of the actual lattice2D elements.

An element x is approximately equal to another element y with a tolerance t, if following equation holds: x-t < y < x+t

This method is mainly used for matrices containing floating point values.

Parameters:
other the other lattice2D to be compared with
tolerance the tolerance to be used
Returns:
true if both matrices are approximatly equal

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::subtract ( const genericLattice2D< T > &  other,
const T  value 
)

Subtract constant value from the other lattice2D and leave result here.

Parameters:
other the other lattice2D
value a constant value to be subtracted from all lattice2D elements
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::subtract ( const T  value  ) 

Subtract constant value from this lattice2D, and leave result here.

Parameters:
value a constant value to be subtracted from all lattice2D elements
Returns:
a reference to the actual lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::subtract ( const genericLattice2D< T > &  a,
const genericLattice2D< T > &  b 
)

Subtract matrices b from a and write result in this lattice2D.

Parameters:
a the first lattice2D
b the second lattice2D
Returns:
a reference to this lattice2D, which is now a-b.

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::subtract ( const genericLattice2D< T > &  other  ) 

Subtract other lattice2D from this lattice2D, and leave result here.

Parameters:
other the lattice2D to be subtracted
Returns:
a reference to this lattice2D.

template<typename T>
template<typename U >
lattice2D<T>& cvr::lattice2D< T >::transpose ( const genericLattice2D< U > &  other  )  [inline]

Transpose the other lattice2D and leave the result here.

If U!=T each element of other is static_cast<T> in the process.

Returns:
a reference to the actual (now transposed) lattice2D

template<typename T>
lattice2D<T>& cvr::lattice2D< T >::transpose (  ) 

Transpose lattice2D and leave the result here.

If the lattice2D is square this is actually a fast on-place operation. However, if the lattice2D is not square a temporary lattice2D is created with the new dimensions. This can be less efficient than using transpose(const lattice2D&) directly on a temporary lattice2D if many matrices of the same size need to be transposed.

Returns:
a reference to the actual (now transposed) lattice2D


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

Generated on Sun Sep 20 22:08:59 2009 for CVR-Lib by Doxygen 1.5.8