00001 #ifndef Impala_Core_Array_Trait_M9poHw_h
00002 #define Impala_Core_Array_Trait_M9poHw_h
00003
00004 #include "Core/Array/Pattern/Categories.h"
00005 #include "Core/Array/Element/E1Sqrt.h"
00006 #include "Core/Array/Element/E1Log.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 M9poHw
00022 {
00023 public:
00025 typedef Pattern::TagTransInVar TransVarianceCategory;
00026
00028 typedef Pattern::TagCallValue CallCategory;
00029
00030 typedef typename DstArrayT::ArithType DstArithT;
00031 typedef typename SrcArrayT::ArithType SrcArithT;
00032
00034 M9poHw(SrcArithT scale)
00035 {
00036 mScale = scale;
00037 }
00038
00040 DstArithT
00041 DoIt(const SrcArithT& E, const SrcArithT& El, const SrcArithT& Ell,
00042 const SrcArithT& Ex, const SrcArithT& Elx, const SrcArithT& Ellx,
00043 const SrcArithT& Ey, const SrcArithT& Ely, const SrcArithT& Elly)
00044 {
00045 SrcArithT norm = (El*El + Ell*Ell) / mScale;
00046 SrcArithT Cx = Ell*Elx - El*Ellx;
00047 SrcArithT Hy = Ell*Ely - El*Elly;
00048 return Element::E1Sqrt(Cx*Cx + Hy*Hy) / norm;
00049
00050 }
00051
00052 private:
00053 SrcArithT mScale;
00054 };
00055
00056 template<class DstArrayT, class SrcArrayT>
00057 class M9poHw_log
00058 {
00059 public:
00061 typedef Pattern::TagTransInVar TransVarianceCategory;
00062
00064 typedef Pattern::TagCallValue CallCategory;
00065
00066 typedef typename DstArrayT::ArithType DstArithT;
00067 typedef typename SrcArrayT::ArithType SrcArithT;
00068
00070 M9poHw_log(SrcArithT scale)
00071 {
00072 mScale = scale;
00073 }
00074
00076 DstArithT
00077 DoIt(const SrcArithT& E, const SrcArithT& El, const SrcArithT& Ell,
00078 const SrcArithT& Ex, const SrcArithT& Elx, const SrcArithT& Ellx,
00079 const SrcArithT& Ey, const SrcArithT& Ely, const SrcArithT& Elly)
00080 {
00081 SrcArithT norm = (El*El + Ell*Ell) / mScale;
00082 SrcArithT Cx = Ell*Elx - El*Ellx;
00083 SrcArithT Hy = Ell*Ely - El*Elly;
00084
00085 return Element::E1Log(Element::E1Sqrt(Cx*Cx + Hy*Hy) / norm + 1);
00086 }
00087
00088 private:
00089 SrcArithT mScale;
00090 };
00091
00092 }
00093 }
00094 }
00095 }
00096
00097 #endif