00001 #ifndef Impala_Core_Array_Trait_InOutSetRandom_h 00002 #define Impala_Core_Array_Trait_InOutSetRandom_h 00003 00004 #include "Core/Array/Pattern/Categories.h" 00005 #include "Util/Random.h" 00006 00007 namespace Impala 00008 { 00009 namespace Core 00010 { 00011 namespace Array 00012 { 00013 namespace Trait 00014 { 00015 00017 template<class ArrayT> 00018 class InOutSetRandom 00019 { 00020 public: 00021 typedef Pattern::TagPixOpIn DirectionCategory; 00022 typedef Pattern::TagTransInVar TransVarianceCategory; 00023 typedef Pattern::Tag1Phase PhaseCategory; 00024 00025 typedef typename ArrayT::ArithType ArithT; 00026 00027 InOutSetRandom(ArithT maxVal, Util::Random& rng) 00028 : mRNG(rng) 00029 { 00030 mMaxValue = maxVal; 00031 } 00032 00036 ArithT 00037 DoIt() 00038 { 00039 return mRNG.GetDouble() * mMaxValue; 00040 } 00041 00042 private: 00043 00044 ArithT mMaxValue; 00045 Util::Random& mRNG; 00046 }; 00047 00048 } // namespace Trait 00049 } // namespace Array 00050 } // namespace Core 00051 } // namespace Impala 00052 00053 #endif