CVR-Lib last update 20 Sep 2009

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

Container class for generic matrices. More...

#include <cvrGenericMatrix.h>

Inheritance diagram for cvr::genericMatrix< T >:

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

Collaboration graph
[legend]

List of all members.

Protected Member Functions

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

virtual row_typeallocNewRows (const int n)
T * reserveNewMem (const int theSize) const
void reserveMem (const int rows, const int cols)
void releaseMem (T *&block) const
void releaseMem ()
void releaseRows (row_type *&theRows) const
void distributeMem (const int theRows, const int theCols, T *block, row_type *memRows) const

Protected Attributes

size_type theSize_
size_type last_
int totalSize_
bool ownData_
eConstantReference constReference_
T * theElements_
row_typerowAddressTable_

Package Functions

 genericMatrix ()
 genericMatrix (const int rows, const int cols)
 genericMatrix (const size_type &size)
 genericMatrix (const int rows, const int cols, const T &iniValue)
 genericMatrix (const size_type &size, const T &iniValue)
 genericMatrix (const int rows, const int cols, const T data[])
 genericMatrix (const size_type &dim, const T data[])
 genericMatrix (const int rows, const int cols, T data[], const eConstantReference constRef)
 genericMatrix (const size_type &theSize, T data[], const eConstantReference constRef)
 genericMatrix (const genericMatrix< T > &other)
 genericMatrix (const genericMatrix< T > &other, const int fromRow, const int fromCol, const int toRow=MaxIndex, const int toCol=MaxIndex)
 genericMatrix (const genericMatrix< T > &other, const size_type &from, const size_type &to)
 genericMatrix (const genericMatrix< T > &other, const genericVector< int > &rows)
virtual ~genericMatrix ()
bool ownsData () const
void restoreOwnership ()
void useExternData (const int rows, const int cols, T data[], const eConstantReference constRef=VariableReference)
void useExternData (const size_type &theSize, T data[], const eConstantReference constRef=VariableReference)
void attach (const int rows, const int cols, T *data)
void attach (const size_type &theSize, T *data)
void detach (genericMatrix< T > &receiver)
void detach (genericVector< T > &receiver)
void swap (genericMatrix< T > &other)
int rows () const
int columns () const
int lastRow () const
int lastColumn () const
const size_typesize () const
const size_typelastIndex () const
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
iterator inverseBegin ()
const_iterator inverseBegin () const
iterator inverseEnd ()
const_iterator inverseEnd () const
void resize (const int newRows, const int newCols, const T &iniValue, const eResizeType resizeType=CopyAndInit)
void resize (const size_type &newDim, const T &iniValue, const eResizeType resizeType=CopyAndInit)
void resize (const int newRows, const int newCols)
void resize (const size_type &newSize)
void allocate (const int newRows, const int newCols)
void allocate (const size_type &newSize)
void assign (const int newRows, const int newCols, const T &initValue)
void assign (const size_type &newSize, const T &initValue)
void clear ()
bool empty () const
void fill (const T &iniValue, const int fromRow=0, const int fromCol=0, const int toRow=MaxIndex, const int toCol=MaxIndex)
void fill (const T &iniValue, const size_type &from, const size_type &to=size_type(MaxIndex, MaxIndex))
void fill (const T &iniValue, const irectangle &window)
void fill (const T data[], const int fromRow=0, const int fromCol=0, const int toRow=MaxIndex, const int toCol=MaxIndex)
void fill (const T data[], const size_type &from, const size_type &to=size_type(MaxIndex, MaxIndex))
void fill (const T data[], const irectangle &window)
void fill (const genericMatrix< T > &mat, const int fromRow=0, const int fromCol=0, const int toRow=MaxIndex, const int toCol=MaxIndex, const int startAtRow=0, const int startAtCol=0)
void fill (const genericMatrix< T > &mat, const size_type &from, const size_type &to=size_type(MaxIndex, MaxIndex), const size_type &startAt=size_type(0, 0))
void fill (const genericMatrix< T > &mat, const irectangle &window, const size_type &start=size_type(0, 0))
T & at (const int row, const int col)
const T & at (const int row, const int col) const
T & at (const size_type &p)
const T & at (const size_type &p) const
T & elem (const int pos)
const T & elem (const int pos) const
row_typegetRow (const int row)
const row_typegetRow (const int row) const
row_typeoperator[] (const int row)
const row_typeoperator[] (const int row) const
void getRowCopy (const int row, row_type &theRow) const
row_type getRowCopy (const int row) const
void getColumnCopy (const int col, row_type &theCol) const
row_type getColumnCopy (const int col) const
void getDiagonal (row_type &diag) const
row_type getDiagonal () const
void setDiagonal (const row_type &diag)
void setRow (const int row, const row_type &theRow)
void setColumn (const int col, const row_type &theCol)
genericMatrix< T > & copy (const genericMatrix< T > &other)
genericMatrix< T > & copy (const genericMatrix< T > &other, const int fromRow, const int fromCol, const int toRow=MaxIndex, const int toCol=MaxIndex)
genericMatrix< T > & copy (const genericMatrix< T > &other, const size_type &from, const size_type &to)
genericMatrix< T > & copy (const genericMatrix< T > &other, const irectangle &window)
genericMatrix< T > & copyRows (const genericMatrix< T > &other, const genericVector< int > &idx)
genericMatrix< T > & copyColumns (const genericMatrix< T > &other, const genericVector< int > &idx)
template<typename U >
genericMatrix< T > & castFrom (const genericMatrix< U > &other)
genericMatrix< T > & castFrom (const genericMatrix< T > &other)
template<typename U >
genericMatrix< T > & castFrom (const genericMatrix< U > &other, const int fromRow, const int fromCol, const int toRow=MaxIndex, const int toCol=MaxIndex)
genericMatrix< T > & castFrom (const genericMatrix< T > &other, const int fromRow, const int fromCol, const int toRow=MaxIndex, const int toCol=MaxIndex)
virtual const std::string & name () const
virtual genericMatrix< T > * clone () const
virtual genericMatrix< T > * newInstance () const
bool equals (const genericMatrix< T > &other) const
bool operator== (const genericMatrix< T > &other) const
genericMatrix< T > & operator= (const genericMatrix< T > &other)
Apply Methods
Following methods are used to apply simple functions to each element of the vector.

