OpenMS
|
A two-dimensional matrix. Similar to std::vector, but uses a binary operator(,) for element access. More...
#include <OpenMS/DATASTRUCTURES/Matrix.h>
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 | |
Constructors, assignment, and destructor | |
Matrix () | |
Matrix (const SizeType rows, const SizeType cols, ValueType value=ValueType()) | |
Matrix (const Matrix &source) | |
Matrix & | operator= (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) |
container_type | row (size_type const i) const |
Return the i-th row of the matrix as a vector. More... | |
container_type | col (size_type const i) const |
Return the i-th column of the matrix as a vector. More... | |
Pure access declarations | |
These make begin(), end() etc. from container_type accessible. | |
void | clear () |
void | resize (size_type i, size_type j, value_type value=value_type()) |
void | resize (std::pair< Size, Size > const &size_pair, value_type value=value_type()) |
SizeType | rows () const |
Number of rows. More... | |
SizeType | cols () const |
Number of columns. More... | |
std::pair< Size, Size > | sizePair () 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. More... | |
std::pair< Size, Size > const | indexPair (Size 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. More... | |
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. More... | |
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. More... | |
bool | operator== (Matrix const &rhs) const |
Equality comparator. More... | |
bool | operator< (Matrix const &rhs) const |
Less-than comparator. Comparison is done lexicographically: first by row, then by column. More... | |
template<int ROWS, int COLS> | |
void | setMatrix (const ValueType matrix[ROWS][COLS]) |
set matrix to 2D arrays values More... | |
const Base & | asVector () |
Protected Types | |
typedef std::vector< Value > | Base |
Protected Attributes | |
Data members | |
SizeType | rows_ |
Number of rows (height of a column) More... | |
SizeType | cols_ |
Number of columns (width of a row) More... | |
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. More... | |
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 data structure is not designed to be used for linear algebra, but rather a simple two-dimensional array.
The following member functions of the base class std::vector<ValueType> can also be used:
typedef Base::allocator_type allocator_type |
typedef allocator_type AllocatorType |
|
protected |
typedef Base::const_iterator const_iterator |
typedef Base::const_reference const_reference |
typedef Base::const_reverse_iterator const_reverse_iterator |
typedef const_iterator ConstIterator |
typedef const_reference ConstReference |
typedef Base container_type |
typedef Base ContainerType |
typedef Base::difference_type difference_type |
typedef difference_type DifferenceType |
typedef Base::iterator iterator |
typedef Base::pointer pointer |
typedef Base::reference reference |
typedef Base::reverse_iterator reverse_iterator |
typedef reverse_iterator ReverseIterator |
typedef Base::size_type size_type |
typedef Base::value_type value_type |
typedef value_type ValueType |
|
inline |
|
inline |
|
inline |
|
inline |
References Matrix< Value >::cols_, and Matrix< Value >::rows_.
|
inline |
Return the i-th column of the matrix as a vector.
References Matrix< Value >::cols_, Matrix< Value >::index(), and Matrix< Value >::rows_.
Referenced by Matrix< Value >::index().
Calculate the column from an index into the underlying vector. Note that Matrix uses the (row,column) lexicographic ordering for indexing.
References Matrix< Value >::cols_, and Matrix< Value >::index().
|
inline |
Number of columns.
References Matrix< Value >::cols_.
Referenced by BilinearInterpolation< Key, Value >::addValue(), OpenMS::convertOpenMSMatrix2EigenMatrixXd(), Matrix< Value >::operator<<(), BilinearInterpolation< Key, Value >::supportMax_1(), and BilinearInterpolation< Key, Value >::value().
References Matrix< Value >::index().
|
inline |
References Matrix< Value >::index().
Referenced by Matrix< Value >::operator()().
Calculate the index into the underlying vector from row and column. Note that Matrix uses the (row,column) lexicographic ordering for indexing.
References Matrix< Value >::col(), Matrix< Value >::cols_, Matrix< Value >::row(), and Matrix< Value >::rows_.
Referenced by Matrix< Value >::col(), Matrix< Value >::colIndex(), Matrix< Value >::getValue(), Matrix< Value >::indexPair(), Matrix< Value >::row(), Matrix< Value >::rowIndex(), and Matrix< Value >::setValue().
Calculate the row and column from an index into the underlying vector. Note that Matrix uses the (row,column) lexicographic ordering for indexing.
References Matrix< Value >::cols_, and Matrix< Value >::index().
References Matrix< Value >::getValue().
|
inline |
References Matrix< Value >::getValue().
|
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.
References Matrix< Value >::cols_, OPENMS_PRECONDITION, and Matrix< Value >::rows_.
References Matrix< Value >::cols_, and Matrix< Value >::rows_.
|
inline |
Equality comparator.
If matrices have different row or column numbers, throws a precondition exception.
References Matrix< Value >::cols_, OPENMS_PRECONDITION, and Matrix< Value >::rows_.
|
inline |
References Matrix< Value >::cols_, and Matrix< Value >::rows_.
Referenced by Matrix< Value >::setMatrix().
|
inline |
References Matrix< Value >::cols_, and Matrix< Value >::rows_.
|
inline |
Return the i-th row of the matrix as a vector.
References Matrix< Value >::cols_, Matrix< Value >::index(), and Matrix< Value >::rows_.
Referenced by Matrix< Value >::index().
Calculate the row from an index into the underlying vector. Note that Matrix uses the (row,column) lexicographic ordering for indexing.
References Matrix< Value >::cols_, and Matrix< Value >::index().
|
inline |
Number of rows.
References Matrix< Value >::rows_.
Referenced by BilinearInterpolation< Key, Value >::addValue(), OpenMS::convertOpenMSMatrix2EigenMatrixXd(), OpenMS::matrixIsIdentityMatrix(), Matrix< Value >::operator<<(), BilinearInterpolation< Key, Value >::supportMax_0(), and BilinearInterpolation< Key, Value >::value().
|
inline |
set matrix to 2D arrays values
References Matrix< Value >::cols_, Matrix< Value >::resize(), Matrix< Value >::rows_, and Matrix< Value >::setValue().
|
inline |
References Matrix< Value >::index().
Referenced by Matrix< Value >::setMatrix().
References Matrix< Value >::cols_, and Matrix< Value >::rows_.
|
related |
Print the contents to a stream.
References Matrix< Value >::cols(), and Matrix< Value >::rows().
|
protected |
Number of columns (width of a row)
Referenced by Matrix< Value >::clear(), Matrix< Value >::col(), Matrix< Value >::colIndex(), Matrix< Value >::cols(), Matrix< Value >::index(), Matrix< Value >::indexPair(), Matrix< Value >::operator<(), Matrix< Value >::operator=(), Matrix< Value >::operator==(), Matrix< Value >::resize(), Matrix< Value >::row(), Matrix< Value >::rowIndex(), Matrix< Value >::setMatrix(), and Matrix< Value >::sizePair().
|
protected |
Number of rows (height of a column)
Referenced by Matrix< Value >::clear(), Matrix< Value >::col(), Matrix< Value >::index(), Matrix< Value >::operator<(), Matrix< Value >::operator=(), Matrix< Value >::operator==(), Matrix< Value >::resize(), Matrix< Value >::row(), Matrix< Value >::rows(), Matrix< Value >::setMatrix(), and Matrix< Value >::sizePair().