Structural deformable models
Public Member Functions | Public Attributes | Friends | List of all members
CElement< D > Class Template Reference

#include <Clusterer.h>

Public Member Functions

 CElement ()
 
 CElement (float v)
 
 CElement (const vector< float > &rhs)
 
CElement< D > & operator= (const vector< float > &rhs)
 
CElement< D > & operator= (const CElement &rhs)
 
CElement< D > & operator= (float v)
 
CElement< D > & operator+= (const CElement< D > &rhs)
 
CElement< D > & operator*= (const CElement< D > &rhs)
 
CElement< D > & operator*= (float v)
 
CElement< D > & operator/= (float v)
 
CElement< D > & randomize (float min=0, float max=1)
 
float dist2 (const CElement< D > &rhs) const
 
float dist (const CElement< D > &rhs) const
 
dword getNMembers () const
 
dwordgetNMembers ()
 
dword getClassID () const
 
void setClassID (dword cid)
 

Public Attributes

float val [D]
 
dword id
 
dword multiv
 

Friends

ostream & operator<< (ostream &os, const CElement< D > &rhs)
 

Detailed Description

template<int D>
class CElement< D >

Definition at line 9 of file Clusterer.h.

Constructor & Destructor Documentation

template<int D>
CElement< D >::CElement ( )
inline

Definition at line 11 of file Clusterer.h.

11 : id(0), multiv(0) {}
dword id
Definition: Clusterer.h:78
dword multiv
Definition: Clusterer.h:79
template<int D>
CElement< D >::CElement ( float  v)
inline

Definition at line 12 of file Clusterer.h.

References CElement< D >::operator=().

12  : id(0), multiv(0) {
13  operator=(v);
14  }
CElement< D > & operator=(const vector< float > &rhs)
Definition: Clusterer.h:18
dword id
Definition: Clusterer.h:78
dword multiv
Definition: Clusterer.h:79
template<int D>
CElement< D >::CElement ( const vector< float > &  rhs)
inline

Definition at line 15 of file Clusterer.h.

References CElement< D >::operator=().

15  : id(0), multiv(0) {
16  operator=(rhs);
17  }
CElement< D > & operator=(const vector< float > &rhs)
Definition: Clusterer.h:18
dword id
Definition: Clusterer.h:78
dword multiv
Definition: Clusterer.h:79

Member Function Documentation

template<int D>
float CElement< D >::dist ( const CElement< D > &  rhs) const
inline

Definition at line 60 of file Clusterer.h.

References CElement< D >::dist2(), and dmutil::sqrt().

60  {
61  return sqrt(dist2(rhs));
62  }
float dist2(const CElement< D > &rhs) const
Definition: Clusterer.h:52
DMatrix< T > & sqrt(DMatrix< T > &mat)
Definition: DMatrixUtil.h:81
template<int D>
float CElement< D >::dist2 ( const CElement< D > &  rhs) const
inline

Definition at line 52 of file Clusterer.h.

References CElement< D >::val.

Referenced by Clusterer< D >::classify(), and CElement< D >::dist().

52  {
53  float d=0;
54  for(int i=0; i<D; i++) {
55  register float cd = val[i]-rhs.val[i];
56  d += cd*cd;
57  }
58  return d;
59  }
float val[D]
Definition: Clusterer.h:77
template<int D>
dword CElement< D >::getClassID ( ) const
inline

Definition at line 66 of file Clusterer.h.

References CElement< D >::multiv.

66 { return multiv; }
dword multiv
Definition: Clusterer.h:79
template<int D>
dword CElement< D >::getNMembers ( ) const
inline

Definition at line 64 of file Clusterer.h.

References CElement< D >::multiv.

Referenced by Clusterer< D >::classify().

64 { return multiv; }
dword multiv
Definition: Clusterer.h:79
template<int D>
dword& CElement< D >::getNMembers ( )
inline

Definition at line 65 of file Clusterer.h.

References CElement< D >::multiv.

