35 #ifndef OPENMS_DATASTRUCTURES_DISTANCEMATRIX_H 36 #define OPENMS_DATASTRUCTURES_DISTANCEMATRIX_H 41 #include <OpenMS/config.h> 67 template <
typename Value>
109 for (i = 1; i < j; i++)
117 throw Exception::OutOfMemory(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, (
UInt)((((dimensionsize - 2) * (dimensionsize - 1)) / 2) *
sizeof(ValueType)));
124 for (SizeType j = 0; j < i; ++j)
153 for (i = 1; i < j; i++)
162 throw Exception::OutOfMemory(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, (
UInt)((((dimensionsize_ - 2) * (dimensionsize_ - 1)) / 2) *
sizeof(ValueType)));
213 const ValueType
getValue(SizeType i, SizeType j)
const 228 return (
const ValueType)(
matrix_[i][j]);
264 void setValue(SizeType i, SizeType j, ValueType value)
350 void resize(SizeType dimensionsize, Value value = Value())
366 for (SizeType
k = 1;
k < j; ++
k)
374 throw Exception::OutOfMemory(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, (
UInt)((((dimensionsize_ - 2) * (dimensionsize_ - 1)) / 2) *
sizeof(Value)));
381 for (SizeType
k = 0;
k < j; ++
k)
461 for (
Size j = 0; j < i; ++j)
515 template <
typename Value>
516 std::ostream& operator<<(std::ostream& os, const DistanceMatrix<Value>& matrix)
520 std::ios_base::fmtflags flag_backup = os.setf(std::ios::scientific);
521 std::streamsize precision_backup = os.precision();
526 for (SizeType i = 0; i < matrix.dimensionsize(); ++i)
528 for (SizeType j = 0; j < matrix.dimensionsize(); ++j)
530 os << matrix(i, j) <<
'\t';
534 os.flags(flag_backup);
535 os.precision(precision_backup);
541 #endif // OPENMS_DATASTRUCTURES_DISTANCEMATRIX_H
SizeType init_size_
number of actually stored rows
Definition: DistanceMatrix.h:490
bool operator==(DistanceMatrix< ValueType > const &rhs) const
Equality comparator.
Definition: DistanceMatrix.h:456
const ValueType getValue(SizeType i, SizeType j) const
gets a value at a given position:
Definition: DistanceMatrix.h:213
Value value_type
Definition: DistanceMatrix.h:74
void resize(SizeType dimensionsize, Value value=Value())
resizing the container
Definition: DistanceMatrix.h:350
ValueType ** matrix_
sparse element not to be included in base container
Definition: DistanceMatrix.h:488
Out of range exception.
Definition: Exception.h:320
ValueType getValue(SizeType i, SizeType j)
gets a value at a given position:
Definition: DistanceMatrix.h:238
value_type ValueType
Definition: DistanceMatrix.h:80
SizeType dimensionsize_
number of accessibly stored rows (i.e. number of columns)
Definition: DistanceMatrix.h:492
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:107
A two-dimensional distance matrix, similar to OpenMS::Matrix.
Definition: DistanceMatrix.h:68
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void clear()
reset all
Definition: DistanceMatrix.h:328
const ValueType operator()(SizeType i, SizeType j) const
gets a value at a given position (read only):
Definition: DistanceMatrix.h:190
DistanceMatrix(const DistanceMatrix &source)
copy constructor
Definition: DistanceMatrix.h:139
void reduce(SizeType j)
reduces DistanceMatrix by one dimension. first the jth row, then jth column
Definition: DistanceMatrix.h:398
void setValueQuick(SizeType i, SizeType j, ValueType value)
sets a value at a given position:
Definition: DistanceMatrix.h:310
void updateMinElement()
keep track of the actual minimum element after altering the matrix
Definition: DistanceMatrix.h:429
ValueType operator()(SizeType i, SizeType j)
gets a value at a given position (read only):
Definition: DistanceMatrix.h:201
DistanceMatrix & operator=(const DistanceMatrix &rhs)
assignment operator (unsafe)
Definition: DistanceMatrix.h:498
void setValue(SizeType i, SizeType j, ValueType value)
sets a value at a given position:
Definition: DistanceMatrix.h:264
DistanceMatrix(SizeType dimensionsize, Value value=Value())
detailed constructor
Definition: DistanceMatrix.h:98
Out of memory exception.
Definition: Exception.h:472
~DistanceMatrix()
destructor
Definition: DistanceMatrix.h:175
std::pair< SizeType, SizeType > getMinElementCoordinates() const
Indexpair of minimal element.
Definition: DistanceMatrix.h:477
DistanceMatrix()
default constructor
Definition: DistanceMatrix.h:86
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
SizeType dimensionsize() const
gives the number of rows (i.e. number of columns)
Definition: DistanceMatrix.h:419
Size SizeType
Definition: DistanceMatrix.h:79
Int writtenDigits< double >(const double &)
Number of digits commonly used for writing a double (a.k.a. precision).
Definition: Types.h:220
std::pair< SizeType, SizeType > min_element_
index of minimal element(i.e. number in underlying SparseVector)
Definition: DistanceMatrix.h:494