Faster  0.0.4Alpha
Superfastdistributtedcomputing
misc.h
1 #ifndef LIBFASTER_MISC_H
2 #define LIBFASTER_MISC_H
3 
4 #define FDD_TYPE_NULL 0x00
5 #define FDD_TYPE_INT 0x01
6 
7 #include <typeinfo>
8 #include <string>
9 #include <math.h>
10 
11 #include "definitions.h"
12 
13 namespace faster{
14 
15  class procstat{
16  public:
17  double ram;
18  long unsigned utime;
19  long unsigned stime;
20  };
21 
22  procstat getProcStat();
23 
24  fddType decodeType(size_t typeCode);
25 
26  const std::string decodeOptype(fddOpType op);
27  const std::string decodeOptypeAb(fddOpType op);
28 
29  template < typename T >
30  double mean(std::vector<T> v){
31  T sum = 0;
32  for ( size_t i = 0; i < v.size(); ++i)
33  sum += v[i];
34 
35  return sum/(double)(v.size());
36  }
37 
38  template < typename T >
39  double max(std::vector<T> v){
40  T m = v[0];
41  for ( size_t i = 1; i < v.size(); ++i)
42  m = std::max( m, v[i] );
43 
44  return m;
45  }
46 
47  template < typename T >
48  double stdDev(std::vector<T> v, double mean){
49  double sum = 0;
50  for ( size_t i = 0; i < v.size(); ++i)
51  sum += pow(v[i] - (double) mean, 2);
52 
53  return ( sqrt( sum/(v.size() - 1) ) );
54  }
55 }
56 
57 #endif
Definition: misc.h:15
Definition: _workerFdd.h:11