00001 #ifndef Impala_Core_Vector_Max_h
00002 #define Impala_Core_Vector_Max_h
00003
00004 #include "Core/Vector/VectorSet.h"
00005 #include "Core/Vector/MaxAssign.h"
00006
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace Vector
00012 {
00013
00014
00015 template <class ArrayT>
00016 inline void
00017 Max(typename VectorSet<ArrayT>::VectorT* dst, VectorSet<ArrayT>* src,
00018 int startIdx, int stepSize, int nrSteps)
00019 {
00020 typedef typename VectorSet<ArrayT>::VectorT VectorT;
00021
00022 if (!src->HasConstVectorSize())
00023 {
00024 std::cout << "Vector::Max: works for constant vector size only" << std::endl;
00025 return;
00026 }
00027 VectorT res(src->GetVectorLength(0));
00028 res = 0;
00029 int endIdx = startIdx + nrSteps * stepSize;
00030 for (int i=startIdx ; i<endIdx ; i+=stepSize)
00031 MaxAssign(res, src->GetVector(i, true));
00032 if (!dst)
00033 dst = new VectorT(res);
00034 else
00035 *dst = res;
00036 }
00037
00038 template <class ArrayT>
00039 inline void
00040 Max(typename VectorSet<ArrayT>::VectorT* dst, VectorSet<ArrayT>* src,
00041 int size, bool* filter)
00042 {
00043 typedef typename VectorSet<ArrayT>::VectorT VectorT;
00044
00045 if (!src->HasConstVectorSize())
00046 {
00047 std::cout << "Vector::Max: works for constant vector size only" << std::endl;
00048 return;
00049 }
00050 VectorT res(src->GetVectorLength(0));
00051 res = 0;
00052 for (int i=0 ; i<size ; i++)
00053 if (!filter || filter[i])
00054 MaxAssign(res, src->GetVector(i, true));
00055 if (!dst)
00056 dst = new VectorT(res);
00057 else
00058 *dst = res;
00059 }
00060
00061 }
00062 }
00063 }
00064
00065 #endif