DynVectorKernel.h
Go to the documentation of this file.
1 #ifndef GfxTL__DYNVECTORKERNEL_HEADER__
2 #define GfxTL__DYNVECTORKERNEL_HEADER__
3 
4 namespace GfxTL
5 {
6  template< class T >
8  {
9  public:
10  DynVectorKernel(unsigned int dim);
11 
12  void Add(const T a[], const T b[], T* r) const;
13  T Dot(const T a[], const T b[]) const;
14  T SqrDistance(const T a[], const T b[]) const;
15 
16  private:
17  unsigned int m_dim;
18  };
19 
20  template< class T >
22  : m_dim(dim)
23  {}
24 
25  template< class T >
26  void DynVectorKernel< T >::Add(const T a[], const T b[], T* r) const
27  {
28  for (unsigned int i = 0; i < m_dim; ++i)
29  {
30  r[i] = a[i] + b[i];
31  }
32  }
33 
34  template< class T >
35  T DynVectorKernel< T >::Dot(const T a[], const T b[]) const
36  {
37  T r = a[0] * b[0];
38  for (size_t i = 1; i < m_dim; ++i)
39  {
40  r += a[i] * b[i];
41  }
42  return r;
43  }
44 
45  template< class T >
46  T DynVectorKernel< T >::SqrDistance(const T a[], const T b[]) const
47  {
48  T r = 0, d;
49  for (size_t i = 0; i < m_dim; ++i)
50  {
51  d = a[i] - b[i];
52  r += d * d;
53  }
54  return r;
55  }
56 };
57 
58 #endif
GfxTL::DynVectorKernel
Definition: DynVectorKernel.h:7
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
GfxTL::DynVectorKernel::Add
void Add(const T a[], const T b[], T *r) const
Definition: DynVectorKernel.h:26
GfxTL::DynVectorKernel::SqrDistance
T SqrDistance(const T a[], const T b[]) const
Definition: DynVectorKernel.h:46
GfxTL
Definition: AABox.h:8
GfxTL::DynVectorKernel::Dot
T Dot(const T a[], const T b[]) const
Definition: DynVectorKernel.h:35
T
float T
Definition: UnscentedKalmanFilterTest.cpp:35
GfxTL::DynVectorKernel::DynVectorKernel
DynVectorKernel(unsigned int dim)
Definition: DynVectorKernel.h:21