genericMatrix< T > & apply (T(*function)(T))
genericMatrix< T > & apply (const genericMatrix< T > &other, T(*function)(T))
genericMatrix< T > & apply (T(*function)(const T &))
genericMatrix< T > & apply (const genericMatrix< T > &other, T(*function)(const T &))
genericMatrix< T > & apply (const genericMatrix< T > &other, T(*function)(const T &, const T &))
genericMatrix< T > & apply (const genericMatrix< T > &other, T(*function)(T, T))
genericMatrix< T > & apply (const genericMatrix< T > &a, const genericMatrix< T > &b, T(*function)(const T &, const T &))
genericMatrix< T > & apply (const genericMatrix< T > &a, const genericMatrix< T > &b, T(*function)(T, T))
Input and Output
virtual bool write (ioHandler &handler, const bool complete=true) const
virtual bool read (ioHandler &handler, const bool complete=true)

Internal types and classes

typedef
cvr::constReferenceException 
constReferenceException
typedef T value_type
typedef ipoint size_type
typedef genericVector< T > row_type
 __pad0__:debugIterator<genericMatrix<T>
false iterator
 __pad1__:debugIterator<genericMatrix<T>
true const_iterator


Detailed Description

template<class T>
class cvr::genericMatrix< T >

Container class for generic matrices.

The cvr::genericMatrix class is a container class implemented as a template.

The cvr::genericMatrix class allows the representation of n x m matrices of any type that does not use any form of dynamic memory allocation. The rows will be indexed between 0 and n-1, and the columns between 0 and m-1.

All types defined in cvrTypes.h use static members and can be contained by the cvr::genericVector and cvr::genericMatrix classes.

If you need to create a genericMatrix of floats with 20 rows and 15 columns, all elements initialized with an initial value of 4.27 just create it:

 cvr::genericMatrix<float> myMat(20,15,4.27f) // creates genericMatrix
                                              // with 300 elements
                                              // all initialized with 4.27f

To access the cvr::genericMatrix elements use the access operators. There are many possibilities. With at(const int row, const int col) it is possible to access an element directly. With getRow(const int row) you can get the row vector. You cannot for instance resize nor change the memory referenced in this vector (see cvr::vector::resize). For example:

 float accu = 0; // initialize accumulator
 cvr::genericMatrix<float> myMat(20,15,4.27f)
 cvr::vector<float> myVct;

 for (int j = 0; j < myMat.rows(); j++) {
   for (int i = 0; i < myMat.columns(); i++) {
   tmp += myMat.at(j,i); // access each element of the genericMatrix:
                         // j is the row and i the column
   }
 }

 myMat.getRowCopy(5,myVct); // copy the sixth row in myVct!
 myVct.resize(6);           // Valid, the vector has its own memory!
 myMat.getRow(5).resize(6)  // ERROR!! the vector is not resizable!

The image representation in the CVR-Lib is derived indirectly from the cvr::genericMatrix class. It is quite confusing to use first the y-coordinate and then the x-coordinate to access the image elements. To avoid confusion use the cvr::ipoint class to access the elements of the genericMatrix:

 cvr::channel8 aChannel(20,15); // creates an 8bit image
 cvr::channel8::value_type tmp; // tmp is of the element type of the
                                // channel8!
 cvr::ipoint p;


 for (p.y = 0; p.y < aChannel.rows(); p.y++) {
   for (p.x = 0; p.x < aChannel.columns(); p.x++) {
   tmp += aChannel.at(p); // access each element of the genericMatrix:
                          // equivalent to: tmp += aChannel.at(p.y,p.x)!
   }
 }

Matrices in the CVR-Lib use always a continuous block of memory, which allows efficient elementwise operations. The previous version of the library (LTI-Lib) provided a lined-mode of the matrices, which is now contained in its own class cvr::genericSubmatrix.

See also:
cvr::genericSubmatrix, cvr::matrix
The genericMatrix has following methods:

Member Typedef Documentation

Exception thrown when a constant reference is violated.

template<class T>
typedef genericVector<T> cvr::genericMatrix< T >::row_type

template<class T>
typedef ipoint cvr::genericMatrix< T >::size_type

template<class T>
typedef T cvr::genericMatrix< T >::value_type


Constructor & Destructor Documentation

template<class T>
cvr::genericMatrix< T >::genericMatrix (  )  [package]

Default constructor creates an empty genericMatrix.

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const int  rows,
const int  cols 
) [package]

Create a rows x cols genericMatrix with uninitialized elements.

Warning:
This is an interface change with the previous library. It has been done to be consistent with the more basic features of the C++ language. If you write for example int c; , the content of c is not defined, and in the same way, if you want a vector with initialized data, you have to specify explicitely the value with which the elements have to be initialized.
Parameters:
rows number of rows of the genericMatrix
cols number of columns of the genericMatrix

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const size_type size  )  [package]

Create a size.x x size.y genericMatrix with uninitialized elements.

Warning:
This is an interface change with the previous library. It has been done to be consistent with the more basic features of the C++ language. If you write for example int c; , the content of c is not defined, and in the same way, if you want a vector with initialized data, you have to specify explicitely the value with which the elements have to be initialized.
Parameters:
size size of the matrix (size.x columns and size.y rows)

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const int  rows,
const int  cols,
const T &  iniValue 
) [package]

Create a rows x cols genericMatrix and initializes all elements with iniValue.

Parameters:
rows number of rows of the genericMatrix
cols number of columns of the genericMatrix
iniValue all elements will be initialized with this value

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const size_type size,
const T &  iniValue 
) [package]

This constructor creates a size.y x size.x GenericMatrix and initializes all elements with iniValue.

Parameters:
size the size of the genericMatrix (size.x is the number of columns and size.y the number of rows)
iniValue all elements will be initialized with this value

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const int  rows,
const int  cols,
const T  data[] 
) [package]

Create a rows x cols genericMatrix and initialize all elements with the data pointed by data.

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

Parameters:
rows number of rows of the genericMatrix
cols number of columns of the genericMatrix
data pointer to the memory block with the data to be initialized with.

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const size_type dim,
const T  data[] 
) [package]

