8#ifndef META_OCEAN_MATH_SUCCESSION_SUBSET_H
9#define META_OCEAN_MATH_SUCCESSION_SUBSET_H
33template <
typename T,
size_t tDimensions>
58 using Flags = std::vector<unsigned char>;
84 inline size_t size()
const;
141 explicit inline operator bool()
const;
170 T
distance(
const size_t a,
const size_t b)
const;
198template <
typename T,
size_t tDimensions>
204template <
typename T,
size_t tDimensions>
210template <
typename T,
size_t tDimensions>
216template <
typename T,
size_t tDimensions>
222template <
typename T,
size_t tDimensions>
227 size_t index =
size_t(-1);
245 if (index ==
size_t(-1))
257template <
typename T,
size_t tDimensions>
273template <
typename T,
size_t tDimensions>
280template <
typename T,
size_t tDimensions>
286template <
typename T,
size_t tDimensions>
298template <
typename T,
size_t tDimensions>
303 for (
size_t n = 0; n <
size; ++n)
305 for (
size_t i = 0; i < tDimensions; ++i)
307 variances[i].add(objects[n][i]);
322 for (
size_t i = 0; i < tDimensions; ++i)
324 normalizationFactors[i] = variances[i].deviation() > 0 ? (T(1) / variances[i].deviation()) : T(1);
327 for (
size_t n = 0; n <
size; ++n)
329 for (
size_t i = 0; i < tDimensions; ++i)
336template <
typename T,
size_t tDimensions>
342template <
typename T,
size_t tDimensions>
349template <
typename T,
size_t tDimensions>
354 for (
size_t n = 0; n < indices.size(); ++n)
357 result[n] =
Index32(indices[n]);
363template <
typename T,
size_t tDimensions>
368 size_t smallestIndex =
size_t(-1);
389 if (localDistance < smallestDistance)
391 smallestDistance = localDistance;
397 return smallestIndex;
400template <
typename T,
size_t tDimensions>
405 size_t largestIndex =
size_t(-1);
426 if (localDistance > largestDistance)
428 largestDistance = localDistance;
437template <
typename T,
size_t tDimensions>
445 for (
size_t i = 0; i < tDimensions; ++i)
453template <
typename T,
size_t tDimensions>
466 const T localDistance =
distance(n, index);
468 if (localDistance > maxDistance)
469 maxDistance = localDistance;
477template <
typename T,
size_t tDimensions>
491 if (localDistance < minDistance)
493 minDistance = localDistance;
static constexpr T minValue()
Returns the min scalar value.
Definition Numeric.h:3259
static constexpr T sqr(const T value)
Returns the square of a given value.
Definition Numeric.h:1499
static constexpr T maxValue()
Returns the max scalar value.
Definition Numeric.h:3253
This class implements a static buffer that has a fixed capacity.
Definition StaticBuffer.h:24
StaticBuffer< T, tDimensions > Object
The definition of an abstract object of this constainer.
Definition SuccessionSubset.h:41
SuccessionSubset()
Creates an empty container object.
Definition SuccessionSubset.h:199
size_t largestMinimalDistanceWithSubset() const
Returns the elements of this container that is not part of the subset and that has the largest minima...
Definition SuccessionSubset.h:401
T distance(const size_t a, const size_t b) const
Determines the distance between two objects of this container.
Definition SuccessionSubset.h:438
T maximalDistance(const size_t index) const
Returns the maximal distance between a specified object of this container and all remaining objects o...
Definition SuccessionSubset.h:454
Indices successionSubset
The indices of all objects inside the subset.
Definition SuccessionSubset.h:195
static size_t dimensions()
Returns the dimension of each object of this container.
Definition SuccessionSubset.h:211
void setObjects(const Object *objects, const size_t size)
Overwrites all objects of this container and resets the current subset of the previous object to zero...
Definition SuccessionSubset.h:299
size_t smallestMaximalDistance() const
Returns the elements of this container that is not part of the subset and that has the smallest maxim...
Definition SuccessionSubset.h:364
std::vector< size_t > Indices
Definition of a vector holding indices.
Definition SuccessionSubset.h:46
Flags successionFlags
Objects flags, for a fast check whether an objects is part of the internal subset.
Definition SuccessionSubset.h:192
const Object & object(const size_t index)
Returns one object of this container.
Definition SuccessionSubset.h:274
size_t size() const
Returns the number of objects that are managed by this container.
Definition SuccessionSubset.h:217
bool isEmpty() const
Returns whether this container is empty and thus does not store any object.
Definition SuccessionSubset.h:337
size_t incrementSubset()
Determines the next object of this container that has the largest distance to all remaining objects t...
Definition SuccessionSubset.h:223
T minimalDistanceWithSubset(const size_t index) const
Returns the smallest distance between a specified object of this container and all subset objects of ...
Definition SuccessionSubset.h:478
static Indices32 indices2indices32(const Indices &indices)
Converts the indices of this object to 32 bit indices.
Definition SuccessionSubset.h:350
Objects successionObjects
All objects of this container.
Definition SuccessionSubset.h:189
std::vector< unsigned char > Flags
Definition of a vector holding flags.
Definition SuccessionSubset.h:58
std::vector< Object > Objects
Definition of a vector holding abstract objects.
Definition SuccessionSubset.h:53
const Indices & subset() const
Returns the current object subset of this container.
Definition SuccessionSubset.h:281
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
The namespace covering the entire Ocean framework.
Definition Accessor.h:15