libfaster API Documentation  Development Version
Super fast distributted computing
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 sum(std::vector<T> v){
49  T sum = 0;
50  for ( size_t i = 0; i < v.size(); ++i)
51  sum += v[i];
52 
53  return sum;
54  }
55 
56  template < typename T >
57  double stdDev(std::vector<T> v, double mean){
58  double sum = 0;
59  for ( size_t i = 0; i < v.size(); ++i)
60  sum += pow(v[i] - (double) mean, 2);
61 
62  return ( sqrt( sum/(v.size() - 1) ) );
63  }
64 }
65 
66 #endif
unsigned int fddOpType
Dataset operation type.
Definition: definitions.h:41
libfaster main namespace
Definition: _workerFdd.h:11
unsigned int fddType
Dataset type.
Definition: definitions.h:16