Create a dim.y x dim.x genericMatrix and initialize all elements with the data pointed by data.

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

Parameters:
dim matrix dimensions
data pointer to the memory block with the data to be initialized with.

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const int  rows,
const int  cols,
data[],
const eConstantReference  constRef 
) [package]

Create a rows x cols genericMatrix and use the given data as if it was given through the useExternData().

See also:
useExternData()
The first cols-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 third 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 third argument, the data is always copied.
Parameters:
rows number of rows of the genericMatrix
cols number of columns of the genericMatrix
data pointer to the memory block with the data to be initialized with.
constRef usually you want this to be ConstantReference

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const size_type theSize,
data[],
const eConstantReference  constRef 
) [package]

Create a rows x cols genericMatrix and use the given data as if it was given through the useExternData().

See also:
useExternData()
The first cols-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 third 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 third argument, the data is always copied.
Parameters:
theSize size of the matrix
data pointer to the memory block with the data to be initialized with.
constRef usually you want this to be ConstantReference

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const genericMatrix< T > &  other  )  [package]

Copy constructor.

Create this genericMatrix as a copy of another genericMatrix.

Parameters:
other the genericMatrix to be copied.

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const genericMatrix< T > &  other,
const int  fromRow,
const int  fromCol,
const int  toRow = MaxIndex,
const int  toCol = MaxIndex 
) [package]

Copy constructor.

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

Parameters:
other the genericMatrix to be copied.
fromRow initial row of the other genericMatrix to be copied
fromCol initial column of the other genericMatrix to be copied
toRow last row to be copied of the other genericMatrix
toCol last column to be copied of the other genericMatrix
Example:
 cvr::genericMatrix<int> m(4,6,0); // integer genericMatrix with 25
                                   // elements
 // ...
 // initialize GenericMatrix with:
 //        0  1  2  3  4  5
 //        2  1  5  4  0  3
 //        1  2  1  2  3  2
 //        3  3  2  1  2  3

 cvr::genericMatrix<int> sm(m,0,2,1,3)  // last line will lead to
 //                                 following contents in sm:
 //        1  2  3
 //        1  5  4
 //        2  1  2

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const genericMatrix< T > &  other,
const size_type from,
const size_type to 
) [package]

Copy constructor.

Create this genericMatrix as a copy of a submatrix of another genericMatrix.

Parameters:
other the genericMatrix to be copied.
from initial position in the other genericMatrix to be copied
to last position to be copied of the other genericMatrix
Example:
 cvr::genericMatrix<int> m(4,6,0); // integer genericMatrix with 25
                                   // elements
 // ...
 // initialize GenericMatrix with:
 //        0  1  2  3  4  5
 //        2  1  5  4  0  3
 //        1  2  1  2  3  2
 //        3  3  2  1  2  3

 cvr::genericMatrix<int> sm(m,0,2,1,3)  // last line will lead to
 //                                 following contents in sm:
 //        1  2  3
 //        1  5  4
 //        2  1  2

template<class T>
cvr::genericMatrix< T >::genericMatrix ( const genericMatrix< T > &  other,
const genericVector< int > &  rows 
) [package]

Copy constructor.

Create this genericMatrix as a copy of another genericMatrix 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 genericMatrix to be copied.
rows indices of the rows to be copied
Example:
 cvr::vector<int> rows(2);
 // initialize with
 // 1 3
 cvr::genericMatrix<int> m(4,6,0); // integer genericMatrix with 25
                                   // elements
 // ...
 // initialize GenericMatrix with:
 //        0  1  2  3  4  5
 //        2  1  5  4  0  3
 //        1  2  1  2  3  2
 //        3  3  2  1  2  3

 cvr::genericMatrix<int> sm(m,rows)     // last line will lead to
 //                                 following contents in sm:
 //        2  1  5  4  0  3
 //        3  3  2  1  2  3

template<class T>
virtual cvr::genericMatrix< T >::~genericMatrix (  )  [package, virtual]

Destructor.


Member Function Documentation

template<class T>
void cvr::genericMatrix< T >::allocate ( const size_type newSize  )  [inline, package]

Change the dimensions of the genericMatrix and leave ALL data uninitialized.

Parameters:
newSize new size of the matrix.
The old values will be discarded and the new data will be kept uninitialized. In principle this is an alias for resize(newSize.y, newSize.x, T(), AllocateOnly).

If the resize is possible (see useExternData()), this object will always own the data!

template<class T>
void cvr::genericMatrix< T >::allocate ( const int  newRows,
const int  newCols 
) [inline, package]

Change the dimensions of the genericMatrix and leave ALL data uninitialized.

Parameters:
newRows new number of rows
newCols new number of columns
The old values will be discarded and the new data will be kept uninitialized. In principle this is an alias for resize(newRows,newCols,T(),AllocateOnly).

If the resize is possible (see useExternData()), this object will always own the data!

template<class T>
virtual row_type* cvr::genericMatrix< T >::allocNewRows ( const int  n  )  [inline, protected, virtual]

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::apply ( const genericMatrix< T > &  a,
const genericMatrix< T > &  b,
T(*)(T, T)  function 
) [package]

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 genericMatrix
b the second genericMatrix
function a pointer to C-function with two parameters
Returns:
a reference to the actual genericMatrix

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::apply ( const genericMatrix< T > &  a,
const genericMatrix< T > &  b,
T(*)(const T &, const T &)  function 
) [package]

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 genericMatrix
b the second genericMatrix
function a pointer to C-function with two parameters
Returns:
a reference to the actual genericMatrix

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::apply ( const genericMatrix< T > &  other,
T(*)(T, T)  function 
) [package]

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

Note that both matrices must have the same size!

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

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::apply ( const genericMatrix< T > &  other,
T(*)(const T &, const T &)  function 
) [package]

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

Note that both matrices must have the same size!

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

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::apply ( const genericMatrix< T > &  other,
T(*)(const T &)  function 
) [package]

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

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

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::apply ( T(*)(const T &)  function  )  [package]

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

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

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::apply ( const genericMatrix< T > &  other,
T(*)(T)  function 
) [package]

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

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

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::apply ( T(*)(T)  function  )  [package]

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

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

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
void cvr::genericMatrix< T >::assign ( const size_type newSize,
const T &  initValue 
) [inline, package]

