OpenMS
Loading...
Searching...
No Matches
DistanceMatrix< Value > Class Template Reference

A two-dimensional distance matrix, similar to OpenMS::Matrix. More...

#include <OpenMS/DATASTRUCTURES/DistanceMatrix.h>

Collaboration diagram for DistanceMatrix< Value >:
[legend]

Public Types

STL compliance type definitions
typedef Value value_type
 

Related Symbols

(Note that these are not member symbols.)

template<typename Value >
std::ostream & operator<< (std::ostream &os, const DistanceMatrix< Value > &matrix)
 Print the contents to a stream (and colors the diagonal, if the stream is cout/cerr)
 

OpenMS compliance type definitions

typedef Size SizeType
 
typedef value_type ValueType
 
ValueType ** matrix_
 sparse element not to be included in base container
 
SizeType init_size_
 number of actually stored rows
 
SizeType dimensionsize_
 number of accessibly stored rows (i.e. number of columns)
 
std::pair< SizeType, SizeTypemin_element_
 index of minimal element(i.e. number in underlying SparseVector)
 
 DistanceMatrix ()
 default constructor
 
 DistanceMatrix (SizeType dimensionsize, Value value=Value())
 detailed constructor
 
 DistanceMatrix (const DistanceMatrix &source)
 copy constructor
 
 ~DistanceMatrix ()
 destructor
 
const ValueType operator() (SizeType i, SizeType j) const
 gets a value at a given position (read only):
 
ValueType operator() (SizeType i, SizeType j)
 gets a value at a given position (read only):
 
const ValueType getValue (SizeType i, SizeType j) const
 gets a value at a given position:
 
ValueType getValue (SizeType i, SizeType j)
 gets a value at a given position:
 
void setValue (SizeType i, SizeType j, ValueType value)
 sets a value at a given position:
 
void setValueQuick (SizeType i, SizeType j, ValueType value)
 sets a value at a given position:
 
void clear ()
 reset all
 
void resize (SizeType dimensionsize, Value value=Value())
 resizing the container
 
void reduce (SizeType j)
 reduces DistanceMatrix by one dimension. first the jth row, then jth column
 
SizeType dimensionsize () const
 gives the number of rows (i.e. number of columns)
 
void updateMinElement ()
 keep track of the actual minimum element after altering the matrix
 
bool operator== (DistanceMatrix< ValueType > const &rhs) const
 Equality comparator.
 
std::pair< SizeType, SizeTypegetMinElementCoordinates () const
 Indexpair of minimal element.
 
DistanceMatrixoperator= (const DistanceMatrix &rhs)
 assignment operator (unsafe)
 

Detailed Description

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

A two-dimensional distance matrix, similar to OpenMS::Matrix.

Similar to OpenMS::Matrix, but contains only elements above the main diagonal, hence translating access with operator(,) for elements of above the main diagonal to corresponding elements below the main diagonal and returning 0 for requested elements in the main diagonal, since self-distance is assumed to be 0. Keeps track of the minimal element in the Matrix with OpenMS::DistanceMatrix::min_element_ if only for setting a value OpenMS::DistanceMatrix::setValue is used. Other OpenMS::DistanceMatrix altering methods may require a manual update by call of OpenMS::DistanceMatrix::updateMinElement, see the respective methods documentation.

Member Typedef Documentation

◆ SizeType

template<typename Value >
typedef Size SizeType

◆ value_type

template<typename Value >
typedef Value value_type

◆ ValueType

template<typename Value >
typedef value_type ValueType

Constructor & Destructor Documentation

◆ DistanceMatrix() [1/3]

template<typename Value >
DistanceMatrix ( )
inline

default constructor

◆ DistanceMatrix() [2/3]

template<typename Value >
DistanceMatrix ( SizeType  dimensionsize,
Value  value = Value() 
)
inline

detailed constructor

Parameters
[in]dimensionsizethe number of rows (and therewith cols)
[in]valueDistanceMatrix will be filled with this element (main diagonal will still "hold" only zeros)
Exceptions
Exception::OutOfMemoryif requested dimensionsize is to big to fit into memory

References DistanceMatrix< Value >::dimensionsize(), DistanceMatrix< Value >::dimensionsize_, DistanceMatrix< Value >::init_size_, DistanceMatrix< Value >::matrix_, and DistanceMatrix< Value >::min_element_.

◆ DistanceMatrix() [3/3]

template<typename Value >
DistanceMatrix ( const DistanceMatrix< Value > &  source)
inline

copy constructor

Parameters
[in]sourcethis DistanceMatrix will be copied
Exceptions
Exception::OutOfMemoryif requested dimensionsize is to big to fit into memory

References DistanceMatrix< Value >::dimensionsize_, DistanceMatrix< Value >::init_size_, DistanceMatrix< Value >::matrix_, and DistanceMatrix< Value >::min_element_.

◆ ~DistanceMatrix()

template<typename Value >
~DistanceMatrix ( )
inline

Member Function Documentation

◆ clear()

◆ dimensionsize()

template<typename Value >
SizeType dimensionsize ( ) const
inline

◆ getMinElementCoordinates()

template<typename Value >
std::pair< SizeType, SizeType > getMinElementCoordinates ( ) const
inline

