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
#include "statistics.h"
2
 
3
#include "Mat2x2f.h"
4
#include "Mat3x3f.h"
5
#include "Mat4x4f.h"
6
 
7
using namespace std;
8
 
9
namespace CGLA
10
{
11
	template<class VT, class MT>
12
	VT covariance(const vector<VT>& vec, MT& C_out)
13
	{
14
		VT m = mean(vec);
15
		int n = vec.size();
16
 
17
		MT C;
18
		for(int i=0;i<n;++i)
19
			{
20
				MT B;
21
				VT v = vec[i]-m;
22
				outer_product(v,v,B);
23
 
24
				C += B;
25
			}
26
		C_out = C;
27
 
28
		return m;
29
	}
30
 
31
	template 
32
	Vec2f covariance<Vec2f,Mat2x2f>(const vector<Vec2f>& vec, Mat2x2f& C_out);
33
 
34
	template 
35
	Vec3f covariance<Vec3f,Mat3x3f>(const vector<Vec3f>& vec, Mat3x3f& C_out);
36
 
37
	template 
38
	Vec4f covariance<Vec4f,Mat4x4f>(const vector<Vec4f>& vec, Mat4x4f& C_out);
39
}