本文整理汇总了C++中Rand::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Rand::get方法的具体用法?C++ Rand::get怎么用?C++ Rand::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rand
的用法示例。
在下文中一共展示了Rand::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: choose
int choose(Rand& rand) const {
const size_t v = rand.get(totalRatio);
for (size_t i = 0; i < TYPE_MAX; i++) {
if (v < ratio[i]) return i;
}
throw cybozu::Exception("must not reach here.");
}
示例2: rest
bool rest( const Int entrpy, const Rand& rand0to12 )
{
Int r = rand0to12.get();
switch ( entrpy )
{
case 0:
return r > 10;
break;
case 1:
return r > 10;
break;
case 2:
return r > 10;
break;
case 3:
return r > 9;
break;
case 4:
return r > 9;
break;
case 5:
return r > 8;
break;
case 6:
return r > 8;
break;
case 7:
return r > 8;
break;
case 8:
return r > 7;
break;
case 9:
return r > 7;
break;
case 10:
return r > 6;
break;
case 11:
return r > 6;
break;
case 12:
return r > 5;
break;
default:
break;
}
return false;
}
示例3: make_MT
DenseMtx Precode_Matrix::make_MT() const
{
// rfc 6330, pg 24
Rand rnd;
DenseMtx MT = DenseMtx (_params.H, _params.K_padded + _params.S);
for (uint16_t row = 0; row < MT.rows(); ++row) {
uint16_t col;
for (col = 0; col < MT.cols() - 1; ++col) {
auto tmp = rnd.get (col + 1, 6, _params.H);
if ((row == tmp) || (row ==
(tmp + rnd.get (col + 1, 7, _params.H - 1) + 1)
% _params.H)) {
MT (row, col) = 1;
} else {
MT (row, col) = 0;
}
}
// last column: alpha ^^ i, as in rfc6330
MT (row, col) = RaptorQ::Impl::oct_exp[row];
}
return MT;
}
示例4: srand
void Gauss::srand(void)
{
static Rand rand;
Rand::setSeed( rand.get() ); // randomize
}