Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

ElemAvg.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Vector_ElemAvg_h
00002 #define Impala_Core_Vector_ElemAvg_h
00003 
00004 #include "Core/Vector/VectorTem.h"
00005 
00006 namespace Impala
00007 {
00008 namespace Core
00009 {
00010 namespace Vector
00011 {
00012 
00013 
00014 template <class ElemT>
00015 inline ElemT
00016 ElemAvg(VectorTem<ElemT> v, bool* filter1, bool* filter2, int maxNr = -1)
00017 {
00018     ElemT* p = v.GetData();
00019     ElemT res = 0;
00020     int nr = 0;
00021     if (maxNr == -1)
00022         maxNr = v.Size();
00023     for (int i=0 ; i<v.Size() ; i++)
00024     {
00025         if ((filter1 && !filter1[i]) || (filter2 && !filter2[i]))
00026             continue;
00027         res += p[i];
00028         nr++;
00029         if (nr >= maxNr)
00030             return res / nr;
00031     }
00032     return res / nr;
00033 }
00034 
00035 } // namespace Vector
00036 } // namespace Core
00037 } // namespace Impala
00038 
00039 #endif

Generated on Fri Mar 19 09:31:28 2010 for ImpalaSrc by  doxygen 1.5.1