Change the dimensions of the genericMatrix and initialize ALL data with the given value.

The old values will be discarded and all data will be initialized with initValue. In principle this is an alias for resize(newSize.y, newSize.x, initValue, Init).

If the resize is possible (see useExternData()), this object will always own the data!

Parameters:
newSize new size of the matrix.
initValue value to be assigned to all matrix elements

template<class T>
void cvr::genericMatrix< T >::assign ( const int  newRows,
const int  newCols,
const T &  initValue 
) [inline, package]

Change the dimensions of the genericMatrix and initialize ALL data with the given value.

The old values will be discarded and all data will be initialized with initValue. In principle this is an alias for resize(newRows, newCols, initValue, Init).

If the resize is possible (see useExternData()), this object will always own the data!

Parameters:
newRows new number of rows
newCols new number of columns
initValue value to be assigned to all matrix elements

template<class T>
const T& cvr::genericMatrix< T >::at ( const size_type p  )  const [inline, package]

Const access operator of genericMatrix element as a point in a 2D-Map.

Parameters:
p position of the element (this is equivalent to at(p.y,p.x))
Returns:
a const reference to the vector element

template<class T>
T& cvr::genericMatrix< T >::at ( const size_type p  )  [inline, package]

Access operator of genericMatrix element as a point in a 2D-Map.

Parameters:
p position of the element (this is equivalent to at(p.y,p.x))
Returns:
a reference to the genericMatrix element

template<class T>
const T& cvr::genericMatrix< T >::at ( const int  row,
const int  col 
) const [inline, package]

Read-only access at the given row and column.

Parameters:
row the row of the element
col the column of the element
Returns:
a reference to the genericMatrix element

template<class T>
T& cvr::genericMatrix< T >::at ( const int  row,
const int  col 
) [inline, package]

Access element at the given row and column.

Parameters:
row the row of the element
col the column of the element
Returns:
a reference to the genericMatrix element

template<class T>
void cvr::genericMatrix< T >::attach ( const size_type theSize,
T *  data 
) [inline, package]

Attach extern data to the genericMatrix.

This member allows the use of this object as an access-functor for the 'data'. An access to the element at (r,c) is equivalent to data[r*columns() + c]. If rows and cols are invalid dimensions, the behaviour will be unpredictible.

The memory will be administrated by this genericMatrix object, and may be deleted if required (genericMatrix deleted or resized!). The user should not try to manipulate the memory allocation of the data after the attachment! See also useExternData().

Parameters:
theSize x number of columns and y number of rows
data a pointer to the memory block to be used
Example:
 cvr::genericMatrix<int> myMat;
 int block1[25];
 int* block2;
 block2 = new int[25];
 ipoint p(5,5);
 myMat.useExternData(p,block1); // ok
 myMat.attach(p,block1); // wrong!!! genericMatrix will try
                         // to manipulate stack memory:
                         // DO NOT DO THIS!!!!!
 myMat.attach(p,block2); // ok!  but do not try to delete the memory
                         //      block2!!

template<class T>
void cvr::genericMatrix< T >::attach ( const int  rows,
const int  cols,
T *  data 
) [package]

Attach extern data to the genericMatrix.

This member allows the use of this object as an access-functor for the 'data'. An access to the element at (r,c) is equivalent to data[r*columns() + c]. If rows and cols are invalid dimensions, the behaviour will be unpredictible.

The memory will be administrated by this genericMatrix object, and may be deleted if required (genericMatrix deleted or resized!). The user should not try to manipulate the memory allocation of the data after the attachment! See also useExternData().

Parameters:
rows number of rows
cols number of columns
data a pointer to the memory block to be used
Example:
 cvr::genericMatrix<int> myMat;
 int block1[25];
 int* block2;
 block2 = new int[25];

 myMat.useExternData(5,5,block1); // ok
 myMat.attach(5,5,block1); // wrong!!! genericMatrix will try
                           // to manipulate stack memory:
                           // DO NOT DO THIS!!!!!
 myMat.attach(5,5,block2); // ok!  but do not try to delete the memory
                           //      block2!!

template<class T>
const_iterator cvr::genericMatrix< T >::begin (  )  const [inline, package]

Return first element of the genericMatrix as a const_iterator.

Note that you can not change the values of the genericMatrix elements when you use a const_iterator. See also begin() for an example

template<class T>
iterator cvr::genericMatrix< T >::begin (  )  [inline, package]

Return iterator to the begin of the genericMatrix.

The use of the interators is similar to the iterators of the Standard Template Library (STL). If you need to iterate on all elements of the genericMatrix, you can use following code:

 int tmp,accu;                  // a temporal variable
 cvr::genericMatrix<int> myMat(10,8,1); // a vector with 10 elements
 cvr::genericMatrix<int>::iterator it;  // an iterator

 for (it=myMat.begin();it!=myMat.end();it++) {
   tmp = *it;                   // tmp has value of element pointed
                                // by the iterator.
   accu += tmp;
   (*it) = accu;                // change the value in the genericMatrix.
 }
Please note that if you define it as a const_iterator, you can not do something like *it=accu.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::castFrom ( const genericMatrix< T > &  other,
const int  fromRow,
const int  fromCol,
const int  toRow = MaxIndex,
const int  toCol = MaxIndex 
) [package]

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

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

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

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

Copy a submatrix of the other genericMatrix by casting each of its elements.

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

Reimplemented in cvr::matrix< T >, cvr::matrix< value_type >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::castFrom ( const genericMatrix< T > &  other  )  [package]

This is just an alias for copy(const genericMatrix<T>&) to facilitate generic programming.

Parameters:
other The genericMatrix to be copied.

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
template<typename U >
genericMatrix<T>& cvr::genericMatrix< T >::castFrom ( const genericMatrix< U > &  other  )  [inline, package]

Copy the other genericMatrix by casting each of its elements.

Parameters:
other The genericMatrix to be casted
Example:
   cvr::genericMatrix<int> matA(10,10,1);// a genericMatrix of integers
   cvr::genericMatrix<double> matB;      // a genericMatrix of doubles

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

Reimplemented in cvr::matrix< T >, cvr::matrix< value_type >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
void cvr::genericMatrix< T >::clear (  )  [package]

