UNIVERS
15.3
UNIVERS base processing software API
Main Page
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
s2proc
sigma_sum.hpp
1
/* sigma_sum.hpp */
2
/* $Id$ */
3
#ifndef __sigma_sum_hpp
4
#define __sigma_sum_hpp
5
6
#include <vector>
7
15
template
<
typename
T>
16
T sigma_sum(
const
size_t
size,
17
const
T* values,
18
const
float
mult = 3)
19
{
20
if
(0 == size)
21
return
0.;
22
23
T M = 0.;
24
for
(
size_t
i=0; i<size; ++i)
25
M += values[i];
26
M /= size;
27
28
T avg = 0.;
29
size_t
count = 0;
30
for
(
size_t
i=0; i<size; ++i)
31
{
32
if
(fabs(values[i] - M) < M*mult)
33
{
34
avg += values[i];
35
count++;
36
}
37
}
38
39
if
(count > 1)
40
avg /= count;
41
42
return
avg;
43
};
44
51
template
<
typename
T>
52
T sigma_sum(
const
std::vector<T> &values,
53
const
float
mult = 3)
54
{
55
return
sigma_sum<T>(values.size(), &(values.front()), mult);
56
}
57
58
#endif
/* sigma_sum.hpp */
Generated by
1.8.5