Subversion Repositories gelsvn

Rev

Rev 12 | Rev 136 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12 Rev 102
1
#ifndef __CGLA_STATISTICS_H__
1
#ifndef __CGLA_STATISTICS_H__
2
#define __CGLA_STATISTICS_H__
2
#define __CGLA_STATISTICS_H__
3
 
3
 
-
 
4
#if (_MSC_VER >= 1200)
-
 
5
#pragma warning (disable: 4018 4244 4800)
-
 
6
#endif
-
 
7
 
4
#include <vector>
8
#include <vector>
5
 
9
 
6
namespace CGLA
10
namespace CGLA
7
{
11
{
8
  template<class VT>
12
  template<class VT>
9
    VT mean(const std::vector<VT>& vec)
13
    VT mean(const std::vector<VT>& vec)
10
    {
14
    {
11
      VT v(0);
15
      VT v(0);
12
      for(int i=0;i<vec.size();++i)
16
      for(int i=0;i<vec.size();++i)
13
	v += vec[i];
17
	v += vec[i];
14
      v /= vec.size();
18
      v /= vec.size();
15
 
19
 
16
      return v;
20
      return v;
17
    }
21
    }
18
 
22
 
19
 
23
 
20
  /** Function that computes the covariance of a set of points.
24
  /** Function that computes the covariance of a set of points.
21
      This function returns the mean, and, upon completion, the
25
      This function returns the mean, and, upon completion, the
22
      final argument contains the covariance matrix.
26
      final argument contains the covariance matrix.
23
 
27
 
24
      This template is instantiated for Vec3f, Vec2f, and Vec4f. */
28
      This template is instantiated for Vec3f, Vec2f, and Vec4f. */
25
			
29
			
26
  template<class VT, class MT>
30
  template<class VT, class MT>
27
    VT covariance(const std::vector<VT>& vec, MT& C_out);
31
    VT covariance(const std::vector<VT>& vec, MT& C_out);
28
}
32
}
29
 
33
 
30
 
34
 
31
 
35
 
32
 
36
 
33
#endif
37
#endif
34
 
38