Clears the genericMatrix (at the end this will be an empty genericMatrix).

template<class T>
virtual genericMatrix<T>* cvr::genericMatrix< T >::clone (  )  const [package, virtual]

template<class T>
int cvr::genericMatrix< T >::columns (  )  const [inline, package]

Number of columns of the genericMatrix.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::copy ( const genericMatrix< T > &  other,
const irectangle window 
) [inline, package]

Assigment operator.

Copy the contents of a submatrix of other into this object. The content of the current object is removed and at the end it will contain only the copy of the submatrix.

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

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::copy ( const genericMatrix< T > &  other,
const size_type from,
const size_type to 
) [inline, package]

Assigment operator.

Copy the contents of a submatrix of other into this object. The content of the current object is removed and at the end it will contain only the submatrix.

Parameters:
other the other genericMatrix to be copied
from initial submatrix indices (x,y) to be copied
to last submatrix indices (x,y) to be copied (inclusive)

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::copy ( const genericMatrix< T > &  other,
const int  fromRow,
const int  fromCol,
const int  toRow = MaxIndex,
const int  toCol = MaxIndex 
) [package]

Assigment operator.

Copy the contents of a submatrix of other into this object. The content of the current object is removed and at the end it will contain a copy the submatrix only.

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

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::copy ( const genericMatrix< T > &  other  )  [package]

Assigment operator.

Copy the contents of other in this object.

Parameters:
other the other genericMatrix to be copied

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::copyColumns ( const genericMatrix< T > &  other,
const genericVector< int > &  idx 
) [package]

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 genericMatrix to be copied
idx indices of the rows to be copied.

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::copyRows ( const genericMatrix< T > &  other,
const genericVector< int > &  idx 
) [package]

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 genericMatrix to be copied
idx indices of the rows to be copied.

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
void cvr::genericMatrix< T >::detach ( genericVector< T > &  receiver  )  [package]

Free the data of this object and hand it over to the "receiver".

The value of ownsData is also transfered to the receiver. (see Note).

This function makes a "memory block transfusion" to a vector by concatenating the rows of the genericMatrix. It is a very efficient way to move the data of this genericMatrix into a vector, if you don't need the source data anymore!

Note: If the attach() or useExternData() methods of this genericMatrix have been called before detachment, the same rules for memory management apply now for the receiver.

At the end of the detachment, this genericMatrix will be empty.

Parameters:
receiver the genericMatrix which will receive the memory block. All data of that genericMatrix will be first deleted!

template<class T>
void cvr::genericMatrix< T >::detach ( genericMatrix< T > &  receiver  )  [package]

Free the data of this object and hand it over to the "receiver".

The value of ownsData is also transfered to the receiver. (see Note).

This function makes a "memory block transfusion" to another genericMatrix. It is a very efficient way to make a copy of this genericMatrix, if you don't need the source data anymore!

If the current matrix does not own its data, neither will the receiver matrix, which will also be just a wrapper of the same data.

If the current matrix is lined, then the other matrix will end as an exact copy if this one, and this one will be emptied after the detachment. In other words, it works similar like a swap() followed by clear(). In extremely time critical situations you may want to use swap() as it does not need to deallocate any memory of the receiver and is therefore a little bit faster.

Please take special care to the memory management issues involved if the current object does not own its data, as its control will still be yours.

At the end of the detachment, this genericMatrix will be empty.

Parameters:
receiver the genericMatrix which will receive the memory block. All data of that genericMatrix will be first deleted!

template<class T>
void cvr::genericMatrix< T >::distributeMem ( const int  theRows,
const int  theCols,
T *  block,
row_type memRows 
) const [protected]

Take the memory block and distribute it on the allocated vectors pointed by theRows.

template<class T>
const T& cvr::genericMatrix< T >::elem ( const int  pos  )  const [inline, package]

Access element at the given position.

With this operator the genericMatrix can be accessed as a vector, where the rows of the genericMatrix are concatenated. The access to the genericMatrix with at(row,col) is equivalent to elem(row*columns()+col).

Parameters:
pos the index of the element of the genericMatrix
Returns:
a reference to the genericMatrix element

template<class T>
T& cvr::genericMatrix< T >::elem ( const int  pos  )  [inline, package]

Access element at the given position.

With this operator the genericMatrix can be accessed as a vector, where the rows of the genericMatrix are concatenated. The access to the genericMatrix with at(row,col) is equivalent to elem(row*columns()+col).

Parameters:
pos the index of the element of the genericMatrix
Returns:
a reference to the genericMatrix element

template<class T>
bool cvr::genericMatrix< T >::empty (  )  const [inline, package]

Returns true if the genericMatrix is empty.

template<class T>
const_iterator cvr::genericMatrix< T >::end (  )  const [inline, package]

returns iterator to the end of the genericMatrix

template<class T>
iterator cvr::genericMatrix< T >::end (  )  [inline, package]

returns iterator to the end of the genericMatrix

template<class T>
bool cvr::genericMatrix< T >::equals ( const genericMatrix< T > &  other  )  const [package]

Compare this genericMatrix with other.

Parameters:
other the other genericMatrix to be compared with
Returns:
true if both matrices have the same elements and same size

template<class T>
void cvr::genericMatrix< T >::fill ( const genericMatrix< T > &  mat,
const irectangle window,
const size_type start = size_type(0, 0) 
) [inline, package]

Fills the region of this genericMatrix specified by window with the contents of the genericMatrix mat starting at start.

If these values are out of bounds, they will be (internally) adjusted to correct values.

Parameters:
mat pointer to the data to be copied
window the window to be filled
start the start position of the region to be copied of the genericMatrix mat

template<class T>
void cvr::genericMatrix< T >::fill ( const genericMatrix< T > &  mat,
const size_type from,
const size_type to = size_type(MaxIndexMaxIndex),
const size_type startAt = size_type(0, 0) 
) [inline, package]

Fills this genericMatrix between the "from's" and "to's" with the contents of the genericMatrix mat starting at startAtRow and startAtCol.

Parameters:
mat the genericMatrix with the data to be copied
from first position of the submatrix to be filled
to last position of the submatrix to be filled
startAt starting position of mat where the data is located.

