Aspect Ratio Iterator
Header: fiction/algorithms/iter/aspect_ratio_iterator.hpp
-
template<typename AspectRatio>
class aspect_ratio_iterator An iterator type that iterates over increasingly larger 2D aspect ratios via factorization, starting from a number of faces \(n\). After iterating over all possible factorizations of n, the next step increases \(n\) and continues with the factorization. Thereby, a sequence of aspect ratios starting from \(n = 4\) faces looks like this: \(1 \times 4, 4 \times 1, 2 \times 2, 1 \times 5, 5 \times 1, 1 \times 6, 6 \times 1, 2 \times 3, 3 \times 2, \dots\)
- Template Parameters:
AspectRatio – Aspect ratio type.
Public Functions
-
inline explicit aspect_ratio_iterator(uint64_t n = 0ul) noexcept
Standard constructor. Takes a starting value and computes an initial factorization. The value
n
represents the amount of faces in the desired aspect ratios. For example, \(n = 1\) will yield aspect ratios with exactly \(1\) face, i.e. \(1 \times 1\) which is equal toucoord_t{0, 0}
. If \(n = 2\), the aspect ratios \(1 \times 2\) and \(2 \times 1\) will result, which are equal toucoord_t{0, 1}
anducoord_t{1, 0}
. Both examples withAspectRatio == offset::ucoord_t
.- Parameters:
n – Starting value of the aspect ratio iteration.
-
inline aspect_ratio_iterator &operator++() noexcept
Lets the iterator point to the next dimension of the current factorization. If there are no next factors,
num
is incremented and the next factors are computed.Prefix version.
- Returns:
Reference to this.
-
inline aspect_ratio_iterator operator++(int) noexcept
Creates a new iterator that points to the next dimension of the current factorization. If there are no next factors,
num
is incremented and the next factors are computed.Postfix version. Less performance than the prefix version due to copy construction.
- Returns:
Resulting iterator.
Gray Code Iterator
Header: fiction/algorithms/iter/gray_code_iterator.hpp
-
class gray_code_iterator
An iterator type that iterates over Gray code representations for decimal numbers.
The
gray_code_iterator
class provides an iterator for generating Gray code representations for a range of decimal numbers. It starts from a specified number and produces Gray codes in ascending order based on bitwise XOR operations.Public Functions
-
inline explicit constexpr gray_code_iterator(const uint64_t start) noexcept
Constructs a Gray Code Iterator with a specified starting number.
Constructs a
gray_code_iterator
that generates Gray codes for decimal numbers starting from the givenstart
number.- Parameters:
start – The starting decimal number for the iterator.
-
inline constexpr const uint64_t &operator*() const noexcept
Dereference operator. Returns a reference to the Gray code of the current iteration.
- Returns:
Reference to the current Gray code.
-
inline constexpr gray_code_iterator &operator++() noexcept
Prefix increment operator. Sets the number and the corresponding Gray code.
- Returns:
Reference to
this
.
-
inline constexpr bool operator==(const gray_code_iterator &other) const noexcept
Equality comparison operator. Compares the current iterator with another iterator.
- Parameters:
other – The iterator to compare with.
- Returns:
true
if the current iterator is equal to the other iterator,false
otherwise.
-
inline constexpr bool operator!=(const gray_code_iterator &other) const noexcept
Inequality comparison operator. Compares the current iterator with another iterator.
- Parameters:
other – The iterator to compare with.
- Returns:
true
if the current iterator is not equal to the other iterator,false
otherwise.
-
inline constexpr bool operator<(const gray_code_iterator &other) const noexcept
Less-than comparison operator. Compares the current iterator with another iterator.
- Parameters:
other – The iterator to compare with.
- Returns:
true
if the current iterator is less than the other iterator,false
otherwise.
-
inline constexpr bool operator<=(const gray_code_iterator &other) const noexcept
Less-than or equal-to comparison operator. Compares the current iterator with another iterator.
- Parameters:
other – The iterator to compare with.
- Returns:
true
if the current iterator is less than or equal to the other iterator,false
otherwise.
-
inline constexpr int64_t operator-(const gray_code_iterator &other) const noexcept
Subtraction operator to calculate the difference between two gray_code_iterators.
This operator calculates the difference between the current iterator and another gray_code_iterator provided as input. The result is returned as an int64_t representing the number of positions between the iterators.
- Parameters:
other – The gray_code_iterator to subtract from the current iterator.
- Returns:
The difference between the current iterator and the input iterator as int64_t.
-
inline constexpr gray_code_iterator operator++(int) noexcept
Postfix increment operator. Sets the next Gray Code.
- Returns:
Copy of
this
before incrementing.
-
inline constexpr gray_code_iterator operator+(const int m) const noexcept
Addition operator. Computes the Gray code of the current iterator plus the given integer.
- Parameters:
m – The amount of Gray codes to skip.
- Returns:
Iterator of the current iterator plus the given integer.
-
inline constexpr gray_code_iterator &operator+=(const int m) noexcept
Addition assignment operator. Iterator is increased by given number.
- Parameters:
m – The amount of Gray codes to skip.
- Returns:
Reference to
this
.
-
inline constexpr gray_code_iterator operator-(const int m) const noexcept
Subtraction operator. Computes the Gray code of the current iterator minus the given integer.
- Parameters:
m – The amount of Gray codes to skip.
- Returns:
Iterator of the current iterator minus the given integer.
-
inline constexpr gray_code_iterator &operator--() noexcept
Prefix decrement operator. Sets the previous Gray code.
- Returns:
Reference to
this
.
-
inline constexpr gray_code_iterator operator--(int) noexcept
Postfix decrement operator. Sets the previous Gray Code.
- Returns:
Copy of
this
before decrementing.
-
inline constexpr gray_code_iterator &operator-=(const int m) noexcept
Subtraction assignment operator. Sets a previous Gray code.
- Parameters:
m – The amount of Gray codes to skip.
- Returns:
Reference to
this
.
-
inline constexpr gray_code_iterator &operator=(const uint64_t m) noexcept
Assignment operator. Sets the current number to the given integer.
- Parameters:
m – The number to set.
-
inline constexpr uint64_t operator[](std::size_t index) const noexcept
Subscript operator. Returns the Gray code at a specific position in the iteration range.
- Parameters:
index – The position in the iteration range.
- Returns:
The Gray code at the specified position.
-
inline constexpr bool operator==(const uint64_t m) const noexcept
Equality operator. Compares the current number with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current number is equal tom
,false
otherwise.
-
inline constexpr bool operator!=(const uint64_t m) const noexcept
Inequality operator. Compares the current number with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current number is not equal tom
,false
otherwise.
-
inline constexpr bool operator<(const uint64_t m) const noexcept
Less-than operator. Compares the current number with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current number is less thanm
,false
otherwise.
-
inline constexpr bool operator<=(const uint64_t m) const noexcept
Less-or-equal-than operator. Compares the current number with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current number is less than or equal tom
,false
otherwise.
-
inline constexpr bool operator>(const uint64_t m) const noexcept
Greater-than operator. Compares the current number with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current number is greater thanm
,false
otherwise.
-
inline constexpr bool operator>=(const uint64_t m) const noexcept
Greater-or-equal-than operator. Compares the current number with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current number is greater than or equal tom
,false
otherwise.
-
inline explicit constexpr gray_code_iterator(const uint64_t start) noexcept
BDL Input Iterator
Header: fiction/algorithms/iter/bdl_input_iterator.hpp
-
struct bdl_input_iterator_params
Parameters for the BDL input iterator.
Public Types
-
enum class input_bdl_configuration : uint8_t
This enum defines how BDL inputs are manipulated within the algorithm. According to existing literature, there are two main approaches for handling BDL inputs:
Distance Encoding, in which an input of
1
is generated by placing a perturber closer to the target, whereas a0
is produced by positioning the perturber farther away (as described in https://dl.acm.org/doi/10.1145/3489517.3530525).Absence Encoding, in which a perturber is used to set the input to
1
, while the absence of a perturber represents a0
(as described in https://ieeexplore.ieee.org/abstract/document/8963859).
Values:
-
enumerator PERTURBER_DISTANCE_ENCODED
An input of
1
is generated by placing a perturber closer to the BDL wire, whereas a0
is produced by positioning the perturber farther away (as described in https://dl.acm.org/doi/10.1145/3489517.3530525).
-
enumerator PERTURBER_ABSENCE_ENCODED
A perturber is used to set the input to
1
, while the absence of a perturber represents a0
(as described in https://ieeexplore.ieee.org/abstract/document/8963859).
Public Members
-
detect_bdl_wires_params bdl_wire_params = {}
Parameters to detect BDL wires.
-
input_bdl_configuration input_bdl_config = {input_bdl_configuration::PERTURBER_DISTANCE_ENCODED}
The
input_bdl_config
member allows selection between different modes for handling input BDLs.
-
enum class input_bdl_configuration : uint8_t
-
template<typename Lyt>
class bdl_input_iterator Iterator that iterates over all possible input states of a BDL layout. There are \(2^n\) possible input states for an \(n\)-input BDL layout, each with a unique input index. The input index is interpreted as a binary number, where the \(i\)-th bit represents the input state of the \(i\)-th input BDL pair. If the bit is
1
, the lower BDL dot is set and the upper BDL dot removed. If the bit is0
, the upper BDL dot is removed and the lower BDL dot set. The iterator creates and stores a deep-copy of the given layout. The state enumeration wraps around, i.e., after the last possible input state, the first input state is set again.The iterator satisfies the requirements of
LegacyRandomAccessIterator
and can be used in iterator-basedfor
loops.- Template Parameters:
Lyt – SiDB cell-level layout type.
Public Functions
-
inline explicit bdl_input_iterator(const Lyt &lyt, const bdl_input_iterator_params &ps = bdl_input_iterator_params{}) noexcept
Standard constructor. It alters the layout to set the first input state, which assigns binary
0
to all input BDL pairs.- Parameters:
lyt – The SiDB BDL layout to iterate over.
ps – Parameters for the BDL input iterator.
-
inline explicit bdl_input_iterator(const Lyt &lyt, const bdl_input_iterator_params &ps, const std::vector<bdl_wire<Lyt>> &input_wires) noexcept
Constructor with pre-detected input wires and directions. It alters the layout to set the first input state, which assigns binary
0
to all input BDL pairs.- Parameters:
lyt – The SiDB BDL layout to iterate over.
ps – Parameters for the BDL input iterator.
input_wires – Pre-detected input BDL wires.
-
inline const Lyt &operator*() const noexcept
Dereference operator. Returns a reference to the layout with the current input state.
- Returns:
Reference to the current layout.
-
inline bdl_input_iterator &operator++() noexcept
Prefix increment operator. Sets the next input state.
- Returns:
Reference to
this
.
-
inline bdl_input_iterator operator++(int) noexcept
Postfix increment operator. Sets the next input state.
- Returns:
Copy of
this
before incrementing.
-
inline bdl_input_iterator operator+(const int m) const noexcept
Addition operator. Computes the input state of the current iterator plus the given integer.
- Parameters:
m – The amount of input states to skip.
- Returns:
The input state of the current iterator plus the given integer.
-
inline bdl_input_iterator &operator+=(const int m) noexcept
Addition assignment operator. Sets a next input state.
- Parameters:
m – The amount of input states to skip.
- Returns:
Reference to
this
.
-
inline bdl_input_iterator operator-(const int m) const noexcept
Subtraction operator. Computes the input state of the current iterator minus the given integer.
- Parameters:
m – The amount of input states to skip.
- Returns:
The input state of the current iterator minus the given integer.
-
inline bdl_input_iterator &operator--() noexcept
Prefix decrement operator. Sets the previous input state.
- Returns:
Reference to
this
.
-
inline bdl_input_iterator operator--(int) noexcept
Postfix decrement operator. Sets the previous input state.
- Returns:
Copy of
this
before decrementing.
-
inline bdl_input_iterator &operator-=(const int m) noexcept
Subtraction assignment operator. Sets a previous input state.
- Parameters:
m – The amount of input states to skip.
- Returns:
Reference to
this
.
-
inline bdl_input_iterator &operator=(const uint64_t m) noexcept
Assignment operator. Sets the input state to the given integer.
- Parameters:
m – The input state to set.
-
inline bdl_input_iterator operator[](const int m) const noexcept
Subscript operator. Computes the input state of the current iterator plus the given integer.
- Parameters:
m – The amount of input states to skip.
- Returns:
The input state of the current iterator plus the given integer.
-
inline int64_t operator-(const bdl_input_iterator &other) const noexcept
Subtraction operator. Computes the difference between the current input index and the given iterator ones.
- Parameters:
other – Iterator to compute the difference with.
- Returns:
The difference between the current input index and the given iterator ones.
-
inline bool operator==(const uint64_t m) const noexcept
Equality operator. Compares the current input index with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current input index is equal tom
,false
otherwise.
-
inline bool operator!=(const uint64_t m) const noexcept
Inequality operator. Compares the current input index with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current input index is not equal tom
,false
otherwise.
-
inline bool operator<(const uint64_t m) const noexcept
Less-than operator. Compares the current input index with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current input index is less thanm
,false
otherwise.
-
inline bool operator<=(const uint64_t m) const noexcept
Less-or-equal-than operator. Compares the current input index with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current input index is less than or equal tom
,false
otherwise.
-
inline bool operator>(const uint64_t m) const noexcept
Greater-than operator. Compares the current input index with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current input index is greater thanm
,false
otherwise.
-
inline bool operator>=(const uint64_t m) const noexcept
Greater-or-equal-than operator. Compares the current input index with the given integer.
- Parameters:
m – Integer to compare with.
- Returns:
true
if the current input index is greater than or equal tom
,false
otherwise.
-
inline uint64_t num_input_pairs() const noexcept
Returns the total number of input BDL pairs of the given SiDB gate layout.
- Returns:
The number of input BDL pairs.
-
inline uint64_t get_current_input_index() const noexcept
Returns the current input index.
- Returns:
The current input index.
- class mnt.pyfiction.input_bdl_configuration
Members:
PERTURBER_ABSENCE_ENCODED : A perturber is used to set the input to 1, while the absence of a
perturber represents a 0 (as described in https://ieeexplore.ieee.org/abstract/document/8963859).
PERTURBER_DISTANCE_ENCODED : An input of 1 is generated by placing a perturber closer to the BDL
wire, whereas a 0 is produced by positioning the perturber farther away (as described in https://dl.acm.org/doi/10.1145/3489517.3530525).
- property name
- class mnt.pyfiction.bdl_input_iterator_params
- property bdl_wire_params
Parameters to detect BDL wires.
- property input_bdl_config
The input_bdl_config member allows selection between different modes for handling input BDLs.
- class mnt.pyfiction.bdl_input_iterator_100
Iterator that iterates over all possible input states of a BDL layout. There are \(2^n\) possible input states for an \(n\)-input BDL layout, each with a unique input index. The input index is interpreted as a binary number, where the \(i\)-th bit represents the input state of the \(i\)-th input BDL pair. If the bit is 1, the lower BDL dot is set and the upper BDL dot removed. If the bit is 0, the upper BDL dot is removed and the lower BDL dot set. The iterator creates and stores a deep-copy of the given layout. The state enumeration wraps around, i.e., after the last possible input state, the first input state is set again.
The iterator satisfies the requirements of LegacyRandomAccessIterator and can be used in iterator-based for loops.
- Template parameter
Lyt
: SiDB cell-level layout type.
- get_layout(self: mnt.pyfiction.pyfiction.bdl_input_iterator_100) fiction::sidb_lattice<fiction::sidb_100_lattice, fiction::cell_level_layout<fiction::sidb_technology, fiction::clocked_layout<fiction::tile_based_layout<fiction::cartesian_layout<fiction::offset::ucoord_t> > > >, false>
- num_input_pairs(self: mnt.pyfiction.pyfiction.bdl_input_iterator_100) int
- Template parameter
- class mnt.pyfiction.bdl_input_iterator_111
Iterator that iterates over all possible input states of a BDL layout. There are \(2^n\) possible input states for an \(n\)-input BDL layout, each with a unique input index. The input index is interpreted as a binary number, where the \(i\)-th bit represents the input state of the \(i\)-th input BDL pair. If the bit is 1, the lower BDL dot is set and the upper BDL dot removed. If the bit is 0, the upper BDL dot is removed and the lower BDL dot set. The iterator creates and stores a deep-copy of the given layout. The state enumeration wraps around, i.e., after the last possible input state, the first input state is set again.
The iterator satisfies the requirements of LegacyRandomAccessIterator and can be used in iterator-based for loops.
- Template parameter
Lyt
: SiDB cell-level layout type.
- get_layout(self: mnt.pyfiction.pyfiction.bdl_input_iterator_111) fiction::sidb_lattice<fiction::sidb_111_lattice, fiction::cell_level_layout<fiction::sidb_technology, fiction::clocked_layout<fiction::tile_based_layout<fiction::cartesian_layout<fiction::offset::ucoord_t> > > >, false>
- num_input_pairs(self: mnt.pyfiction.pyfiction.bdl_input_iterator_111) int
- Template parameter