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> {
static const size_t value = 0; };
91template <
size_t _Rp>
struct __log2_imp<0, _Rp> {
static const size_t value = _Rp + 1; };
93template <
class _UIntType, _UIntType _Xp>
struct __log2 {
94 static const size_t value = __log2_imp<_Xp,
sizeof(_UIntType) * __CHAR_BIT__ - 1>
::value;
97template <
class _Engine,
class _UIntType>
class __independent_bits_engine {
103 using _Engine_result_type =
typename _Engine::result_type;
105 _Engine_result_type>::type _Working_result_type;
112 _Working_result_type __y0_;
113 _Working_result_type __y1_;
114 _Engine_result_type __mask0_;
115 _Engine_result_type __mask1_;
119#pragma warning(disable : 4307)
121 static constexpr const _Working_result_type _Rp = _Engine::max() - _Engine::min() + _Working_result_type(1);
125 static constexpr const size_t __m = __log2<_Working_result_type, _Rp>::value;
126 static constexpr const size_t _WDt = std::numeric_limits<_Working_result_type>::digits;
127 static constexpr const size_t _EDt = std::numeric_limits<_Engine_result_type>::digits;
131 __independent_bits_engine(_Engine &__e,
size_t __w);
134 result_type operator()() {
return __eval(std::integral_constant<bool, _Rp != 0>()); }
141template <
class _Engine,
class _UIntType>
142__independent_bits_engine<_Engine, _UIntType>::__independent_bits_engine(_Engine &__e,
size_t __w)
143 : __e_(__e), __w_(__w) {
144 __n_ = __w_ / __m + (__w_ % __m != 0);
148 else if (__w0_ < _WDt)
149 __y0_ = (_Rp >> __w0_) << __w0_;
152 if (_Rp - __y0_ > __y0_ / __n_) {
156 __y0_ = (_Rp >> __w0_) << __w0_;
160 __n0_ = __n_ - __w_ % __n_;
161 if (__w0_ < _WDt - 1)
162 __y1_ = (_Rp >> (__w0_ + 1)) << (__w0_ + 1);
165 __mask0_ = __w0_ > 0 ? _Engine_result_type(~0) >> (_EDt - __w0_) : _Engine_result_type(0);
166 __mask1_ = __w0_ < _EDt - 1 ? _Engine_result_type(~0) >> (_EDt - (__w0_ + 1)) : _Engine_result_type(~0);
169template <
class _Engine,
class _UIntType>
170inline _UIntType __independent_bits_engine<_Engine, _UIntType>::__eval(std::false_type) {
171 return static_cast<result_type>(__e_() & __mask0_);
174template <
class _Engine,
class _UIntType>
175_UIntType __independent_bits_engine<_Engine, _UIntType>::__eval(std::true_type) {
176 const size_t _WRt = std::numeric_limits<result_type>::digits;
178 for (
size_t __k = 0; __k < __n0_; ++__k) {
179 _Engine_result_type __u;
181 __u = __e_() - _Engine::min();
182 }
while (__u >= __y0_);
189 for (
size_t __k = __n0_; __k < __n_; ++__k) {
190 _Engine_result_type __u;
192 __u = __e_() - _Engine::min();
193 }
while (__u >= __y1_);
194 if (__w0_ < _WRt - 1)
259 return !(__x == __y);
263template <
class _IntType>
264template <
class _URNG>
267 using _UIntType =
typename std::conditional<
sizeof(
result_type) <=
sizeof(uint32_t), uint32_t, uint64_t>::type;
268 const _UIntType _Rp = __p.
b() - __p.
a() + _UIntType(1);
271 const size_t _Dt = std::numeric_limits<_UIntType>::digits;
272 using _Eng = __independent_bits_engine<_URNG, _UIntType>;
275 size_t __w = _Dt - __clz(_Rp) - 1;
276 if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
282 }
while (__u >= _Rp);
290#undef INLINE_VISIBILITY
291#ifdef _MANTID_CHAR_BIT_DEFINED_HERE
293#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