timer.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "examples/timer.hh"
00023
00024 double
00025 am(double t[], int n) {
00026 if (n < 1)
00027 return 0.0;
00028 double s = 0;
00029 for (int i=n; i--; )
00030 s += t[i];
00031 return s / n;
00032 }
00033
00034 double
00035 dev(double t[], int n) {
00036 if (n < 2)
00037 return 0.0;
00038 double m = am(t,n);
00039 double s = 0.0;
00040 for (int i=n; i--; ) {
00041 double d = t[i]-m;
00042 s += d*d;
00043 }
00044 return sqrt(s / (n-1)) / m;
00045 }
00046
00047