diff --git a/corsika/framework/random/ExponentialDistribution.hpp b/corsika/framework/random/ExponentialDistribution.hpp index 2a2a1b74f3cf8ad7d751c32f15bab3f38c425a5f..51e34ce452cb42ed6b031e00f4e090ec1401525e 100644 --- a/corsika/framework/random/ExponentialDistribution.hpp +++ b/corsika/framework/random/ExponentialDistribution.hpp @@ -13,56 +13,57 @@ n/* namespace corsika { - template <class TQuantity> + template <typename Quantity> class ExponentialDistribution { - using RealType = typename TQuantity::value_type; - typedef std::exponential_distribution<RealType> distribution_type; - typedef TQuantity quantity_type; + typedef typename Quantity::value_type real_type; + typedef std::exponential_distribution<real_type> distribution_type; public: + typedef Quantity value_type; + ExponentialDistribution()=delete; - ExponentialDistribution(quantity_type vBeta) - : beta_(vBeta) {} + ExponentialDistribution(value_type const& beta) + : beta_(beta) {} - ExponentialDistribution(ExponentialDistribution<quantity_type>const& other): + ExponentialDistribution(ExponentialDistribution<value_type>const& other): beta_(other.getBeta()) {} - ExponentialDistribution<quantity_type>& - operator=(ExponentialDistribution<quantity_type>const& other){ + ExponentialDistribution<value_type>& + operator=(ExponentialDistribution<value_type>const& other){ if( this == &other) return *this; beta_ = other.getBeta(); return *this; } /** - * @fn quantity_type getBeta()const + * @fn value_type getBeta()const * @brief Get parameter of exponential distribution \f[ \beta e^{-X}\f] * @pre * @post - * @return quantity_type + * @return value_type */ - quantity_type getBeta() const { + value_type getBeta() const { return beta_; } /** - * @fn void setBeta(quantity_type) + * @fn void setBeta(value_type) * @brief Set parameter of exponential distribution \f[ \beta e^{-X}\f] * * @pre * @post * @param vBeta */ - void setBeta(quantity_type vBeta) { - beta_ = vBeta; + void setBeta(value_type const& beta) { + beta_ = beta; } /** - * @fn quantity_type operator ()(Generator&) + * @fn value_type operator ()(Generator&) * @brief Generate a random number distributed like \f[ \beta e^{-X}\f] * * @pre @@ -72,14 +73,14 @@ namespace corsika { * @return */ template <class Generator> - quantity_type operator()(Generator& g) { + value_type operator()(Generator& g) { return beta_ * dist_(g); } private: distribution_type dist_{1.}; - quantity_type beta_; + value_type beta_; }; } // namespace corsika diff --git a/corsika/framework/random/RNGManager.hpp b/corsika/framework/random/RNGManager.hpp index d78691fa9942a35f11e0d4a38c80bdc3b53a4a8d..163489842644ebd3ee7ef01a4b51b389f18c4458 100644 --- a/corsika/framework/random/RNGManager.hpp +++ b/corsika/framework/random/RNGManager.hpp @@ -46,18 +46,18 @@ namespace corsika { * * \throws sth. when stream \a pModuleName is already registered */ - inline void registerRandomStream(string_type const& vStreamName); + inline void registerRandomStream(string_type const& streamName); /*! * returns the pre-stored stream of given name \a pStreamName if * available */ - inline prng_type& getRandomStream(string_type const& vStreamName); + inline prng_type& getRandomStream(string_type const& streamName); /*! * Check whether a stream has been registered. */ - inline bool isRegistered(string_type const& vStreamName) const; + inline bool isRegistered(string_type const& streamName) const; /*! * dumps the names and states of all registered random-number streams @@ -69,7 +69,7 @@ namespace corsika { * Set explicit seeds for all currently registered streams. The actual seed values * are incremented from \a vSeed. */ - inline void seedAll(seed_type vSeed); + inline void seedAll(seed_type seed); /** * Set seeds for all currently registered streams. diff --git a/corsika/framework/random/UniformRealDistribution.hpp b/corsika/framework/random/UniformRealDistribution.hpp index 49ca93fc5c86c1750d9818b455fecd54f51bcbd7..620e72ecd7faee9cf2d101af2ffeb62c793147e8 100644 --- a/corsika/framework/random/UniformRealDistribution.hpp +++ b/corsika/framework/random/UniformRealDistribution.hpp @@ -14,32 +14,33 @@ namespace corsika { - template <class TQuantity> + template <typename Quantity> class UniformRealDistribution { - using RealType = typename TQuantity::value_type; - typedef std::uniform_real_distribution<RealType> distribution_type; + + typedef typename Quantity::value_type real_type; + typedef std::uniform_real_distribution<real_type> distribution_type; public: - typedef TQuantity quantity_type; + typedef Quantity value_type; UniformRealDistribution() = delete; - UniformRealDistribution(TQuantity b) - : min_{quantity_type(phys::units::detail::magnitude_tag, 0)} + UniformRealDistribution(Quantity const& b) + : min_{value_type(phys::units::detail::magnitude_tag, 0)} , max_(b) {} - UniformRealDistribution(quantity_type vMin, quantity_type vMax) - : min_(vMin) - , max_(vMax) {} + UniformRealDistribution(value_type const& pmin, value_type const& pmax) + : min_(pmin) + , max_(pmax) {} - UniformRealDistribution(UniformRealDistribution<quantity_type> const& other): + UniformRealDistribution(UniformRealDistribution<value_type> const& other): min_(other.getMin()) , max_(other.getMax()) {} - inline UniformRealDistribution<quantity_type>& - operator=(UniformRealDistribution<quantity_type> const& other){ + inline UniformRealDistribution<value_type>& + operator=(UniformRealDistribution<value_type> const& other){ if( this == &other) return *this; min_ = other.getMin(); max_ = other.getMax(); @@ -54,7 +55,7 @@ namespace corsika { * @post * @return quantity_type */ - inline quantity_type getMax() const { + inline value_type getMax() const { return max_; } @@ -66,8 +67,8 @@ namespace corsika { * @post * @param vMax */ - inline void setMax(quantity_type vMax) { - max_ = vMax; + inline void setMax(value_type const& pmax) { + max_ = pmax; } /** @@ -78,7 +79,7 @@ namespace corsika { * @post * @return */ - inline quantity_type getMin() const { + inline value_type getMin() const { return min_; } @@ -90,8 +91,8 @@ namespace corsika { * @post * @param vMin */ - inline void setMin(quantity_type vMin) { - min_ = vMin; + inline void setMin(value_type const& pmin) { + min_ = pmin; } /** @@ -105,16 +106,16 @@ namespace corsika { * @return quantity_type */ template <class Generator> - inline quantity_type operator()(Generator& g) { + inline value_type operator()(Generator& g) { return min_ + dist_(g) * (max_ - min_); } private: - distribution_type dist_{RealType(0.), RealType(1.)}; + distribution_type dist_{real_type(0.), real_type(1.)}; - quantity_type min_; - quantity_type max_; + value_type min_; + value_type max_; }; } // namespace corsika