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

TalkNgbPnLoop.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_Trait_TalkNgbPnLoop_h
00002 #define Impala_Core_Array_Trait_TalkNgbPnLoop_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>
00021 class TalkNgbPnLoop
00022 {
00023 public:
00024 
00026     typedef Pattern::TagLoop IteratorCategory;
00027 
00029     typedef Pattern::TagNPhase 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 
00036 
00038     TalkNgbPnLoop(bool verbose, int ngbWidth, int ngbHeight)
00039     {
00040         mNgbWidth = ngbWidth;
00041         mNgbHeight = ngbHeight;
00042         mFactor = ngbWidth * ngbHeight;
00043         mVerbose = verbose;
00044     }
00045 
00047     int
00048     Width()
00049     {
00050         return mNgbWidth;
00051     }
00052 
00054     int
00055     Height()
00056     {
00057         return mNgbHeight;
00058     }
00059 
00061     void
00062     Init(int phase, int x, int y, SrcArithType value)
00063     {
00064         if (mVerbose)
00065             std::cout << "  TalkNgbPnLoop::init(" << phase << ","
00066                       << x << "," << y << "," << value << ") " << std::endl;
00067         if (phase == 1)
00068             mResult = Element::E1Cast(0, DstArithType());
00069     }
00070 
00072     void
00073     NextEl(int x, int y, SrcArithType value)
00074     {
00075         if (mVerbose)
00076             std::cout << "      TalkNgbPnLoop::next(" << x << "," << y << ","
00077                       << value << ") " << std::endl;
00078         mResult += value;
00079     }
00080 
00082     void
00083     Done(int phase)
00084     {
00085     }
00086 
00088     bool
00089     HasNextPhase(int lastPhase)
00090     {
00091         if (mVerbose)
00092             std::cout << "  TalkNgbPnLoop::hasNext(" << lastPhase << ") "
00093                       << std::endl;
00094         return (lastPhase < 4);
00095     }
00096 
00098     DstArithType
00099     Result() const
00100     {
00101         return Element::E1Cast(mResult, DstArithType()) /
00102                Element::E1Cast(mFactor, DstArithType());
00103     }
00104 
00105 private:
00106     int          mNgbWidth;
00107     int          mNgbHeight;
00108     SrcArithType mResult;
00109     SrcArithType mFactor;
00110     bool         mVerbose;
00111 };
00112 
00113 } // namespace Trait
00114 } // namespace Array
00115 } // namespace Core
00116 } // namespace Impala
00117 
00118 #endif

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