template<class T>
void cvr::genericMatrix< T >::fill ( const genericMatrix< T > &  mat,
const int  fromRow = 0,
const int  fromCol = 0,
const int  toRow = MaxIndex,
const int  toCol = MaxIndex,
const int  startAtRow = 0,
const int  startAtCol = 0 
) [package]

Fills this genericMatrix between the "from's" and "to's" with the contents of the genericMatrix mat starting at startAtRow and startAtCol.

Parameters:
mat the genericMatrix with the data to be copied
fromRow first row of the submatrix to be filled
fromCol first column of the submatrix to be filled
toRow last row of the submatrix to be filled
toCol last column of the submatrix to be filled
startAtRow starting row of mat where the data is located.
startAtCol starting column of mat where the data is located.

template<class T>
void cvr::genericMatrix< T >::fill ( const T  data[],
const irectangle window 
) [inline, package]

Fills genericMatrix elements with iniValue.

The fill "area" is limited by window.

If these values are out of bounds, they will be (internally) adjusted to correct values.

Parameters:
data pointer to the data to be copied
window the window to be filled

template<class T>
void cvr::genericMatrix< T >::fill ( const T  data[],
const size_type from,
const size_type to = size_type(MaxIndexMaxIndex) 
) [inline, package]

Fills genericMatrix elements with the data pointed by data.

The fill "area" is limited by fromCol,toCol, fromRow and toRow. If these values are out of bounds, they will be (internally) adjusted to correct values.

Parameters:
data pointer to the data to be copied.
from first position of the submatrix to be filled
to last position of the submatrix to be filled

template<class T>
void cvr::genericMatrix< T >::fill ( const T  data[],
const int  fromRow = 0,
const int  fromCol = 0,
const int  toRow = MaxIndex,
const int  toCol = MaxIndex 
) [package]

Fills genericMatrix elements with the data pointed by data.

The fill "area" is limited by fromCol,toCol, fromRow and toRow. If these values are out of bounds, they will be (internally) adjusted to correct values.

Parameters:
data pointer to the data to be copied.
fromRow first row of the submatrix to be filled
fromCol first column of the submatrix to be filled
toRow last row of the submatrix to be filled
toCol last column of the submatrix to be filled

template<class T>
void cvr::genericMatrix< T >::fill ( const T &  iniValue,
const irectangle window 
) [inline, package]

Fills genericMatrix elements with iniValue.

The fill "area" is limited by window. If these values are out of bounds, they will be (internally) adjusted to correct values.

Parameters:
iniValue the elements will be initialized with this value
window the window to be filled

template<class T>
void cvr::genericMatrix< T >::fill ( const T &  iniValue,
const size_type from,
const size_type to = size_type(MaxIndexMaxIndex) 
) [inline, package]

Fills genericMatrix elements with iniValue.

The fill "area" is limited by from and to points If these values are out of bounds, they will be (internally) adjusted to correct values.

Parameters:
iniValue the elements will be initialized with this value
from first position of the submatrix to be filled
to last row of the submatrix to be filled

template<class T>
void cvr::genericMatrix< T >::fill ( const T &  iniValue,
const int  fromRow = 0,
const int  fromCol = 0,
const int  toRow = MaxIndex,
const int  toCol = MaxIndex 
) [package]

Fills genericMatrix elements with iniValue.

The fill "area" is limited by fromCol,toCol, fromRow and toRow. If these values are out of bounds, they will be (internally) adjusted to correct values.

Parameters:
iniValue the elements will be initialized with this value
fromRow first row of the submatrix to be filled
fromCol first column of the submatrix to be filled
toRow last row of the submatrix to be filled
toCol last column of the submatrix to be filled

template<class T>
row_type cvr::genericMatrix< T >::getColumnCopy ( const int  col  )  const [inline, package]

Return genericMatrix-column as a vector.

This method copies the data of the genericMatrix, 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 genericMatrix

Reimplemented in cvr::matrix< T >, cvr::matrix< value_type >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
void cvr::genericMatrix< T >::getColumnCopy ( const int  col,
row_type theCol 
) const [package]

Return genericMatrix-column as a vector.

This method copies the data of the genericMatrix, 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 genericMatrix should be copied.

template<class T>
row_type cvr::genericMatrix< T >::getDiagonal (  )  const [inline, package]

Return the diagonal elements of the genericMatrix as vector.

This method copies the diagonal elements of the genericMatrix into the vector. If the genericMatrix is non-symmetrical, the vector will be of dimension min(rows(),columns()).

Returns:
a vector with the diagonal elements of the genericMatrix.

Reimplemented in cvr::matrix< T >, cvr::matrix< value_type >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
void cvr::genericMatrix< T >::getDiagonal ( row_type diag  )  const [package]

Return the diagonal elements of the genericMatrix as vector.

This method copies the diagonal elements of the genericMatrix into the vector. If the genericMatrix is non-symmetrical, the vector will be of dimension min(rows(),columns()).

Parameters:
diag a vector, where the diagonal of the genericMatrix should be copied.

template<class T>
const row_type& cvr::genericMatrix< T >::getRow ( const int  row  )  const [inline, package]

Return genericMatrix-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 in cvr::matrix< T >, cvr::matrix< value_type >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
row_type& cvr::genericMatrix< T >::getRow ( const int  row  )  [inline, package]

Return genericMatrix-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 in cvr::matrix< T >, cvr::matrix< value_type >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
row_type cvr::genericMatrix< T >::getRowCopy ( const int  row  )  const [inline, package]

Return genericMatrix-row as a vector.

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

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

Reimplemented in cvr::matrix< T >, cvr::matrix< value_type >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
void cvr::genericMatrix< T >::getRowCopy ( const int  row,
row_type theRow 
) const [inline, package]

Copy a row vector in the given parameter.

This method copies the data of a given row of the genericMatrix 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<class T>
const_iterator cvr::genericMatrix< T >::inverseBegin (  )  const [inline, package]

This method returns an iterator that points to the last valid element of the genericMatrix.

See inverseBegin() for more details.

template<class T>
iterator cvr::genericMatrix< T >::inverseBegin (  )  [inline, package]

This method returns an iterator that points to the last valid element of the genericMatrix.

