f****n 发帖数: 20 | 1 boost里有这么一个生成正态分布随机数的template.
template
class normal_distribution
{
public:
typedef RealType input_type;
typedef RealType result_type;
explicit normal_distribution(const result_type& mean = 0,
const result_type& sigma = 1);
RealType mean() const;
RealType sigma() const;
void reset();
template
result_type operator()(UniformRandomNumberGenerator& urng);
};
如果想把UniformRandomNumberGenerator指定为lagged_fibon | f****n 发帖数: 20 | 2 主要问题是这个class template有个member是function template,而且template
parameters在两个位置出现,哪位同学给解释一下?多谢 | c********e 发帖数: 383 | 3 there is a thing for function template called template parameter deduction
【在 f****n 的大作中提到】 : 主要问题是这个class template有个member是function template,而且template : parameters在两个位置出现,哪位同学给解释一下?多谢
| t****t 发帖数: 6806 | 4 从prototype看这个class设计思想是这样.
class的参数明显是数据类型,多半不是float就是double
那个operator()的参数是uniform generator class,因为高斯随机数通常是由均匀分布
的随机数变换而来,而uniform的质量有不一样,所以为灵活起见要求你提供一个.
用的时候这样写
normal_distribution n_prng(mean, sigma);
lagged_fibonacci607 u_prng( ... );
double x=n_prng(u_prng);
【在 f****n 的大作中提到】 : boost里有这么一个生成正态分布随机数的template. : template : class normal_distribution : { : public: : typedef RealType input_type; : typedef RealType result_type; : explicit normal_distribution(const result_type& mean = 0, : const result_type& sigma = 1); : RealType mean() const;
| f****n 发帖数: 20 | |
|