00001 /**************************************************************************** 00002 ** 00003 ** Copyright (c) 2008-2011 C.B. Barber. All rights reserved. 00004 ** $Id: //main/2011/qhull/src/libqhullcpp/functionObjects.h#3 $$Change: 1342 $ 00005 ** $DateTime: 2011/03/07 21:55:47 $$Author: bbarber $ 00006 ** 00007 ****************************************************************************/ 00008 00009 #ifndef QHFUNCTIONOBJECTS_H 00010 #define QHFUNCTIONOBJECTS_H 00011 00012 #include <stdlib.h> 00013 #include <math.h> 00014 00015 namespace orgQhull { 00016 #//Type 00017 00019 class AbsoluteSumOf; 00021 class SumOf; 00023 class SumSquaresOf; 00024 00025 #//Class 00026 00028 class AbsoluteSumOf 00029 { 00030 private: 00031 double sum; 00032 public: 00033 inline AbsoluteSumOf() : sum(0.0) {} 00034 inline void operator()(double v) { sum += fabs(v); } 00035 inline operator double() { return sum; } 00036 };//AbsoluteSumOf 00037 00039 class SumOf 00040 { 00041 private: 00042 double sum; 00043 public: 00044 inline SumOf() : sum(0.0) {} 00045 inline void operator()(double v) { sum += v; } 00046 inline operator double() { return sum; } 00047 };//SumOf 00048 00049 00051 class SumSquaresOf 00052 { 00053 private: 00054 double sum; 00055 public: 00056 inline SumSquaresOf() : sum(0.0) {} 00057 inline void operator()(double v) { sum += v*v; } 00058 inline operator double() { return sum; } 00059 };//SumSquaresOf 00060 00061 00062 }//orgQhull 00063 00064 00065 #endif //QHFUNCTIONOBJECTS_H 00066