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

TalkNgbExtraPnLoop.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_Trait_TalkNgbExtraPnLoop_h
00002 #define Impala_Core_Array_Trait_TalkNgbExtraPnLoop_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 TalkNgbExtraPnLoop
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     typedef typename ExtraArrayT::StorType ExtraStorType;
00036     typedef typename ExtraArrayT::ArithType ExtraArithType;
00037 
00038 
00040     TalkNgbExtraPnLoop(bool verbose, int ngbWidth, int ngbHeight)
00041     {
00042         mNgbWidth = ngbWidth;
00043         mNgbHeight = ngbHeight;
00044         mFactor = Element::E1Cast(ngbWidth * ngbHeight, DstArithType());
00045         mVerbose = verbose;
00046     }
00047 
00049     int
00050     Width()
00051     {
00052         return mNgbWidth;
00053     }
00054 
00056     int
00057     Height()
00058     {
00059         return mNgbHeight;
00060     }
00061 
00063     void
00064     Init(int phase, int x, int y, SrcArithType v1, ExtraArithType v2)
00065     {
00066         if (mVerbose)
00067             std::cout << "  TalkNgbExtraPnLoop::init(" << phase << ","
00068                       << x << "," << y << "," << v1 << "," << v2 << ") "
00069                       << std::endl;
00070         if (phase == 1)
00071             mResult = Element::E1Cast(0, DstArithType());
00072     }
00073 
00075     void
00076     NextEl(int x, int y, SrcArithType v1, ExtraArithType v2)
00077     {
00078         if (mVerbose)
00079             std::cout << "      TalkNgbExtraPnLoop::next(" << x << "," << y
00080                       << "," << v1 << "," << v2 << ") " << std::endl;
00081         DstArithType tmp(v1, v2, 0);
00082         mResult += tmp;
00083     }
00084 
00086     void
00087     Done(int phase)
00088     {
00089     }
00090 
00092     bool
00093     HasNextPhase(int lastPhase)
00094     {
00095         if (mVerbose)
00096             std::cout << "  TalkNgbExtraPnLoop::hasNext(" << lastPhase << ") "
00097                       << std::endl;
00098         return (lastPhase < 4);
00099     }
00100 
00102     DstArithType
00103     Result() const
00104     {
00105         return mResult / mFactor;
00106     }
00107 
00108 private:
00109     int          mNgbWidth;
00110     int          mNgbHeight;
00111     DstArithType mResult;
00112     DstArithType mFactor;
00113     bool         mVerbose;
00114 };
00115 
00116 } // namespace Trait
00117 } // namespace Array
00118 } // namespace Core
00119 } // namespace Impala
00120 
00121 #endif

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