Generated on Wed Nov 1 15:04:28 2006 for Gecode by doxygen 1.4.5

timer.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2004
00007  *
00008  *  Last modified:
00009  *     $Date: 2005-11-02 13:53:36 +0100 (Wed, 02 Nov 2005) $ by $Author: schulte $
00010  *     $Revision: 2470 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
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 // STATISTICS: example-any