Ocean
Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster Class Reference

This class implements one cluster that holds the mean values of all observations belonging to this cluster and the indices of all observations belonging to this cluster. More...

Public Member Functions

 Cluster (Cluster &&cluster) noexcept
 Move constructor for another cluster object. More...
 
const Observationmean () const
 Returns the mean observation value of this cluster. More...
 
const DataIndicesdataIndices () const
 Returns the indices of the observations that belong to this cluster. More...
 
TSquareDistance sqrDistance (const Observation &observation) const
 Returns the square distance between a given observation and this cluster (the mean observation value of this cluster). More...
 
TSquareDistance maximalSqrDistance (DataIndex *observationIndex=nullptr) const
 Calculates the maximal square distance between the mean observation value of this cluster and all observations which belong to this cluster. More...
 
TSquareDistance averageSqrDistance () const
 Calculates the average square distance between the mean observation value of this cluster and all observations which belong to this cluster. More...
 
Clusteroperator= (Cluster &&cluster) noexcept
 Move operator moving a cluster object to this object. More...
 
bool operator< (const Cluster &cluster) const
 Returns whether the left cluster has less elements than the right cluster. More...
 

Protected Member Functions

 Cluster (const ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices > &owner, const Observation &mean)
 Creates a new cluster object by a given mean value. More...
 
 Cluster (const ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices > &owner, const Observation &mean, const DataIndices &dataIndices)
 Creates a new cluster object by a given mean value and several indices of observations that belong to this cluster. More...
 
 Cluster (const ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices > &owner, const Observation &mean, DataIndices &&dataIndices)
 Creates a new cluster object by a given mean value and several indices of observations that belong to this cluster. More...
 
DataIndicesdataIndices ()
 Returns the data-indices of the observations that belong to this cluster. More...
 
void updateMean ()
 Updates the mean observation value of this cluster by application of the stored indices of all observations that belong to this cluster. More...
 

Protected Attributes

const ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices > * owner_
 The owner of this cluster. More...
 
Observation mean_
 The mean observation value of this cluster. More...
 
DataIndices dataIndices_
 The data indices of all observation that belong to this cluster. More...
 

Friends

class ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >
 
class std::allocator< Cluster >
 

Detailed Description

template<typename T, size_t tDimension, typename TSum = T, typename TSquareDistance = T, bool tUseIndices = true>
class Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster

This class implements one cluster that holds the mean values of all observations belonging to this cluster and the indices of all observations belonging to this cluster.

Constructor & Destructor Documentation

◆ Cluster() [1/4]

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::Cluster ( Cluster &&  cluster)
inlinenoexcept

Move constructor for another cluster object.

Parameters
clusterThe cluster object to be moved

◆ Cluster() [2/4]

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::Cluster ( const ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices > &  owner,
const Observation mean 
)
inlineprotected

Creates a new cluster object by a given mean value.

Parameters
ownerThe owner of this cluster object
meanThe mean observation value that will define this cluster

◆ Cluster() [3/4]

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::Cluster ( const ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices > &  owner,
const Observation mean,
const DataIndices dataIndices 
)
inlineprotected

Creates a new cluster object by a given mean value and several indices of observations that belong to this cluster.

Parameters
ownerThe owner of this cluster object
meanThe mean observation value that will define this cluster
dataIndicesThe data-indices of the observations that belong to this cluster

◆ Cluster() [4/4]

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::Cluster ( const ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices > &  owner,
const Observation mean,
DataIndices &&  dataIndices 
)
inlineprotected

Creates a new cluster object by a given mean value and several indices of observations that belong to this cluster.

Parameters
ownerThe owner of this cluster object
meanThe mean observation value that will define this cluster
dataIndicesThe data-indices of the observations that belong to this cluster; beware: the indices will be moved to this cluster object

Member Function Documentation

◆ averageSqrDistance()

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
TSquareDistance Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::averageSqrDistance

Calculates the average square distance between the mean observation value of this cluster and all observations which belong to this cluster.

Returns
Average square distance

◆ dataIndices() [1/2]

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::DataIndices & Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::dataIndices
inlineprotected

Returns the data-indices of the observations that belong to this cluster.

Returns
The cluster's observation indices

◆ dataIndices() [2/2]

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
const ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::DataIndices & Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::dataIndices
inline

Returns the indices of the observations that belong to this cluster.

Returns
The cluster's observation indices

◆ maximalSqrDistance()

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
TSquareDistance Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::maximalSqrDistance ( DataIndex observationIndex = nullptr) const

Calculates the maximal square distance between the mean observation value of this cluster and all observations which belong to this cluster.

Parameters
observationIndexOptional resulting index of the observation with maximal distance to the mean observation value, if defined
Returns
Maximal square distance

◆ mean()

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
const ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Observation & Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::mean
inline

Returns the mean observation value of this cluster.

Returns
The cluster's mean observation value

◆ operator<()

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
bool Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::operator< ( const Cluster cluster) const
inline

Returns whether the left cluster has less elements than the right cluster.

Parameters
clusterThe right cluster to compare
Returns
True, if so

◆ operator=()

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster & Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::operator= ( Cluster &&  cluster)
inlinenoexcept

Move operator moving a cluster object to this object.

Parameters
clusterThe cluster object to be moved
Returns
Reference to this object

◆ sqrDistance()

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
TSquareDistance Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::sqrDistance ( const Observation observation) const
inline

Returns the square distance between a given observation and this cluster (the mean observation value of this cluster).

Parameters
observationThe observation for that the distance is returned
Returns
Resulting square distance

◆ updateMean()

template<typename T , size_t tDimension, typename TSum , typename TSquareDistance , bool tUseIndices>
void Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::updateMean
protected

Updates the mean observation value of this cluster by application of the stored indices of all observations that belong to this cluster.

Friends And Related Function Documentation

◆ ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >

template<typename T , size_t tDimension, typename TSum = T, typename TSquareDistance = T, bool tUseIndices = true>
friend class ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >
friend

◆ std::allocator< Cluster >

template<typename T , size_t tDimension, typename TSum = T, typename TSquareDistance = T, bool tUseIndices = true>
friend class std::allocator< Cluster >
friend

Field Documentation

◆ dataIndices_

template<typename T , size_t tDimension, typename TSum = T, typename TSquareDistance = T, bool tUseIndices = true>
DataIndices Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::dataIndices_
protected

The data indices of all observation that belong to this cluster.

◆ mean_

template<typename T , size_t tDimension, typename TSum = T, typename TSquareDistance = T, bool tUseIndices = true>
Observation Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::mean_
protected

The mean observation value of this cluster.

◆ owner_

template<typename T , size_t tDimension, typename TSum = T, typename TSquareDistance = T, bool tUseIndices = true>
const ClusteringKMeans<T, tDimension, TSum, TSquareDistance, tUseIndices>* Ocean::ClusteringKMeans< T, tDimension, TSum, TSquareDistance, tUseIndices >::Cluster::owner_
protected

The owner of this cluster.


The documentation for this class was generated from the following file: