EcGen
1.1.8
Loading...
Searching...
No Matches
gray_code.hpp
Go to the documentation of this file.
1
5
6
#pragma once
7
8
#include <py2cpp/gen.hpp>
9
#include <py2cpp/recursive_gen.hpp>
10
11
namespace
ecgen
{
47
extern
auto
brgc_gen
(
int
n) -> py::RecursiveGenerator<int>;
48
74
template
<
typename
Container>
auto
brgc
(
int
n) -> py::Generator<Container&> {
75
auto
lst = Container(
static_cast<
typename Container::size_type
>
(n), 0);
76
co_yield
lst;
77
for
(
const
int
idx :
brgc_gen
(n)) {
78
lst[
static_cast<
typename Container::size_type
>
(idx)]
79
= 1 - lst[
static_cast<
typename Container::size_type
>
(idx)];
// flip
80
co_yield
lst;
81
}
82
}
83
}
// namespace ecgen
ecgen
Definition
combin.hpp:13
ecgen::brgc_gen
auto brgc_gen(int n) -> py::RecursiveGenerator< int >
Generate recursive Binary Reflected Gray Code sequence.
ecgen::brgc
auto brgc(int n) -> py::Generator< Container & >
Generate Binary Reflected Gray Code (BRGC) sequence using recursion.
Definition
gray_code.hpp:74
ecgen
gray_code.hpp
Generated by
1.15.0