35 #ifndef OPENMS_DATASTRUCTURES_DPOSITION_H 36 #define OPENMS_DATASTRUCTURES_DPOSITION_H 53 template <UInt D,
typename TCoordinateType =
double>
115 OPENMS_PRECONDITION(D == 2,
"DPosition<D, TCoordinateType>:DPosition(x,y): index overflow!");
123 if (&source ==
this)
return *
this;
139 OPENMS_PRECONDITION(index < D,
"DPosition<D,TCoordinateType>:operator [] (Position): index overflow!");
146 OPENMS_PRECONDITION(index < D,
"DPosition<D,TCoordinateType>:operator [] (Position): index overflow!");
181 for (
Size i = 0; i < D; i++)
183 #pragma clang diagnostic push 184 #pragma clang diagnostic ignored "-Wfloat-equal" 187 #pragma clang diagnostic pop 204 for (
Size i = 0; i < D; i++)
216 for (
Size i = 0; i < D; i++)
228 for (
Size i = 0; i < D; i++)
238 for (
Size i = 0; i < D; i++)
261 for (
Size i = 0; i < D; ++i)
271 for (
Size i = 0; i < D; ++i)
282 for (
Size i = 0; i < D; ++i)
292 for (
Size i = 0; i < D; ++i)
303 for (
Size i = 0; i < D; ++i)
313 CoordinateType prod(0);
314 for (
Size i = 0; i < D; ++i)
324 for (
Size i = 0; i < D; ++i)
334 for (
Size i = 0; i < D; ++i)
350 for (
Size i = 0; i < D; ++i)
369 return DPosition((std::numeric_limits<typename DPosition::CoordinateType>::min)());
375 return DPosition(-(std::numeric_limits<typename DPosition::CoordinateType>::max)());
381 return DPosition((std::numeric_limits<typename DPosition::CoordinateType>::max)());
388 ConstIterator
begin()
const 420 template <UInt D,
typename TCoordinateType>
423 for (
Size i = 0; i < D; ++i)
425 position[i] *= scalar;
431 template <UInt D,
typename TCoordinateType>
434 for (
Size i = 0; i < D; ++i)
436 position[i] *= scalar;
442 template <UInt D,
typename TCoordinateType>
445 for (
Size i = 0; i < D; ++i)
447 position[i] /= scalar;
453 template <UInt D,
typename TCoordinateType>
454 std::ostream& operator<<(std::ostream& os, const DPosition<D, TCoordinateType>& pos)
457 for (
UInt i = 1; i < D; ++i)
466 #endif // OPENMS_DATASTRUCTURES_DPOSITION_H
const CoordinateType * const_iterator
Definition: DPosition.h:77
CoordinateType operator*(const DPosition &point) const
Inner product.
Definition: DPosition.h:311
DPosition operator+(const DPosition &point) const
Addition (a bit inefficient)
Definition: DPosition.h:258
bool operator!=(const DPosition &point) const
Equality operator.
Definition: DPosition.h:193
Iterator begin()
Mutable begin iterator.
Definition: DPosition.h:401
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:107
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
bool operator<(const DPosition &point) const
Lexicographical less than operator. Lexicographical comparison from dimension 0 to dimension D-1 is d...
Definition: DPosition.h:202
Definition: DPosition.h:67
DPosition(CoordinateType x, CoordinateType y)
Constructor only for DPosition<2> that takes two Coordinates.
Definition: DPosition.h:113
DPosition & operator*=(CoordinateType scalar)
Scalar multiplication.
Definition: DPosition.h:322
DPosition operator-() const
Negation (a bit inefficient)
Definition: DPosition.h:300
CoordinateType * Iterator
Mutable iterator.
Definition: DPosition.h:61
void clear()
Set all dimensions to zero.
Definition: DPosition.h:348
DPosition< D, TCoordinateType > operator/(DPosition< D, TCoordinateType > position, typename DPosition< D, TCoordinateType >::CoordinateType scalar)
Scalar multiplication (a bit inefficient)
Definition: DPosition.h:443
const CoordinateType * ConstIterator
Non-mutable iterator.
Definition: DPosition.h:63
CoordinateType getY() const
Name accessor for the second dimension. Only for DPosition<2>, for visualization. ...
Definition: DPosition.h:158
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void setY(CoordinateType c)
Name mutator for the second dimension. Only for DPosition<2>, for visualization.
Definition: DPosition.h:172
DPosition & operator+=(const DPosition &point)
Addition.
Definition: DPosition.h:269
static Size size()
Returns the number of dimensions.
Definition: DPosition.h:342
static const DPosition minPositive()
smallest positive
Definition: DPosition.h:367
DPosition(const DPosition &pos)
Copy constructor.
Definition: DPosition.h:106
CoordinateType * pointer
Definition: DPosition.h:75
DPosition operator-(const DPosition &point) const
Subtraction (a bit inefficient)
Definition: DPosition.h:279
bool spatiallyLessEqual(const DPosition &point) const
Spatially (geometrically) less or equal operator. All coordinates must be "<=".
Definition: DPosition.h:226
CoordinateType getX() const
Name accessor for the first dimension. Only for DPosition<2>, for visualization.
Definition: DPosition.h:151
CoordinateType & operator[](Size index)
Accessor for the dimensions.
Definition: DPosition.h:144
bool spatiallyGreaterEqual(const DPosition &point) const
Spatially (geometrically) greater or equal operator. All coordinates must be ">=".
Definition: DPosition.h:236
CoordinateType * iterator
Definition: DPosition.h:76
CoordinateType coordinate_[D]
Definition: DPosition.h:415
const PrecisionWrapper< FloatingPointType > precisionWrapper(const FloatingPointType rhs)
Wrapper function that sets the appropriate precision for output temporarily. The original precision i...
Definition: PrecisionWrapper.h:97
void setX(CoordinateType c)
Name mutator for the first dimension. Only for DPosition<2>, for visualization.
Definition: DPosition.h:165
Representation of a coordinate in D-dimensional space.
Definition: DPosition.h:54
static const DPosition zero()
all zero
Definition: DPosition.h:361
bool operator>=(const DPosition &point) const
Lexicographical greater or equal operator.
Definition: DPosition.h:252
~DPosition()
Destructor (not-virtual as this will save a lot of space!)
Definition: DPosition.h:95
DPosition & operator/=(CoordinateType scalar)
Scalar division.
Definition: DPosition.h:332
bool operator==(const DPosition &point) const
Equality operator.
Definition: DPosition.h:179
DPosition & operator-=(const DPosition &point)
Subtraction.
Definition: DPosition.h:290
DPosition()
Default constructor.
Definition: DPosition.h:89
CoordinateType value_type
Definition: DPosition.h:73
ConstIterator begin() const
Non-mutable begin iterator.
Definition: DPosition.h:389
static const DPosition maxPositive()
largest positive
Definition: DPosition.h:379
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
DPosition & operator=(const DPosition &source)
Assignment operator.
Definition: DPosition.h:121
Iterator end()
Mutable end iterator.
Definition: DPosition.h:407
static const DPosition minNegative()
smallest negative
Definition: DPosition.h:373
CoordinateType & reference
Definition: DPosition.h:74
bool operator<=(const DPosition &point) const
Lexicographical greater less or equal operator.
Definition: DPosition.h:214
DPosition(CoordinateType x)
Constructor that fills all dimensions with the value x.
Definition: DPosition.h:100
TCoordinateType CoordinateType
Coordinate type.
Definition: DPosition.h:59
bool operator>(const DPosition &point) const
Lexicographical greater than operator.
Definition: DPosition.h:246
CoordinateType operator[](Size index) const
Const accessor for the dimensions.
Definition: DPosition.h:137
ConstIterator end() const
Non-mutable end iterator.
Definition: DPosition.h:395