Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

Matrix Class Template Reference
[Datastructures]

#include <OpenMS/DATASTRUCTURES/Matrix.h>

Inheritance diagram for Matrix:

List of all members.


Detailed Description

template<typename Value>
class OpenMS::Matrix< Value >

A two-dimensional matrix. Similar to std::vector, but uses a binary operator(,) for element access.

Think of it as a random access container. You can also generate gray scale images. This is not designed to be used for linear algebra.

The following member functions of the base class std::vector<ValueType> can also be used:

(It seems that Doxygen does not parse pure access declarations, so we list them here.)

Public Types

STL compliance type definitions
typedef Base container_type
typedef Base::difference_type difference_type
typedef Base::size_type size_type
typedef Base::const_iterator const_iterator
typedef
Base::const_reverse_iterator 
const_reverse_iterator
typedef Base::iterator iterator
typedef Base::reverse_iterator reverse_iterator
typedef Base::const_reference const_reference
typedef Base::pointer pointer
typedef Base::reference reference
typedef Base::value_type value_type
typedef Base::allocator_type allocator_type
OpenMS compliance type definitions
typedef Base ContainerType
typedef difference_type DifferenceType
typedef size_type SizeType
typedef const_iterator ConstIterator
typedef const_reverse_iterator ConstReverseIterator
typedef iterator Iterator
typedef reverse_iterator ReverseIterator
typedef const_reference ConstReference
typedef pointer Pointer
typedef reference Reference
typedef value_type ValueType
typedef allocator_type AllocatorType

Public Member Functions

void clear ()
void resize (size_type i, size_type j, value_type value=value_type())
void resize (std::pair< UInt, UInt > const &size_pair, value_type value=value_type())
SizeType rows () const throw ()
 Number of rows.
SizeType cols () const throw ()
 Number of columns.
std::pair< UInt, UIntsizePair () const
SizeType const index (SizeType row, SizeType col) const
 Calculate the index into the underlying vector from row and column. Note that Matrix uses the (row,column) lexicographic ordering for indexing.
std::pair< UInt, UInt > const indexPair (UInt index) const
 Calculate the row and column from an index into the underlying vector. Note that Matrix uses the (row,column) lexicographic ordering for indexing.
SizeType colIndex (SizeType index) const
 Calculate the column from an index into the underlying vector. Note that Matrix uses the (row,column) lexicographic ordering for indexing.
SizeType rowIndex (SizeType index) const
 Calculate the row from an index into the underlying vector. Note that Matrix uses the (row,column) lexicographic ordering for indexing.
bool operator== (Matrix const &rhs) const throw (Exception::Precondition)
 Equality comparator.
bool operator< (Matrix const &rhs) const throw (Exception::Precondition)
 Less-than comparator. Comparison is done lexicographically: first by row, then by column.
Constructors, assignment, and destructor
 Matrix ()
 Matrix (SizeType rows, SizeType cols, ValueType value=ValueType())
 Matrix (const Matrix &source)
Matrixoperator= (const Matrix &rhs)
 ~Matrix ()
Accessors
const_reference operator() (size_type const i, size_type const j) const
reference operator() (size_type const i, size_type const j)
const_reference getValue (size_type const i, size_type const j) const
reference getValue (size_type const i, size_type const j)
void setValue (size_type const i, size_type const j, value_type value)

Protected Types

typedef std::vector< Value > Base

Protected Attributes

Data members
SizeType rows_
 Number of rows (height of a column).
SizeType cols_
 Number of columns (width of a row).

Related Functions

(Note that these are not member functions.)

template<typename Value>
std::ostream & operator<< (std::ostream &os, const Matrix< Value > &matrix)
 Print the contents to a stream.

Member Typedef Documentation

typedef std::vector< Value > Base [protected]

typedef Base container_type

typedef Base::difference_type difference_type

typedef Base::size_type size_type

typedef Base::const_iterator const_iterator

typedef Base::const_reverse_iterator const_reverse_iterator

typedef Base::iterator iterator

typedef Base::reverse_iterator reverse_iterator

typedef Base::const_reference const_reference

typedef Base::pointer pointer

typedef Base::reference reference

typedef Base::value_type value_type

typedef Base::allocator_type allocator_type

typedef Base ContainerType

typedef difference_type DifferenceType

typedef size_type SizeType

typedef const_iterator ConstIterator

typedef const_reverse_iterator ConstReverseIterator

typedef iterator Iterator

typedef reverse_iterator ReverseIterator

typedef const_reference ConstReference

typedef pointer Pointer

typedef reference Reference

typedef value_type ValueType

typedef allocator_type AllocatorType


Constructor & Destructor Documentation

Matrix (  )  [inline]

Matrix ( SizeType  rows,
SizeType  cols,
ValueType  value = ValueType() 
) [inline]

Matrix ( const Matrix< Value > &  source  )  [inline]

~Matrix (  )  [inline]


Member Function Documentation

Matrix& operator= ( const Matrix< Value > &  rhs  )  [inline]

const_reference operator() ( size_type const   i,
size_type const   j 
) const [inline]

reference operator() ( size_type const   i,
size_type const   j 
) [inline]

const_reference getValue ( size_type const   i,
size_type const   j 
) const [inline]

reference getValue ( size_type const   i,
size_type const   j 
) [inline]

void setValue ( size_type const   i,
size_type const   j,
value_type  value 
) [inline]

void clear (  )  [inline]

void resize ( size_type  i,
size_type  j,
value_type  value = value_type() 
) [inline]

void resize ( std::pair< UInt, UInt > const &  size_pair,
value_type  value = value_type() 
) [inline]

SizeType rows (  )  const throw () [inline]

Number of rows.

SizeType cols (  )  const throw () [inline]

Number of columns.

std::pair<UInt,UInt> sizePair (  )  const [inline]

SizeType const index ( SizeType  row,
SizeType  col 
) const [inline]

Calculate the index into the underlying vector from row and column. Note that Matrix uses the (row,column) lexicographic ordering for indexing.

std::pair<UInt,UInt> const indexPair ( UInt  index  )  const [inline]

Calculate the row and column from an index into the underlying vector. Note that Matrix uses the (row,column) lexicographic ordering for indexing.

SizeType colIndex ( SizeType  index  )  const [inline]

Calculate the column from an index into the underlying vector. Note that Matrix uses the (row,column) lexicographic ordering for indexing.

SizeType rowIndex ( SizeType  index  )  const [inline]

Calculate the row from an index into the underlying vector. Note that Matrix uses the (row,column) lexicographic ordering for indexing.

bool operator== ( Matrix< Value > const &  rhs  )  const throw (Exception::Precondition) [inline]

Equality comparator.

If matrices have different row or colmn numbers, throws a precondition exception.

bool operator< ( Matrix< Value > const &  rhs  )  const throw (Exception::Precondition) [inline]

Less-than comparator. Comparison is done lexicographically: first by row, then by column.

If matrices have different row or column numbers, throws a precondition exception.


Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  os,
const Matrix< Value > &  matrix 
) [related]

Print the contents to a stream.


Member Data Documentation

SizeType rows_ [protected]

Number of rows (height of a column).

SizeType cols_ [protected]

Number of columns (width of a row).


The documentation for this class was generated from the following file:
Generated Tue Apr 1 15:36:43 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1