Subversion Repositories gelsvn

Rev

Rev 12 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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