00001 #ifndef Impala_Core_Array_Pattern_FuncUpo_h
00002 #define Impala_Core_Array_Pattern_FuncUpo_h
00003 
00004 #include "Core/Array/Pattern/Categories.h"
00005 #include "Core/Array/Pattern/ArrayFunc.h"
00006 #include "Core/Array/Pattern/PtrFunc.h"
00007 
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Array
00013 {
00014 namespace Pattern
00015 {
00016 
00017 
00020 template <class DstArrayT, class SrcArrayT, class UpoT>
00021 void
00022 FuncUpo(DstArrayT* dst, SrcArrayT* src, UpoT& upo,
00023         TagTransInVar dummy, TagCallValue dummy2)
00024 {
00025     typedef typename DstArrayT::StorType DstStorT;
00026     typedef typename DstArrayT::ArithType DstArithT;
00027     typedef typename SrcArrayT::StorType SrcStorT;
00028     typedef typename SrcArrayT::ArithType SrcArithT;
00029 
00030     int width = ArrayCW(dst);
00031     int height = ArrayCH(dst);
00032     for (int y=0 ; y<height ; y++)
00033     {
00034         SrcStorT* sPtr = ArrayCPB(src, 0, y);
00035         DstStorT* dPtr = ArrayCPB(dst, 0, y);
00036         for (int x=0 ; x<width ; x++)
00037         {
00038             PtrWrite(dPtr, upo.DoIt(PtrRead(sPtr, SrcArithT())));
00039             dPtr += DstArrayT::ElemSize();
00040             sPtr += SrcArrayT::ElemSize();
00041         }
00042     }
00043 }
00044 
00045 template <class DstArrayT, class SrcArrayT, class UpoT>
00046 void
00047 FuncUpo(DstArrayT* dst, SrcArrayT* src, UpoT& upo,
00048         TagTransInVar dummy, TagCallPointer dummy2)
00049 {
00050     typedef typename DstArrayT::StorType DstStorT;
00051     typedef typename DstArrayT::ArithType DstArithT;
00052     typedef typename SrcArrayT::StorType SrcStorT;
00053     typedef typename SrcArrayT::ArithType SrcArithT;
00054 
00055     int width = ArrayCW(dst);
00056     int height = ArrayCH(dst);
00057     for (int y=0 ; y<height ; y++)
00058     {
00059         SrcStorT* sPtr = ArrayCPB(src, 0, y);
00060         DstStorT* dPtr = ArrayCPB(dst, 0, y);
00061         for (int x=0 ; x<width ; x++)
00062         {
00063             upo.DoIt(dPtr, sPtr);
00064             dPtr += DstArrayT::ElemSize();
00065             sPtr += SrcArrayT::ElemSize();
00066         }
00067     }
00068 }
00069 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00126 template <class DstArrayT, class SrcArrayT, class UpoT>
00127 void
00128 FuncUpoDispatch(DstArrayT* dst, SrcArrayT* src, UpoT& upo)
00129 {
00130     FuncUpo(dst, src, upo, typename UpoT::TransVarianceCategory(),
00131               typename UpoT::CallCategory());
00132 }
00133 
00134 } 
00135 } 
00136 } 
00137 } 
00138 
00139 #endif