Subversion Repositories gelsvn

Rev

Rev 431 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 431 Rev 595
Line -... Line 1...
-
 
1
/* ----------------------------------------------------------------------- *
-
 
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
-
 
3
 * Copyright (C) the authors and DTU Informatics
-
 
4
 * For license and list of authors, see ../../doc/intro.pdf
-
 
5
 * ----------------------------------------------------------------------- */
-
 
6
 
1
#include "statistics.h"
7
#include "statistics.h"
2
 
8
 
3
#include "Mat2x2f.h"
9
#include "Mat2x2f.h"
4
#include "Mat3x3f.h"
10
#include "Mat3x3f.h"
5
#include "Mat4x4f.h"
11
#include "Mat4x4f.h"
Line 13... Line 19...
13
{
19
{
14
	template<class VT, class MT>
20
	template<class VT, class MT>
15
	VT covariance(const vector<VT>& vec, MT& C_out)
21
	VT covariance(const vector<VT>& vec, MT& C_out)
16
	{
22
	{
17
		VT m = mean(vec);
23
		VT m = mean(vec);
18
		unsigned int n = vec.size();
24
		size_t n = vec.size();
19
		
25
		
20
		MT C(0);
26
		MT C(0);
21
		for(unsigned int i=0;i<n;++i)
27
		for(size_t i=0;i<n;++i)
22
		{
28
		{
23
			MT B;
29
			MT B;
24
			VT v = vec[i]-m;
30
			VT v = vec[i]-m;
25
			outer_product(v,v,B);
31
			outer_product(v,v,B);
26
			
32