Subversion Repositories gelsvn

Rev

Rev 102 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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