CluE  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cfdiameter.h
Go to the documentation of this file.
1 #ifndef CFENTRYDIAMETER_H
2 #define CFENTRYDIAMETER_H
3 
4 #include <cmath>
5 
6 #include "../base/attributecalculator.h"
7 
8 namespace CluE
9 {
14 template<typename T> class CFDiameter : public AttributeCalculator<CFEntry<T> >
15 {
16 public:
17  virtual CFDiameter* clone() const;
18 
19  virtual double calculate(CFEntry<T> const&) const;
20 };
21 
22 template<typename T> CFDiameter<T>* CFDiameter<T>::clone() const
23 {
24  return new CFDiameter(*this);
25 }
26 
27 template<typename T> double CFDiameter<T>::calculate(CFEntry<T> const & x) const
28 {
29  double numerator = 2*(x.number*x.SS - x.LS*x.LS);
30  double denominator = x.number * (x.number-1);
31  return std::pow(numerator / denominator, 0.5);
32 }
33 
34 }
35 
36 #endif
double SS
Squared sum.
Definition: cfentry.h:37
Abstract base class for attribute calculation (e.g. diameter).
T LS
Linear sum.
Definition: cfentry.h:32
size_t number
Number of points contained in the feature.
Definition: cfentry.h:27
virtual CFDiameter * clone() const
Definition: cfdiameter.h:22
Calculates the diameter D of a given CFEntry.
Definition: cfdiameter.h:14
Clustering feature tree entry.
Definition: cfentry.h:22
virtual double calculate(CFEntry< T > const &) const
Computes a characteristic attribute of a given object.
Definition: cfdiameter.h:27