Subversion Repositories gelsvn

Rev

Rev 102 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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