thrust/random/xor_combine_engine.h
File members: thrust/random/xor_combine_engine.h
/*
* Copyright 2008-2013 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <thrust/detail/config.h>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
# pragma GCC system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
# pragma clang system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
# pragma system_header
#endif // no system header
#include <thrust/detail/type_traits.h>
#include <thrust/random/detail/random_core_access.h>
#include <thrust/random/detail/xor_combine_engine_max.h>
#include <cstddef> // for size_t
#include <iostream>
THRUST_NAMESPACE_BEGIN
namespace random
{
template <typename Engine1, size_t s1, typename Engine2, size_t s2 = 0u>
class xor_combine_engine
{
public:
// types
using base1_type = Engine1;
using base2_type = Engine2;
using result_type = typename thrust::detail::eval_if<
(sizeof(typename base2_type::result_type) > sizeof(typename base1_type::result_type)),
thrust::detail::identity_<typename base2_type::result_type>,
thrust::detail::identity_<typename base1_type::result_type>>::type;
static const size_t shift1 = s1;
static const size_t shift2 = s2;
static const result_type min = 0;
static const result_type max = detail::xor_combine_engine_max<Engine1, s1, Engine2, s2, result_type>::value;
// constructors and seeding functions
_CCCL_HOST_DEVICE xor_combine_engine();
_CCCL_HOST_DEVICE xor_combine_engine(const base1_type& urng1, const base2_type& urng2);
_CCCL_HOST_DEVICE xor_combine_engine(result_type s);
_CCCL_HOST_DEVICE void seed();
_CCCL_HOST_DEVICE void seed(result_type s);
// generating functions
_CCCL_HOST_DEVICE result_type operator()(void);
_CCCL_HOST_DEVICE void discard(unsigned long long z);
// property functions
_CCCL_HOST_DEVICE const base1_type& base1() const;
_CCCL_HOST_DEVICE const base2_type& base2() const;
private:
base1_type m_b1;
base2_type m_b2;
friend struct thrust::random::detail::random_core_access;
_CCCL_HOST_DEVICE bool equal(const xor_combine_engine& rhs) const;
template <typename CharT, typename Traits>
std::basic_istream<CharT, Traits>& stream_in(std::basic_istream<CharT, Traits>& is);
template <typename CharT, typename Traits>
std::basic_ostream<CharT, Traits>& stream_out(std::basic_ostream<CharT, Traits>& os) const;
}; // end xor_combine_engine
template <typename Engine1_, size_t s1_, typename Engine2_, size_t s2_>
_CCCL_HOST_DEVICE bool operator==(const xor_combine_engine<Engine1_, s1_, Engine2_, s2_>& lhs,
const xor_combine_engine<Engine1_, s1_, Engine2_, s2_>& rhs);
template <typename Engine1_, size_t s1_, typename Engine2_, size_t s2_>
_CCCL_HOST_DEVICE bool operator!=(const xor_combine_engine<Engine1_, s1_, Engine2_, s2_>& lhs,
const xor_combine_engine<Engine1_, s1_, Engine2_, s2_>& rhs);
template <typename Engine1_, size_t s1_, typename Engine2_, size_t s2_, typename CharT, typename Traits>
std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os, const xor_combine_engine<Engine1_, s1_, Engine2_, s2_>& e);
template <typename Engine1_, size_t s1_, typename Engine2_, size_t s2_, typename CharT, typename Traits>
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, xor_combine_engine<Engine1_, s1_, Engine2_, s2_>& e);
} // namespace random
// import names into thrust::
using random::xor_combine_engine;
THRUST_NAMESPACE_END
#include <thrust/random/detail/xor_combine_engine.inl>