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

TalkNgbExtra2PnLoop.h

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

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