It is used for inverse order iteration through the genericMatrix using normal iterators (as opposed to reverse iterators). This has the advantage that iterators going from front to end and in the inverse direction are the same and can thus be compared, copied etc. Further the implementation of reverse_iterators is not as fast as that of iterators and thus not desired in the CVR-Lib.

See cvr::genericVector<T>::inverseBegin() for an example.

template<class T>
const_iterator cvr::genericMatrix< T >::inverseEnd (  )  const [inline, package]

This method returns an iterator that points to the element before the first valid element of the genericMatrix.

template<class T>
iterator cvr::genericMatrix< T >::inverseEnd (  )  [inline, package]

This method returns an iterator that points to the element before the first valid element of the genericMatrix.

It is used to mark the end for inverse order iteration through the genericMatrix using normal iterators (as opposed to reverse iterators). This has the advantage that iterators going from front to end and in the inverse direction are the same and can thus be compared, copied etc.

template<class T>
int cvr::genericMatrix< T >::lastColumn (  )  const [inline, package]

Index of the last columns (columns()-1).

template<class T>
const size_type& cvr::genericMatrix< T >::lastIndex (  )  const [inline, package]

Returns a read-only reference to the last index of the matrix.

Returns:
cvr::ipoint with the number of columns in its x coordinate and the number of rows in its y coordinate.

template<class T>
int cvr::genericMatrix< T >::lastRow (  )  const [inline, package]

Index of the last row (rows()-1).

template<class T>
virtual const std::string& cvr::genericMatrix< T >::name (  )  const [package, virtual]

template<class T>
virtual genericMatrix<T>* cvr::genericMatrix< T >::newInstance (  )  const [package, virtual]

template<class T>
genericMatrix<T>& cvr::genericMatrix< T >::operator= ( const genericMatrix< T > &  other  )  [inline, package]

Assigment operator (alias for copy(other)).

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

Reimplemented in cvr::matrix< T >, cvr::matrix< int32 >, cvr::matrix< float >, cvr::matrix< fcomplex >, cvr::matrix< rgbaPixel >, and cvr::matrix< ubyte >.

template<class T>
bool cvr::genericMatrix< T >::operator== ( const genericMatrix< T > &  other  )  const [inline, package]

Compare the contents of each element of this genericMatrix with the other one.

It assumes the type T can be compared using the operator==.

Parameters:
other the other genericMatrix to be compared with
Returns:
true if both matrices have the same elements and same size

template<class T>
const row_type& cvr::genericMatrix< T >::operator[] ( const int  row  )  const [inline, package]

template<class T>
row_type& cvr::genericMatrix< T >::operator[] ( const int  row  )  [inline, package]

template<class T>
bool cvr::genericMatrix< T >::ownsData (  )  const [inline, package]

Owns this object the data? returns false if this genericMatrix contains a reference to extern data.

template<class T>
virtual bool cvr::genericMatrix< T >::read ( ioHandler handler,
const bool  complete = true 
) [package, virtual]

Read the object from the given ioHandler.

Reimplemented from cvr::ioObject.

template<class T>
void cvr::genericMatrix< T >::releaseMem (  )  [protected]

Release the internal memory blocks, including theElements_ and the row array.

template<class T>
void cvr::genericMatrix< T >::releaseMem ( T *&  block  )  const [protected]

Release the given block of memory.

template<class T>
void cvr::genericMatrix< T >::releaseRows ( row_type *&  theRows  )  const [inline, protected]

Allocate n number of rows or the appropriate type.

template<class T>
void cvr::genericMatrix< T >::reserveMem ( const int  rows,
const int  cols 
) [protected]

Reserve memory.

This method allocates memory for the elements, for the rows and distributes the memory into the blocks

template<class T>
T* cvr::genericMatrix< T >::reserveNewMem ( const int  theSize  )  const [inline, protected]

Reserve just a memory block of the given size;.

template<class T>
void cvr::genericMatrix< T >::resize ( const size_type newSize  )  [inline, package]

Change the dimensions of the genericMatrix.

Parameters:
newSize new size of the matrix.
The old values will be copied, but the new data will be kept uninitialized. In principle this is an alias for resize(newRows,newCols,T(),Copy).

If the resize is possible (see useExternData()), this object will always own the data!

template<class T>
void cvr::genericMatrix< T >::resize ( const int  newRows,
const int  newCols 
) [inline, package]

Change the dimensions of the genericMatrix.

Parameters:
newRows new number of rows
newCols new number of columns
The old values will be copied, but the new data will be kept uninitialized. In principle this is an alias for resize(newRows,newCols,T(),Copy).

If the resize is possible (see useExternData()), this object will always own the data!

template<class T>
void cvr::genericMatrix< T >::resize ( const size_type newDim,
const T &  iniValue,
const eResizeType  resizeType = CopyAndInit 
) [inline, package]

Change the dimensions of the genericMatrix.

Parameters:
newDim new dimensions of the genericMatrix
iniValue the initialization value.
resizeType specifies what should happen with the data of the resized matrix.
If the resize is possible (see useExternData()), this object will always own the data!

This is equivalent to call resize(newDim.y,newDim.x,iniValue,resizeType)

See also:
eResizeType

template<class T>
void cvr::genericMatrix< T >::resize ( const int  newRows,
const int  newCols,
const T &  iniValue,
const eResizeType  resizeType = CopyAndInit 
) [package]

Change the dimensions of the genericMatrix.

Parameters:
newRows new number of rows
newCols new number of columns
iniValue the initialization value.
resizeType specifies what should happen with the data of the resized matrix.
For example:
   cvr::genericMatrix<int> myMat;  // creates empty genericMatrix
   myMat.resize(5,5,0);     // genericMatrix with 5x5 elements
                            // initialized with 0
   myMat.resize(10,7,2);    // genericMatrix has now 10x7 elements: the
                            // submatrix 5x5 at (0,0) has still 0s
                            // and the rest have a 2
   myMat.resize(20,10,0,cvr::AllocateOnly); // now the genericMatrix has
                                            // 20 elements but their
                                            // values are unknown.
   myMat.resize(5,5,1,Copy); // the genericMatrix has now 5x5
                             // elements all initialized with 1

If the resize is possible (see useExternData()), this object will always owns the data!

See also:
eResizeType

template<class T>
void cvr::genericMatrix< T >::restoreOwnership (  )  [package]

