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

FuncSet.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_Pattern_FuncSet_h
00002 #define Impala_Core_Array_Pattern_FuncSet_h
00003 
00004 #include "Basis/NativeTypes.h"
00005 #include "Core/Array/Pattern/ArrayFunc.h"
00006 #include "Core/Array/Pattern/PtrFunc.h"
00007 #include "Core/Array/Element/E1Cast.h"
00008 #include <memory.h>
00009 
00010 namespace Impala
00011 {
00012 namespace Core
00013 {
00014 namespace Array
00015 {
00016 namespace Pattern
00017 {
00018 
00019 
00021 template <class DstStorT, class SrcStorT>
00022 void
00023 FuncSet_Row(DstStorT* dstPtr, SrcStorT* srcPtr, Int64 nr)
00024 {
00025     while (--nr >= 0)
00026         *dstPtr++ = (DstStorT) *srcPtr++;
00027 }
00028 
00032 template<>
00033 inline void
00034 FuncSet_Row<Real64, Real64>(Real64* dstPtr, Real64* srcPtr, Int64 nr)
00035 {
00036     memcpy(dstPtr, srcPtr, sizeof(Real64) * nr);
00037 }
00038 
00043 template<class DstArrayT, class SrcArrayT>
00044 void
00045 FuncSet(DstArrayT* dst, SrcArrayT* src, Int64 srcX, Int64 srcY,
00046         Int64 width, Int64 height, Int64 dstX, Int64 dstY)
00047 {
00048     typedef typename DstArrayT::StorType DstStorT;
00049     typedef typename DstArrayT::ArithType DstArithT;
00050     typedef typename SrcArrayT::StorType SrcStorT;
00051     typedef typename SrcArrayT::ArithType SrcArithT;
00052 
00053     if (DstArrayT::ElemSize() == SrcArrayT::ElemSize())
00054     {
00055         for (Int64 y=0 ; y<height ; y++)
00056         {
00057             DstStorT* dPtr = ArrayCPB(dst, dstX, dstY + y);
00058             SrcStorT* sPtr = ArrayCPB(src, srcX, srcY + y);
00059             FuncSet_Row(dPtr, sPtr, width * SrcArrayT::ElemSize());
00060         }
00061     }
00062     else
00063     {
00064         for (Int64 y=0 ; y<height ; y++)
00065         {
00066             DstStorT* dPtr = ArrayCPB(dst, dstX, dstY + y);
00067             SrcStorT* sPtr = ArrayCPB(src, srcX, srcY + y);
00068             for (Int64 x=0 ; x<width ; x++)
00069             {
00070                 PtrWrite(dPtr, Element::E1Cast(PtrRead(sPtr, SrcArithT()),
00071                                                DstArithT()));
00072                 dPtr += DstArrayT::ElemSize();
00073                 sPtr += SrcArrayT::ElemSize();
00074             }
00075         }
00076     }
00077 }
00078 
00079 } // namespace Pattern
00080 } // namespace Array
00081 } // namespace Core
00082 } // namespace Impala
00083 
00084 #endif

Generated on Fri Mar 19 09:30:50 2010 for ImpalaSrc by  doxygen 1.5.1