Indexpair of minimal element.

Exceptions
Exception::OutOfRangethrown if there is no element to access

References DistanceMatrix< Value >::dimensionsize_, and DistanceMatrix< Value >::min_element_.

◆ getValue() [1/2]

template<typename Value >
ValueType getValue ( SizeType  i,
SizeType  j 
)
inline

gets a value at a given position:

Parameters
[in]ithe i-th row
[in]jthe j-th col
Exceptions
Exception::OutOfRangeif given coordinates are out of range

References DistanceMatrix< Value >::dimensionsize_, and DistanceMatrix< Value >::matrix_.

◆ getValue() [2/2]

template<typename Value >
const ValueType getValue ( SizeType  i,
SizeType  j 
) const
inline

gets a value at a given position:

Parameters
[in]ithe i-th row
[in]jthe j-th col
Exceptions
Exception::OutOfRangeif given coordinates are out of range

References DistanceMatrix< Value >::dimensionsize_, and DistanceMatrix< Value >::matrix_.

Referenced by DistanceMatrix< Value >::operator()(), and DistanceMatrix< Value >::operator()().

◆ operator()() [1/2]

template<typename Value >
ValueType operator() ( SizeType  i,
SizeType  j 
)
inline

gets a value at a given position (read only):

Parameters
[in]ithe i-th row
[in]jthe j-th col

References DistanceMatrix< Value >::getValue().

◆ operator()() [2/2]

template<typename Value >
const ValueType operator() ( SizeType  i,
SizeType  j 
) const
inline

gets a value at a given position (read only):

Parameters
[in]ithe i-th row
[in]jthe j-th col

References DistanceMatrix< Value >::getValue().

◆ operator=()

template<typename Value >
DistanceMatrix & operator= ( const DistanceMatrix< Value > &  rhs)
inlineprivate

◆ operator==()

template<typename Value >
bool operator== ( DistanceMatrix< ValueType > const &  rhs) const
inline

◆ reduce()

template<typename Value >
void reduce ( SizeType  j)
inline

reduces DistanceMatrix by one dimension. first the jth row, then jth column

Parameters
[in]jthe jth row (and therewith also jth col) to be removed
Exceptions
Exception::OutOfRangeif j is grater than the greatest row number

May invalidates min_element_, make sure to update min_element_ if necessary before used

References DistanceMatrix< Value >::dimensionsize_, and DistanceMatrix< Value >::matrix_.

◆ resize()

template<typename Value >
void resize ( SizeType  dimensionsize,
Value  value = Value() 
)
inline

resizing the container

Parameters
[in]dimensionsizethe desired number of rows (and therewith cols)
[in]valuewhich the matrix will be filled with
Exceptions
Exception::OutOfMemorythrown if size of DistanceMatrix requested does not fit into memory

invalidates all content

References DistanceMatrix< Value >::dimensionsize(), DistanceMatrix< Value >::dimensionsize_, DistanceMatrix< Value >::init_size_, DistanceMatrix< Value >::matrix_, and DistanceMatrix< Value >::min_element_.

Referenced by ClusterHierarchical::cluster(), and ClusterHierarchical::cluster().

◆ setValue()

template<typename Value >
void setValue ( SizeType  i,
SizeType  j,
ValueType  value 
)
inline

sets a value at a given position:

Parameters
[in]ithe i-th row
[in]jthe j-th col
[in]valuethe set-value
Exceptions
Exception::OutOfRangeif given coordinates are out of range

References DistanceMatrix< Value >::dimensionsize_, DistanceMatrix< Value >::matrix_, DistanceMatrix< Value >::min_element_, and DistanceMatrix< Value >::updateMinElement().

Referenced by ClusterHierarchical::cluster().

◆ setValueQuick()

template<typename Value >
void setValueQuick ( SizeType  i,
SizeType  j,
ValueType  value 
)
inline

sets a value at a given position:

Parameters
[in]ithe i-th row
[in]jthe j-th col
[in]valuethe set-value
Exceptions
Exception::OutOfRangeif given coordinates are out of range

possible invalidation of min_element_ - make sure to update before further usage of matrix

References DistanceMatrix< Value >::dimensionsize_, and DistanceMatrix< Value >::matrix_.

Referenced by ClusterHierarchical::cluster().

◆ updateMinElement()

template<typename Value >
void updateMinElement ( )
inline

keep track of the actual minimum element after altering the matrix

Exceptions
Exception::OutOfRangethrown if there is no element to access

References DistanceMatrix< Value >::dimensionsize_, DistanceMatrix< Value >::matrix_, and DistanceMatrix< Value >::min_element_.

Referenced by DistanceMatrix< Value >::setValue().

Friends And Related Symbol Documentation

◆ operator<<()

template<typename Value >
std::ostream & operator<< ( std::ostream &  os,
const DistanceMatrix< Value > &  matrix 
)
related

Print the contents to a stream (and colors the diagonal, if the stream is cout/cerr)

References DistanceMatrix< Value >::dimensionsize(), and OpenMS::red.

Member Data Documentation

◆ dimensionsize_

◆ init_size_

◆ matrix_

◆ min_element_