x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
linear_feedback_shift.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\random\linear_feedback_shift.hpp
旋转
特效
属性
历史版本
/* boost random/tausworthe.hpp header file * * Copyright Jens Maurer 2002 * 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. * * $Id: linear_feedback_shift.hpp 29116 2005-05-21 15:57:01Z dgregor $ * */ #ifndef BOOST_RANDOM_LINEAR_FEEDBACK_SHIFT_HPP #define BOOST_RANDOM_LINEAR_FEEDBACK_SHIFT_HPP #include
#include
#include
#include
#include
#include
namespace boost { namespace random { // Tausworte 1965 template
class linear_feedback_shift { public: typedef UIntType result_type; // avoid the warning trouble when using (1<
0); // BOOST_STATIC_ASSERT(q > 0); // BOOST_STATIC_ASSERT(k < w); // BOOST_STATIC_ASSERT(0 < 2*q && 2*q < k); // BOOST_STATIC_ASSERT(0 < s && s <= k-q); explicit linear_feedback_shift(UIntType s0 = 341) : wordmask(0) { // MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT(std::numeric_limits
::is_integer); BOOST_STATIC_ASSERT(!std::numeric_limits
::is_signed); #endif // avoid "left shift count >= with of type" warning for(int i = 0; i < w; ++i) wordmask |= (1u << i); seed(s0); } template
linear_feedback_shift(It& first, It last) : wordmask(0) { // MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT(std::numeric_limits
::is_integer); BOOST_STATIC_ASSERT(!std::numeric_limits
::is_signed); #endif // avoid "left shift count >= with of type" warning for(int i = 0; i < w; ++i) wordmask |= (1u << i); seed(first, last); } void seed(UIntType s0 = 341) { assert(s0 >= (1 << (w-k))); value = s0; } template
void seed(It& first, It last) { if(first == last) throw std::invalid_argument("linear_feedback_shift::seed"); value = *first++; assert(value >= (1 << (w-k))); } result_type operator()() { const UIntType b = (((value << q) ^ value) & wordmask) >> (k-s); const UIntType mask = ( (~static_cast
(0)) << (w-k) ) & wordmask; value = ((value & mask) << s) ^ b; return value; } bool validation(result_type x) const { return val == x; } #ifndef BOOST_NO_OPERATORS_IN_NAMESPACE #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS template
friend std::basic_ostream
& operator<<(std::basic_ostream
& os, linear_feedback_shift x) { os << x.value; return os; } template
friend std::basic_istream
& operator>>(std::basic_istream
& is, linear_feedback_shift& x) { is >> x.value; return is; } #endif friend bool operator==(linear_feedback_shift x, linear_feedback_shift y) { return x.value == y.value; } friend bool operator!=(linear_feedback_shift x, linear_feedback_shift y) { return !(x == y); } #else // Use a member function; Streamable concept not supported. bool operator==(linear_feedback_shift rhs) const { return value == rhs.value; } bool operator!=(linear_feedback_shift rhs) const { return !(*this == rhs); } #endif private: UIntType wordmask; // avoid "left shift count >= width of type" warnings UIntType value; }; #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION // A definition is required even for integral static constants template
const bool linear_feedback_shift
::has_fixed_range; template
const int linear_feedback_shift
::word_size; template
const int linear_feedback_shift
::exponent1; template
const int linear_feedback_shift
::exponent2; template
const int linear_feedback_shift
::step_size; #endif } // namespace random } // namespace boost #endif // BOOST_RANDOM_LINEAR_FEEDBACK_SHIFT_HPP
linear_feedback_shift.hpp
网页地址
文件地址
上一页
12/28
下一页
下载
( 5 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.