00001 #ifndef Impala_Core_Array_Trait_M9poNw_h
00002 #define Impala_Core_Array_Trait_M9poNw_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 M9poNw
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 M9poNw(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 norm2 = E*E/mScale;
00046 SrcArithT norm3 = E*E*E/mScale;
00047 SrcArithT Nlx = Elx*E - El*Ex;
00048 SrcArithT Nly = Ely*E - El*Ey;
00049 SrcArithT Nlw = Element::E1Sqrt(Nlx*Nlx + Nly*Nly) / norm2;
00050
00051 SrcArithT A1 = Ellx*E*E - Ell*Ex*E;
00052 SrcArithT A2 = El*El*Ex - Elx*El*E;
00053 SrcArithT A = A1 + 2*A2;
00054 SrcArithT B1 = Elly*E*E - Ell*Ey*E;
00055 SrcArithT B2 = El*El*Ey - Ely*El*E;
00056 SrcArithT B = B1 + 2*B2;
00057
00058 SrcArithT Nllw = Element::E1Sqrt(A*A + B*B) / norm3;
00059 return Element::E1Sqrt(Nlw*Nlw + Nllw*Nllw);
00060
00061 }
00062
00063 private:
00064 SrcArithT mScale;
00065 };
00066
00067 template<class DstArrayT, class SrcArrayT>
00068 class M9poNw_log
00069 {
00070 public:
00072 typedef Pattern::TagTransInVar TransVarianceCategory;
00073
00075 typedef Pattern::TagCallValue CallCategory;
00076
00077 typedef typename DstArrayT::ArithType DstArithT;
00078 typedef typename SrcArrayT::ArithType SrcArithT;
00079
00081 M9poNw_log(SrcArithT scale)
00082 {
00083 mScale = scale;
00084 }
00085
00087 DstArithT
00088 DoIt(const SrcArithT& E, const SrcArithT& El, const SrcArithT& Ell,
00089 const SrcArithT& Ex, const SrcArithT& Elx, const SrcArithT& Ellx,
00090 const SrcArithT& Ey, const SrcArithT& Ely, const SrcArithT& Elly)
00091 {
00092 SrcArithT norm2 = E*E/mScale;
00093 SrcArithT norm3 = E*E*E/mScale;
00094 SrcArithT Nlx = Elx*E - El*Ex;
00095 SrcArithT Nly = Ely*E - El*Ey;
00096 SrcArithT Nlw = Element::E1Sqrt(Nlx*Nlx + Nly*Nly) / norm2;
00097
00098 SrcArithT A1 = Ellx*E*E - Ell*Ex*E;
00099 SrcArithT A2 = El*El*Ex - Elx*El*E;
00100 SrcArithT A = A1 + 2*A2;
00101 SrcArithT B1 = Elly*E*E - Ell*Ey*E;
00102 SrcArithT B2 = El*El*Ey - Ely*El*E;
00103 SrcArithT B = B1 + 2*B2;
00104
00105 SrcArithT Nllw = Element::E1Sqrt(A*A + B*B) / norm3;
00106
00107 return Element::E1Log(Element::E1Sqrt(Nlw*Nlw + Nllw*Nllw) + 1);
00108 }
00109
00110 private:
00111 SrcArithT mScale;
00112 };
00113
00114 }
00115 }
00116 }
00117 }
00118
00119 #endif