If this object does not own its data, this member will create a new memory buffer with the same data and will make this genericMatrix as its owner.

If this genericMatrix already owns its data nothing happens.

template<class T>
int cvr::genericMatrix< T >::rows (  )  const [inline, package]

Number of rows of the genericMatrix.

template<class T>
void cvr::genericMatrix< T >::setColumn ( const int  col,
const row_type theCol 
) [package]

Copy the data of a vector in a given column.

Parameters:
col the column that receives the data.
theCol the vector with the data to be copied

template<class T>
void cvr::genericMatrix< T >::setDiagonal ( const row_type diag  )  [package]

Sets the diagonal of the genericMatrix to the values given in the genericVector diag.

Let r be the number of rows and c be the number of columns of the matrix. Then minRC is min(r,c). Also let d be the size of diag. Only min(minRC,d) values are copied from diag. If d is smaller than minRC the remaining values on the diagonal are left untouched. The copying always starts at (0,0) of the matrix.

Parameters:
diag values to be copied into the diagonal of the matrix

template<class T>
void cvr::genericMatrix< T >::setRow ( const int  row,
const row_type theRow 
) [inline, package]

Copy the data of a vector in a given row.

Parameters:
row the row that receives the data.
theRow the vector with the data to be copied

template<class T>
const size_type& cvr::genericMatrix< T >::size (  )  const [inline, package]

Returns the size of the genericMatrix in a cvr::ipoint structure.

Returns:
cvr::ipoint with the number of columns in its x coordinate and the number of rows in its y coordinate.

template<class T>
void cvr::genericMatrix< T >::swap ( genericMatrix< T > &  other  )  [package]

Exchange (in a fast way) the data between this and the other genericMatrix.

Similar to detach(), this method will exchange the complete memory blocks, avoiding an element-wise copy.

Parameters:
other the genericMatrix with which the data will be exchanged.

template<class T>
void cvr::genericMatrix< T >::useExternData ( const size_type theSize,
data[],
const eConstantReference  constRef = VariableReference 
) [inline, package]

Reference to extern data.

This member allows the use of this object as an access-functor for the 'data'. An access to the element at (r,c) is equivalent to data[r*columns() + c]. The user must take care for memory allocation and deallocation: this object will never delete the data!. If rows and cols are invalid dimensions, the behaviour will be unpredictible.

Parameters:
theSize size of the matrix
data a pointer to the memory block to be used
constRef usually you want this to be ConstantReference
For an example see attach()

template<class T>
void cvr::genericMatrix< T >::useExternData ( const int  rows,
const int  cols,
data[],
const eConstantReference  constRef = VariableReference 
) [package]

Reference to extern data.

This member allows the use of this object as an access-functor for the 'data'. An access to the element at (r,c) is equivalent to data[r*columns() + c].

The user must take care for memory allocation and deallocation: this object will never delete the given data!.

If rows and cols are invalid dimensions, the behaviour will be unpredictible.

In case the provided data is the same than the one being used by this matrix, and additionally the provided rows and columns coincide with the dimensions in use, nothing will be changed, not even the ownership of the data.

Parameters:
rows number of rows
cols number of columns
data a pointer to the memory block to be used
constRef usually you want this to be ConstantReference
For an example see attach()

template<class T>
virtual bool cvr::genericMatrix< T >::write ( ioHandler handler,
const bool  complete = true 
) const [package, virtual]

Write the object in the given ioHandler.

Reimplemented from cvr::ioObject.


Member Data Documentation

template<class T>
cvr::genericMatrix< T >::__pad0__ [package]

Iterator type (allows read and write operations).

The use of the iterator classes is similar to the iterators of the STL (Standard Template Library). See cvr::genericMatrix::begin() for an example .

For the debugging version of the iterators, boundary check will be done! This explains the low speed of the iterators of the debug version. In the release version, no boundary check will be done, and the iterators are sometimes a factor 10 faster than the debug iterators.

The use of the access operator at() is faster than the iterators in the debug version only. If you need to iterate on a genericMatrix use iterators instead (in the release version iterators are approximately a factor 3 faster than "at()").

Warning:
Try to use the prefix incremental operator (i.e. ++it) over the postfix operator (i.e. it++) to allow efficient code also in debug-modus!

template<class T>
cvr::genericMatrix< T >::__pad1__ [package]

Constant iterator type (allows read-only operations).

The use of the iterator classes is similar to the iterators of the STL (Standard Template Library). See cvr::genericMatrix::begin() for an example.

For the debugging version of the iterators, boundary check will be done! This explains the low speed of the iterators of the debug version. In the release version, no boundary check will be done, and the iterators are sometimes a factor 10 faster than the debug iterators.

The use of the access operator at() is faster than the iterators in the debug version only. If you need to iterate on a genericMatrix use iterators instead (in the release version iterators are approximately a factor 3 faster than "at()").

Warning:
Try to use the prefix incremental operator (i.e. ++it) instead of the postfix operator (i.e. it++) to allow efficient code also in debug-modus!

template<class T>
true cvr::genericMatrix< T >::const_iterator [package]

template<class T>
eConstantReference cvr::genericMatrix< T >::constReference_ [protected]

If constReference=true, is not possible to resize or change the reference of this genericVector.

Very important for an efficient matrix class!! (see useExternData())

template<class T>
false cvr::genericMatrix< T >::iterator [package]

template<class T>
size_type cvr::genericMatrix< T >::last_ [protected]

Index of the last row, i.e.

last_.x=theSize.x-1, and last_.y=theSize.y-1

template<class T>
bool cvr::genericMatrix< T >::ownData_ [protected]

Indicates if theElements points to own data or to external data.

template<class T>
row_type* cvr::genericMatrix< T >::rowAddressTable_ [protected]

Table of pointers to the rows.

template<class T>
T* cvr::genericMatrix< T >::theElements_ [protected]

Pointer to the elements of the genericMatrix.

template<class T>
size_type cvr::genericMatrix< T >::theSize_ [protected]

Size of the matrix as point.

template<class T>
int cvr::genericMatrix< T >::totalSize_ [protected]

Size of theElements_ memory block, i.e.

theSize_.x*theSize_.y;


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

Generated on Sun Sep 20 22:09:07 2009 for CVR-Lib by Doxygen 1.5.8