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

TalkNgbExtraP1Loop.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_Trait_TalkNgbExtraP1Loop_h
00002 #define Impala_Core_Array_Trait_TalkNgbExtraP1Loop_h
00003 
00004 #include "Core/Array/Pattern/Categories.h"
00005 #include "Core/Array/Pattern/Cnum.h"
00006 #include "Core/Array/Element/E1Cast.h"
00007 
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Array
00013 {
00014 namespace Trait
00015 {
00016 
00017 
00020 template<class DstArrayT, class SrcArrayT, class ExtraArrayT>
00021 class TalkNgbExtraP1Loop
00022 {
00023 public:
00024 
00026     typedef Pattern::TagLoop IteratorCategory;
00027 
00029     typedef Pattern::Tag1Phase PhaseCategory;
00030 
00031     typedef typename DstArrayT::StorType DstStorType;
00032     typedef typename DstArrayT::ArithType DstArithType;
00033     typedef typename SrcArrayT::StorType SrcStorType;
00034     typedef typename SrcArrayT::ArithType SrcArithType;
00035     typedef typename ExtraArrayT::StorType ExtraStorType;
00036     typedef typename ExtraArrayT::ArithType ExtraArithType;
00037 
00039     TalkNgbExtraP1Loop(bool verbose, int ngbWidth, int ngbHeight)
00040     {
00041         mNgbWidth = ngbWidth;
00042         mNgbHeight = ngbHeight;
00043         mFactor = Element::E1Cast(ngbWidth * ngbHeight, DstArithType());
00044         mVerbose = verbose;
00045     }
00046 
00048     int
00049     Width()
00050     {
00051         return mNgbWidth;
00052     }
00053 
00055     int
00056     Height()
00057     {
00058         return mNgbHeight;
00059     }
00060 
00062     void
00063     Init(int x, int y, const SrcArithType& v1, const ExtraArithType& v2)
00064     {
00065         if (mVerbose)
00066             std::cout << "  TalkNgbExtraP1Loop::init(" << x << "," << y << ","
00067                       << v1 << "," << v2 << ") " << std::endl;
00068         mResult = Element::E1Cast(0, DstArithType());
00069     }
00070 
00072     void
00073     NextEl(int x, int y, const SrcArithType& v1, const ExtraArithType& v2)
00074     {
00075         if (mVerbose)
00076             std::cout << "      TalkNgbExtraP1Loop::next(" << x << "," << y
00077                       << "," << v1 << "," << v2 << ") " << std::endl;
00078         DstArithType tmp(v1, v2, 0);
00079         mResult += tmp;
00080     }
00081 
00083     DstArithType
00084     Result() const
00085     {
00086         return mResult / mFactor;
00087     }
00088 
00089 private:
00090     int          mNgbWidth;
00091     int          mNgbHeight;
00092     DstArithType mResult;
00093     DstArithType mFactor;
00094     bool         mVerbose;
00095 };
00096 
00097 } // namespace Trait
00098 } // namespace Array
00099 } // namespace Core
00100 } // namespace Impala
00101 
00102 #endif

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