00001 #ifndef Impala_Core_Vector_HistogramNormalization_h 00002 #define Impala_Core_Vector_HistogramNormalization_h 00003 00004 #include "Core/Vector/VectorSet.h" 00005 #include "Core/Vector/DivAssign.h" 00006 #include "Core/Vector/Sum.h" 00007 #include "Core/Vector/ElemMax.h" 00008 00009 namespace Impala 00010 { 00011 namespace Core 00012 { 00013 namespace Vector 00014 { 00015 00016 00017 template <class ArrayT> 00018 inline void 00019 HistogramNormalization(VectorSet<ArrayT>* vs, bool normWeight, bool* filter) 00020 { 00021 for (int i=0 ; i<vs->Size() ; i++) 00022 { 00023 if (filter && (!filter[i])) 00024 continue; 00025 typename VectorSet<ArrayT>::VectorT v = vs->GetVector(i, true); 00026 typename VectorSet<ArrayT>::ElemT factor; 00027 factor = (normWeight) ? Sum(v) : ElemMax(v); 00028 if (factor == 0) 00029 v = 0; 00030 else 00031 DivAssign(v, factor); 00032 } 00033 } 00034 00035 } // namespace Vector 00036 } // namespace Core 00037 } // namespace Impala 00038 00039 #endif