/* boost random/rician_distribution.hpp header file * * Copyright Matthias Christian Schabel 2008 * Distributed under the Boost Software License, Version 1.0. (See * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * See http://www.boost.org for most recent version including documentation. * */ #ifndef BOOST_RANDOM_RICIAN_DISTRIBUTION_HPP #define BOOST_RANDOM_RICIAN_DISTRIBUTION_HPP #include #include #include #include #include #include namespace boost { template class rician_distribution { public: typedef RealType input_type; typedef RealType result_type; #if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) && !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300) BOOST_STATIC_ASSERT(!std::numeric_limits::is_integer); #endif explicit rician_distribution(const result_type& v_arg = result_type(0), const result_type& s_arg = result_type(1)) : _v(v_arg), _s(s_arg), _normal_dist() { assert(_s >= result_type(0)); } // compiler-generated copy constructor is fine // rician_distribution(const rician_distribution& other) // : _v(other._v), _s(other._s), _normal_dist(other._normal_dist) // { } // compiler-generated copy ctor and assignment operator are fine RealType v() const { return _v; } RealType s() const { return _s; } void reset() { _normal_dist.reset(); } template result_type operator()(Engine& eng) { #ifndef BOOST_NO_STDC_NAMESPACE // allow for Koenig lookup using std::sqrt; #endif const result_type x = _s*_normal_dist(eng) + _v, y = _s*_normal_dist(eng); return sqrt(x*x+y*y); } #if !defined(BOOST_NO_OPERATORS_IN_NAMESPACE) && !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) template friend std::basic_ostream& operator<<(std::basic_ostream& os, const rician_distribution& nd) { os << nd._v << " " << nd._s; return os; } template friend std::basic_istream& operator>>(std::basic_istream& is, rician_distribution& nd) { is >> std::ws >> nd._v >> std::ws >> nd._s; return is; } #endif private: result_type _v, _s; normal_distribution _normal_dist; }; } // namespace boost #endif // BOOST_RANDOM_RICIAN_DISTRIBUTION_HPP