00001 #ifndef Impala_Core_Array_Trait_ExportStat_h 00002 #define Impala_Core_Array_Trait_ExportStat_h 00003 00004 #include "Basis/Std.h" 00005 #include "Core/Array/Pattern/Categories.h" 00006 #include "Core/Array/Element/E0SmallVal.h" 00007 #include "Core/Array/Element/E0LargeVal.h" 00008 #include "Core/Array/Element/E1Cast.h" 00009 #include "Core/Array/Element/E1Abs.h" 00010 00011 namespace Impala 00012 { 00013 namespace Core 00014 { 00015 namespace Array 00016 { 00017 namespace Trait 00018 { 00019 00020 00021 template<class ArithT, class DataT> 00022 class ExportStat 00023 { 00024 public: 00025 typedef Pattern::TagPixOpOut DirectionCategory; 00026 typedef Pattern::TagTransInVar TransVarianceCategory; 00027 typedef Pattern::Tag1Phase PhaseCategory; 00028 00029 ExportStat() 00030 { 00031 mNum = 0; 00032 mMinVal = Element::E0LargeVal<ArithT>(ArithT()); 00033 mMaxVal = Element::E0SmallVal<ArithT>(ArithT()); 00034 mSum = Element::E1Cast(0, ArithT()); 00035 mSumSqr = Element::E1Cast(0, ArithT()); 00036 mSumAbs = Element::E1Cast(0, ArithT()); 00037 } 00038 00039 void 00040 DoIt(const ArithT& x) 00041 { 00042 mMinVal = Impala::Min(mMinVal, x); 00043 mMaxVal = Impala::Max(mMaxVal, x); 00044 mSum += x; 00045 mSumSqr += x*x; 00046 mSumAbs += Element::E1Abs(x); 00047 mNum += 1; 00048 } 00049 00050 //private: 00051 Int32 mNum; 00052 ArithT mMinVal; 00053 ArithT mMaxVal; 00054 ArithT mSum; 00055 ArithT mSumSqr; 00056 ArithT mSumAbs; 00057 }; 00058 00059 } // namespace Trait 00060 } // namespace Array 00061 } // namespace Core 00062 } // namespace Impala 00063 00064 #endif