Subversion Repositories gelsvn

Rev

Rev 102 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 102 Rev 136
Line 7... Line 7...
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(unsigned 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