std::independent_bits_engine<Engine,W,UIntType>:: independent_bits_engine
From cppreference.net
<
cpp
|
numeric
|
random
|
independent bits engine
C++
Numerics library
| Common mathematical functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mathematical special functions (C++17) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mathematical constants (C++20) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Basic linear algebra algorithms (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Data-parallel types (SIMD) (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Floating-point environment (C++11) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Complex numbers | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Numeric array (
valarray
)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Pseudo-random number generation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bit manipulation (C++20) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Saturation arithmetic (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Factor operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Interpolations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Generic numeric operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| C-style checked integer arithmetic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Pseudo-random number generation
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::independent_bits_engine
| Member functions | ||||
|
independent_bits_engine::independent_bits_engine
|
||||
| Generation | ||||
| Characteristics | ||||
| Non-member functions | ||||
|
(C++11)
(C++11)
(until C++20)
|
||||
|
(C++11)
(C++11)
|
|
independent_bits_engine
(
)
;
|
(1) | (C++11부터) |
|
explicit
independent_bits_engine
(
result_type s
)
;
|
(2) | (C++11부터) |
|
template
<
class
SeedSeq
>
explicit independent_bits_engine ( SeedSeq & seq ) ; |
(3) | (C++11부터) |
|
explicit
independent_bits_engine
(
const
Engine
&
e
)
;
|
(4) | (C++11부터) |
|
explicit
independent_bits_engine
(
Engine
&&
e
)
;
|
(5) | (C++11부터) |
새로운 의사 난수 엔진 어댑터를 생성합니다.
1)
기본 생성자. 내부 엔진도 기본 생성됩니다.
2)
기본 엔진을
s
로 구성합니다.
3)
기본 엔진을 시드 시퀀스
seq
로 구성합니다.
4)
기본 엔진을
e
의 사본으로 구성합니다.
5)
기본 엔진을
e
로 이동 생성합니다.
e
는 이후에 지정되지 않았지만 유효한 상태를 유지합니다.
목차 |
매개변수
| s | - | 기본 엔진을 구성하는 데 사용되는 정수 값 |
| seq | - | 기본 엔진을 구성하는 데 사용되는 시드 시퀀스 |
| e | - | 초기화에 사용되는 의사 난수 엔진 |
예외
예제
이 코드 실행
#include <iostream> #include <random> int main() { auto print = [](auto rem, auto engine, int count) { std::cout << rem << ": "; for (int i {}; i != count; ++i) std::cout << static_cast<unsigned>(engine()) << ' '; std::cout << '\n'; }; std::independent_bits_engine<std::mt19937, /*bits*/ 1, unsigned short> e1; // 기본 생성 print("e1", e1, 8); std::independent_bits_engine<std::mt19937, /*bits*/ 1, unsigned int> e2(1); // 1로 생성 print("e2", e2, 8); std::random_device rd; std::independent_bits_engine<std::mt19937, /*bits*/ 3, unsigned long> e3(rd()); // rd()로 시드 설정 print("e3", e3, 8); std::seed_seq s {3, 1, 4, 1, 5}; std::independent_bits_engine<std::mt19937, /*bits*/ 3, unsigned long long> e4(s); // 시드 시퀀스 s로 시드 설정 print("e4", e4, 8); }
가능한 출력:
e1: 0 0 0 1 0 1 1 1 e2: 1 1 0 0 1 1 1 1 e3: 3 1 5 4 3 2 3 4 e4: 0 2 4 4 4 3 3 6
결함 보고서
다음 동작 변경 결함 보고서는 이전에 발표된 C++ 표준에 소급 적용되었습니다.
| DR | 적용 대상 | 게시된 동작 | 올바른 동작 |
|---|---|---|---|
| LWG 2181 | C++11 |
오버로드
(
3
)
는
seq.generate
호출이 예외를 던져도 예외를 던지지 않음
|
예외를 전파함 |