TruthTable class
#include <TruthTable.hpp>
Contents
Constructors, destructors, conversion operators
- TruthTable()
- TruthTable(uint_fast32_t seed)
- TruthTable(TruthTable&& other) defaulted
- TruthTable(int32_t i_input, int32_t i_output, const std::vector<std::vector<bool>>& i_array = {})
- TruthTable(const TruthTable& i_tt, std::vector<std::vector<bool>> i_array = {})
- TruthTable(int32_t i_input, int32_t i_output, double i_p = 0.5)
Public functions
- auto operator=(const TruthTable& other) -> TruthTable& defaulted
- auto operator=(TruthTable&& other) -> TruthTable& defaulted
- void setSeed(uint_fast32_t i_seed)
- setSeed Set the seed for random number generation.
- void generateRandom(TruthTableParameters i_gp)
- generateTable The method generates a truth table for a combinational circuit with a given probability i_p for each output value.
- void generateTable(double i_p = 0)
- generateTable Generate a truth table with specified probability.
- auto getInput() const -> int32_t
- getInput Get the number of input variables in the truth table.
- auto getOutput() const -> int32_t
- getOutput Get the number of output variables in the truth table
- auto size() const -> int32_t
- size Get the size of the truth table.
- auto getOutTable() const -> std::vector<std::vector<bool>>
- getOutTable Get the output table.
- auto getOutTable(int32_t i, int32_t j) const -> bool
- getOutTable Get the truth value at a specific position in the output table.
- auto convToBinary() const -> std::vector<std::vector<bool>>
- convToBinary Convert truth table indices to binary representation This method converts the indices of the truth table into binary representation.
- void printTable() const
- printTable Print the truth table.
- auto operator==(const TruthTable& r) const -> bool
Function documentation
void CG_Gen:: TruthTable:: setSeed(uint_fast32_t i_seed)
setSeed Set the seed for random number generation.
| Parameters | |
|---|---|
| i_seed | The seed for random number generation. |
This method sets the seed for the random number generator used in generating the truth table. Setting the seed allows for reproducible random number sequences.
void CG_Gen:: TruthTable:: generateTable(double i_p = 0)
generateTable Generate a truth table with specified probability.
| Parameters | |
|---|---|
| i_p | The probability of generating a true value for each cell in the truth table. |
This method generates a truth table with the given probability 'i_p". If i_p is greater than 0 and less than or equal to 1.
int32_t CG_Gen:: TruthTable:: getInput() const
getInput Get the number of input variables in the truth table.
| Returns | The number of input variables. |
|---|
int32_t CG_Gen:: TruthTable:: getOutput() const
getOutput Get the number of output variables in the truth table
| Returns | The number of output variables. |
|---|
int32_t CG_Gen:: TruthTable:: size() const
size Get the size of the truth table.
| Returns | The size of the truth table (number of rows). |
|---|
This method returns the total number of rows in the truth table. Each rows corresponds to a unique combination of input values
std::vector<std::vector<bool>> CG_Gen:: TruthTable:: getOutTable() const
getOutTable Get the output table.
| Returns | The output table as a two-dimensional vector of boolean values. |
|---|
This method returns a copy of the entire output table of the truth table. The output table contains the truth values for each combination of input variables.
bool CG_Gen:: TruthTable:: getOutTable(int32_t i,
int32_t j) const
getOutTable Get the truth value at a specific position in the output table.
| Parameters | |
|---|---|
| i | The row index of the output table. |
| j | |
| Returns | The truth value at the specified position. |
This method returns the truth value at the specified position (i, j) in the output table. The position (i, j) corresponds to the i-th row and j-th column of the output table, representing a specific combination of input variables.
std::vector<std::vector<bool>> CG_Gen:: TruthTable:: convToBinary() const
convToBinary Convert truth table indices to binary representation This method converts the indices of the truth table into binary representation.
| Returns | A two-dimensional vector representing the binary representation of each row index in the truth table. |
|---|
Each row index of the truth table corresponds to a unique combination of input variables, which is represented in binary form. For example, if the number of input variables is 3, the binary representation of the row index 5 (101 in binary) corresponds to the input combination [true, false, true].
void CG_Gen:: TruthTable:: printTable() const
printTable Print the truth table.
This method prints the entire truth table to the standard output stream. Each row of the truth table is printed as a space-separated sequence of boolean values. After printing the table, a newline character is inserted to separate rows.