65 { return multiv; }
dword multiv
Definition: Clusterer.h:79
template<int D>
CElement<D>& CElement< D >::operator*= ( const CElement< D > &  rhs)
inline

Definition at line 36 of file Clusterer.h.

References CElement< D >::val.

36  {
37  for(int i=0; i<D; i++) val[i]*=rhs.val[i];
38  return *this;
39  }
float val[D]
Definition: Clusterer.h:77
template<int D>
CElement<D>& CElement< D >::operator*= ( float  v)
inline

Definition at line 40 of file Clusterer.h.

References CElement< D >::val.

40  {
41  for(int i=0; i<D; i++) val[i]*=v;
42  return *this;
43  }
float val[D]
Definition: Clusterer.h:77
template<int D>
CElement<D>& CElement< D >::operator+= ( const CElement< D > &  rhs)
inline

Definition at line 32 of file Clusterer.h.

References CElement< D >::val.

32  {
33  for(int i=0; i<D; i++) val[i]+=rhs.val[i];
34  return *this;
35  }
float val[D]
Definition: Clusterer.h:77
template<int D>
CElement<D>& CElement< D >::operator/= ( float  v)
inline

Definition at line 44 of file Clusterer.h.

References CElement< D >::val.

44  {
45  for(int i=0; i<D; i++) val[i]/=v;
46  return *this;
47  }
float val[D]
Definition: Clusterer.h:77
template<int D>
CElement<D>& CElement< D >::operator= ( const vector< float > &  rhs)
inline

Definition at line 18 of file Clusterer.h.

References CElement< D >::val.

Referenced by CElement< D >::CElement().

18  {
19  for(int i=0; i<D; i++) val[i]=rhs[i];
20  return *this;
21  }
float val[D]
Definition: Clusterer.h:77
template<int D>
CElement<D>& CElement< D >::operator= ( const CElement< D > &  rhs)
inline

Definition at line 22 of file Clusterer.h.

References CElement< D >::id, CElement< D >::multiv, and CElement< D >::val.

22  {
23  for(int i=0; i<D; i++) val[i]=rhs.val[i];
24  id = rhs.id;
25  multiv = rhs.multiv;
26  return *this;
27  }
dword id
Definition: Clusterer.h:78
dword multiv
Definition: Clusterer.h:79
float val[D]
Definition: Clusterer.h:77
template<int D>
CElement<D>& CElement< D >::operator= ( float  v)
inline

Definition at line 28 of file Clusterer.h.

References CElement< D >::val.

28  {
29  for(int i=0; i<D; i++) val[i]=v;
30  return *this;
31  }
float val[D]
Definition: Clusterer.h:77
template<int D>
CElement<D>& CElement< D >::randomize ( float  min = 0,
float  max = 1 
)
inline

Definition at line 48 of file Clusterer.h.

References frand, and CElement< D >::val.

48  {
49  for(int i=0; i<D; i++) val[i]=frand(max-min)+min;
50  return *this;
51  }
#define frand(max)
Definition: mathutil.h:48
float val[D]
Definition: Clusterer.h:77
template<int D>
void CElement< D >::setClassID ( dword  cid)
inline

Definition at line 67 of file Clusterer.h.

References CElement< D >::multiv.

Referenced by Clusterer< D >::classify().

67 { multiv = cid; }
dword multiv
Definition: Clusterer.h:79

Friends And Related Function Documentation

template<int D>
ostream& operator<< ( ostream &  os,
const CElement< D > &  rhs 
)
friend

Definition at line 68 of file Clusterer.h.

68  {
69  for(int i=0; i<D; i++) {
70  if(i) os << " ";
71  os << rhs.val[i];
72  }
73  return os;
74  }
float val[D]
Definition: Clusterer.h:77

Member Data Documentation

template<int D>
dword CElement< D >::id

Definition at line 78 of file Clusterer.h.

Referenced by CElement< D >::operator=().

template<int D>
dword CElement< D >::multiv
template<int D>
float CElement< D >::val[D]

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