| OpenMS 2.5.0

Public Member Functions | Protected Types | Related Functions | List of all members
Matrix< Value > Class Template Reference
Datastructures

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

`#include <OpenMS/ANALYSIS/QUANTITATION/IsobaricQuantitationMethod.h>`

Inheritance diagram for Matrix< Value >:

## 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< 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 ()
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...

## 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...

## 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 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:

- begin
- end
- rbegin
- rend
- front
- back
- assign
- empty
- size
- capacity
- max_size

## Member Typedef Documentation

## ◆ allocator_type

typedef Base::allocator_type allocator_type

## ◆ AllocatorType

typedef allocator_type AllocatorType

## ◆ Base

typedef std::vector<Value> Base

protected

## ◆ const_iterator

typedef Base::const_iterator const_iterator

## ◆ const_reference

typedef Base::const_reference const_reference

## ◆ const_reverse_iterator

typedef Base::const_reverse_iterator const_reverse_iterator

## ◆ ConstIterator

typedef const_iterator ConstIterator

## ◆ ConstReference

typedef const_reference ConstReference

## ◆ ConstReverseIterator

typedef const_reverse_iterator ConstReverseIterator

## ◆ container_type

typedef Base container_type

## ◆ ContainerType

typedef Base ContainerType

## ◆ difference_type

typedef Base::difference_type difference_type

## ◆ DifferenceType

typedef difference_type DifferenceType

## ◆ iterator

typedef Base::iterator iterator

## ◆ Iterator

typedef iterator Iterator

## ◆ pointer

typedef Base::pointer pointer

## ◆ Pointer

typedef pointer Pointer

## ◆ reference

typedef Base::reference reference

## ◆ Reference

typedef reference Reference

## ◆ reverse_iterator

typedef Base::reverse_iterator reverse_iterator

## ◆ ReverseIterator

typedef reverse_iterator ReverseIterator

## ◆ size_type

typedef Base::size_type size_type

## ◆ SizeType

typedef size_type SizeType

## ◆ value_type

typedef Base::value_type value_type

## ◆ ValueType

typedef value_type ValueType

## Constructor & Destructor Documentation

## ◆ Matrix() [1/3]

Matrix | ( |  | ) |

inline

## ◆ Matrix() [2/3]

Matrix | ( | const SizeType | rows,
|  | const SizeType | cols,
|  | ValueType | value = `ValueType()`
| ) |  |

inline

## ◆ Matrix() [3/3]

Matrix | ( | const Matrix< Value > & | source | ) |

inline

## ◆ ~Matrix()

~Matrix | ( |  | ) |

inline

## Member Function Documentation

## ◆ asVector()

const Base& asVector | ( |  | ) |

inline

## ◆ clear()

void clear | ( |  | ) |

inline

## ◆ col()

container_type col | ( | size_type const | i | ) | const

inline

Return the i-th column of the matrix as a vector.

Referenced by Matrix< UInt >::index().

## ◆ colIndex()

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.

## ◆ cols()

SizeType cols | ( |  | ) | const

inline

Number of columns.

Referenced by BilinearInterpolation< Key, Value >::addValue(), OpenMS::convertOpenMSMatrix2EigenMatrixXd(), BilinearInterpolation< Key, Value >::supportMax_1(), and BilinearInterpolation< Key, Value >::value().

## ◆ getValue() [1/2]

const_reference getValue | ( | size_type const | i,
|  | size_type const | j
| ) |  | const

inline

Referenced by Matrix< UInt >::operator()().

## ◆ getValue() [2/2]

reference getValue | ( | size_type const | i,
|  | size_type const | j
| ) |  |

inline

## ◆ index()

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.

Referenced by Matrix< UInt >::col(), Matrix< UInt >::colIndex(), Matrix< UInt >::getValue(), Matrix< UInt >::indexPair(), Matrix< UInt >::row(), Matrix< UInt >::rowIndex(), and Matrix< UInt >::setValue().

## ◆ indexPair()

std::pair<Size, Size> const indexPair | ( | Size | 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.

## ◆ operator()() [1/2]

const_reference operator() | ( | size_type const | i,
|  | size_type const | j
| ) |  | const

inline

## ◆ operator()() [2/2]

reference operator() | ( | size_type const | i,
|  | size_type const | j
| ) |  |

inline

## ◆ operator<()

bool operator< | ( | Matrix< Value > const & | rhs | ) | const

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.

## ◆ operator=()

Matrix& operator= | ( | const Matrix< Value > & | rhs | ) |

inline

## ◆ operator==()

bool operator== | ( | Matrix< Value > const & | rhs | ) | const

inline

Equality comparator.

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

## ◆ resize() [1/2]

void resize | ( | size_type | i,
|  | size_type | j,
|  | value_type | value = `value_type()`
| ) |  |

inline

Referenced by Matrix< UInt >::setMatrix().

## ◆ resize() [2/2]

void resize | ( | std::pair< Size, Size > const & | size_pair,
|  | value_type | value = `value_type()`
| ) |  |

inline

## ◆ row()

container_type row | ( | size_type const | i | ) | const

inline

Return the i-th row of the matrix as a vector.

Referenced by Matrix< UInt >::index().

## ◆ rowIndex()

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.

## ◆ rows()

SizeType rows | ( |  | ) | const

inline

Number of rows.

Referenced by BilinearInterpolation< Key, Value >::addValue(), OpenMS::convertOpenMSMatrix2EigenMatrixXd(), OpenMS::matrixIsIdentityMatrix(), BilinearInterpolation< Key, Value >::supportMax_0(), and BilinearInterpolation< Key, Value >::value().

## ◆ setMatrix()

void setMatrix | ( | const ValueType | matrix[ROWS][COLS] | ) |

inline

set matrix to 2D arrays values

## ◆ setValue()

void setValue | ( | size_type const | i,
|  | size_type const | j,
|  | value_type | value
| ) |  |

inline

Referenced by Matrix< UInt >::setMatrix().

## ◆ sizePair()

std::pair<Size, Size> sizePair | ( |  | ) | const

inline

## Friends And Related Function Documentation

## ◆ operator<<()

std::ostream & operator<< | ( | std::ostream & | os,
|  | const Matrix< Value > & | matrix
| ) |  |

related

Print the contents to a stream.

## Member Data Documentation

## ◆ cols_

SizeType cols_

protected

Number of columns (width of a row)

Referenced by Matrix< UInt >::clear(), Matrix< UInt >::col(), Matrix< UInt >::colIndex(), Matrix< UInt >::cols(), Matrix< UInt >::index(), Matrix< UInt >::indexPair(), Matrix< UInt >::operator<(), Matrix< UInt >::operator=(), Matrix< UInt >::operator==(), Matrix< UInt >::resize(), Matrix< UInt >::row(), Matrix< UInt >::rowIndex(), Matrix< UInt >::setMatrix(), and Matrix< UInt >::sizePair().

## ◆ rows_

SizeType rows_

protected

Number of rows (height of a column)

Referenced by Matrix< UInt >::clear(), Matrix< UInt >::col(), Matrix< UInt >::index(), Matrix< UInt >::operator<(), Matrix< UInt >::operator=(), Matrix< UInt >::operator==(), Matrix< UInt >::resize(), Matrix< UInt >::row(), Matrix< UInt >::rows(), Matrix< UInt >::setMatrix(), and Matrix< UInt >::sizePair().