25#define __CHAR_BIT__ CHAR_BIT
26#define INLINE_VISIBILITY __forceinline
28#define INLINE_VISIBILITY __attribute__((__always_inline__))
39 return static_cast<unsigned>(__builtin_clz(__x));
41 static_assert(
sizeof(unsigned) ==
sizeof(
unsigned long),
"");
42 static_assert(
sizeof(
unsigned long) == 4,
"");
46 if (_BitScanReverse(&where, __x))
54 return static_cast<unsigned long>(__builtin_clzl(__x));
56 static_assert(
sizeof(unsigned) ==
sizeof(
unsigned long),
"");
57 return __clz(
static_cast<unsigned>(__x));
63 return static_cast<unsigned long long>(__builtin_clzll(__x));
68#if defined(_LIBCPP_HAS_BITSCAN64)
69 if (_BitScanReverse64(&where, __x))
70 return static_cast<int>(63 - where);
73 if (_BitScanReverse(&where,
static_cast<unsigned long>(__x >> 32)))
74 return 63 - (where + 32);
76 if (_BitScanReverse(&where,
static_cast<unsigned long>(__x)))
85template <
unsigned long long _Xp,
size_t _Rp>
struct __log2_imp {
86 static const size_t value = _Xp & ((
unsigned long long)(1) << _Rp) ? _Rp : __log2_imp<_Xp, _Rp - 1>
::value;
89template <
unsigned long long _Xp>
struct __log2_imp<_Xp, 0> {
90 static const size_t value = 0;
93template <
size_t _Rp>
struct __log2_imp<0, _Rp> {
94 static const size_t value = _Rp + 1;
97template <
class _UIntType, _UIntType _Xp>
struct __log2 {
98 static const size_t value = __log2_imp<_Xp,
sizeof(_UIntType) * __CHAR_BIT__ - 1>
::value;
101template <
class _Engine,
class _UIntType>
class __independent_bits_engine {
104 using result_type = _UIntType;
107 using _Engine_result_type =
typename _Engine::result_type;
108 typedef typename std::conditional<
sizeof(_Engine_result_type) <=
sizeof(result_type), result_type,
109 _Engine_result_type>::type _Working_result_type;
116 _Working_result_type __y0_;
117 _Working_result_type __y1_;
118 _Engine_result_type __mask0_;
119 _Engine_result_type __mask1_;
123#pragma warning(disable : 4307)
125 static constexpr const _Working_result_type _Rp = _Engine::max() - _Engine::min() + _Working_result_type(1);
129 static constexpr const size_t __m = __log2<_Working_result_type, _Rp>::value;
130 static constexpr const size_t _WDt = std::numeric_limits<_Working_result_type>::digits;
131 static constexpr const size_t _EDt = std::numeric_limits<_Engine_result_type>::digits;
135 __independent_bits_engine(_Engine &__e,
size_t __w);
138 result_type operator()() {
return __eval(std::integral_constant<bool, _Rp != 0>()); }
141 result_type __eval(std::false_type);
142 result_type __eval(std::true_type);
145template <
class _Engine,
class _UIntType>
146__independent_bits_engine<_Engine, _UIntType>::__independent_bits_engine(_Engine &__e,
size_t __w)
147 : __e_(__e), __w_(__w) {
148 __n_ = __w_ / __m + (__w_ % __m != 0);
152 else if (__w0_ < _WDt)
153 __y0_ = (_Rp >> __w0_) << __w0_;
156 if (_Rp - __y0_ > __y0_ / __n_) {
160 __y0_ = (_Rp >> __w0_) << __w0_;
164 __n0_ = __n_ - __w_ % __n_;
165 if (__w0_ < _WDt - 1)
166 __y1_ = (_Rp >> (__w0_ + 1)) << (__w0_ + 1);
169 __mask0_ = __w0_ > 0 ? _Engine_result_type(~0) >> (_EDt - __w0_) : _Engine_result_type(0);
170 __mask1_ = __w0_ < _EDt - 1 ? _Engine_result_type(~0) >> (_EDt - (__w0_ + 1)) : _Engine_result_type(~0);
173template <
class _Engine,
class _UIntType>
174inline _UIntType __independent_bits_engine<_Engine, _UIntType>::__eval(std::false_type) {
175 return static_cast<result_type
>(__e_() & __mask0_);
178template <
class _Engine,
class _UIntType>
179_UIntType __independent_bits_engine<_Engine, _UIntType>::__eval(std::true_type) {
180 const size_t _WRt = std::numeric_limits<result_type>::digits;
182 for (
size_t __k = 0; __k < __n0_; ++__k) {
183 _Engine_result_type __u;
185 __u = __e_() - _Engine::min();
186 }
while (__u >= __y0_);
191 _Sp +=
static_cast<result_type
>(__u & __mask0_);
193 for (
size_t __k = __n0_; __k < __n_; ++__k) {
194 _Engine_result_type __u;
196 __u = __e_() - _Engine::min();
197 }
while (__u >= __y1_);
198 if (__w0_ < _WRt - 1)
202 _Sp +=
static_cast<result_type
>(__u & __mask1_);
263 return !(__x == __y);
267template <
class _IntType>
268template <
class _URNG>
271 using _UIntType =
typename std::conditional<
sizeof(
result_type) <=
sizeof(uint32_t), uint32_t, uint64_t>::type;
272 const _UIntType _Rp = __p.
b() - __p.
a() + _UIntType(1);
275 const size_t _Dt = std::numeric_limits<_UIntType>::digits;
276 using _Eng = __independent_bits_engine<_URNG, _UIntType>;
279 size_t __w = _Dt - __clz(_Rp) - 1;
280 if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
286 }
while (__u >= _Rp);
294#undef INLINE_VISIBILITY
295#ifdef _MANTID_CHAR_BIT_DEFINED_HERE
297#undef _MANTID_CHAR_BIT_DEFINED_HERE
double value
The value of the point.
Helper class which provides the Collimation Length for SANS instruments.
#define INLINE_VISIBILITY