00001 #ifndef Impala_Core_Stream_SeqConvKernel_h
00002 #define Impala_Core_Stream_SeqConvKernel_h
00003
00004 #include "Core/Array/MulVal.h"
00005 #include "Core/Array/Add.h"
00006 #include "Core/Array/Element/E1Cast.h"
00007
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Stream
00013 {
00014
00015
00016
00017 template<class ArrayT, class Window, class KerArrayT>
00018 inline void
00019 SeqConvKernel(ArrayT*& dst, Window* src, KerArrayT* ker)
00020 {
00021 typedef typename ArrayT::ArithType ArithT;
00022 typedef typename KerArrayT::ArithType KerArithT;
00023 typedef typename KerArrayT::StorType KerStorT;
00024
00025 using Array::MulVal;
00026 using Array::Element::E1Cast;
00027
00028 ILOG_VAR(Impala.Core.Stream.SeqConvKernel);
00029 if (src->WindowSize() != ker->CW())
00030 {
00031 ILOG_ERROR("window size does not match kernel size");
00032 return;
00033 }
00034
00035 KerStorT* filter = ker->CPB();
00036 MulVal(dst, src->DataArrayWindow(0), E1Cast(filter[0], ArithT()));
00037 int filterSize = ker->CW();
00038 ArrayT* tmp = 0;
00039 for (int i=1 ; i<filterSize ; i++)
00040 {
00041 MulVal(tmp, src->DataArrayWindow(i), E1Cast(filter[i], ArithT()));
00042 Array::Add(dst, dst, tmp);
00043 }
00044 delete tmp;
00045 }
00046
00047 }
00048 }
00049 }
00050
00051 #endif