本文整理汇总了C++中BitVector::concat方法的典型用法代码示例。如果您正苦于以下问题:C++ BitVector::concat方法的具体用法?C++ BitVector::concat怎么用?C++ BitVector::concat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitVector
的用法示例。
在下文中一共展示了BitVector::concat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pickFpBiased
FloatingPoint Sampler::pickFpBiased(unsigned e, unsigned s)
{
// The biased generation of random FP values is inspired by
// PyMPF [0].
//
// [0] https://github.com/florianschanda/PyMPF
Random& rnd = Random::getRandom();
BitVector zero(1);
BitVector one(1, static_cast<unsigned int>(1));
BitVector sign(1);
BitVector exp(e);
BitVector sig(s - 1);
if (rnd.pickWithProb(probSpecial))
{
// Generate special values
uint64_t type = rnd.pick(0, 12);
switch (type)
{
// NaN
// sign = 1, exp = 11...11, sig = 11...11
case 0:
sign = one;
exp = BitVector::mkOnes(e);
sig = BitVector::mkOnes(s - 1);
break;
// +/- inf
// sign = x, exp = 11...11, sig = 00...00
case 1:
sign = one;
// Intentional fall-through
case 2: exp = BitVector::mkOnes(e); break;
// +/- zero
// sign = x, exp = 00...00, sig = 00...00
case 3:
sign = one;
// Intentional fall-through
case 4: break;
// +/- max subnormal
// sign = x, exp = 00...00, sig = 11...11
case 5:
sign = one;
// Intentional fall-through
case 6: sig = BitVector::mkOnes(s - 1); break;
// +/- min subnormal
// sign = x, exp = 00...00, sig = 00...01
case 7:
sign = one;
// Intentional fall-through
case 8: sig = BitVector(s - 1, static_cast<unsigned int>(1)); break;
// +/- max normal
// sign = x, exp = 11...10, sig = 11...11
case 9:
sign = one;
// Intentional fall-through
case 10:
exp = BitVector::mkOnes(e) - BitVector(e, static_cast<unsigned int>(1));
sig = BitVector::mkOnes(s - 1);
break;
// +/- min normal
// sign = x, exp = 00...01, sig = 00...00
case 11:
sign = one;
// Intentional fall-through
case 12: exp = BitVector(e, static_cast<unsigned int>(1)); break;
default: Unreachable();
}
}
else
{
// Generate normal and subnormal values
// 50% chance of positive/negative sign
if (rnd.pickWithProb(0.5))
{
sign = one;
}
uint64_t pattern = rnd.pick(0, 5);
switch (pattern)
{
case 0:
// sign = x, exp = xx...x0, sig = 11...11
exp = pickBvUniform(e - 1).concat(zero);
sig = BitVector::mkOnes(s - 1);
break;
case 1:
// sign = x, exp = xx...x0, sig = 00...00
//.........这里部分代码省略.........