Main circuit class. More...
Public Types | |
typedef boost::transform_iterator < filter_circuit, gate::vector::iterator > | iterator |
Mutable iterator for accessing the gates in a circuit. | |
typedef boost::transform_iterator < const_filter_circuit, gate::vector::const_iterator > | const_iterator |
Constant iterator for accessing the gates in a circuit. | |
typedef boost::transform_iterator < filter_circuit, gate::vector::reverse_iterator > | reverse_iterator |
Mutable reverse iterator for accessing the gates in a circuit. | |
typedef boost::transform_iterator < const_filter_circuit, gate::vector::const_reverse_iterator > | const_reverse_iterator |
Constant reverse iterator for accessing the gates in a circuit. | |
Public Member Functions | |
circuit () | |
Default constructor. | |
circuit (const standard_circuit &std_circ) | |
Cast Constructor for a standard_circuit. | |
circuit (standard_circuit &std_circ) | |
Cast Constructor for a standard_circuit. | |
circuit (const subcircuit &sub_circ) | |
Cast Constructor for a subcircuit. | |
circuit (subcircuit &sub_circ) | |
Cast Constructor for a subcircuit. | |
unsigned | num_gates () const |
Returns the number of gates. | |
void | set_lines (unsigned lines) |
Sets the number of line. | |
unsigned | lines () const |
Returns the number of lines. | |
const_iterator | begin () const |
Constant begin iterator pointing to gates. | |
const_iterator | end () const |
Constant end iterator pointing to gates. | |
iterator | begin () |
Mutable begin iterator pointing to gates. | |
iterator | end () |
Mutable end iterator pointing to gates. | |
const_reverse_iterator | rbegin () const |
Constant begin reverse iterator pointing to gates. | |
const_reverse_iterator | rend () const |
Constant end reverse iterator pointing to gates. | |
reverse_iterator | rbegin () |
Mutable begin reverse iterator pointing to gates. | |
reverse_iterator | rend () |
Mutable end reverse iterator pointing to gates. | |
gate & | append_gate () |
Inserts a gate at the end of the circuit. | |
gate & | prepend_gate () |
Inserts a gate at the beginning of the circuit. | |
gate & | insert_gate (unsigned pos) |
Inserts a gate into the circuit. | |
void | remove_gate_at (unsigned pos) |
Removes a gate at a given index. | |
void | set_inputs (const std::vector< std::string > &inputs) |
Sets the input names of the lines in a circuit. | |
const std::vector< std::string > & | inputs () const |
Returns the input names of the lines in a circuit. | |
void | set_outputs (const std::vector< std::string > &outputs) |
Sets the output names of the lines in a circuit. | |
const std::vector< std::string > & | outputs () const |
Returns the output names of the lines in a circuit. | |
void | set_constants (const std::vector< constant > &constants) |
Sets the constant input line specifications. | |
const std::vector< constant > & | constants () const |
Returns the constant input line specification. | |
void | set_garbage (const std::vector< bool > &garbage) |
Sets whether outputs are garbage or not. | |
const std::vector< bool > & | garbage () const |
Returns whether outputs are garbage or not. | |
void | set_circuit_name (const std::string &name) |
Sets a name of the circuit. | |
const std::string & | circuit_name () const |
Returns the name of the circuit. | |
bool | is_subcircuit () const |
Returns whether the circuit is a sub-circuit or not. | |
std::pair< unsigned, std::vector< unsigned > > | filter () const |
Returns the filter of a sub-circuit. | |
unsigned | offset () const |
Returns the offset of the circuit (sub-circuit). |
Main circuit class.
This class represents a circuit and can be used generically for standard circuits and sub circuits.
circuit | ( | ) | [inline] |
Default constructor.
This constructor initializes a standard_circuit with 0 lines, also called an empty circuit. Empty circuits are usually used as parameters for parsing functions, optimization algorithms, etc.
circuit | ( | const standard_circuit & | std_circ | ) | [inline] |
Cast Constructor for a standard_circuit.
With this constructor the standard_circuit constructor is automatically converted to a circuit, e.g. by calling
circuit circ( 3 );
a circuit with 3 lines is created.
std_circ | standard_circuit implementation |
circuit | ( | standard_circuit & | std_circ | ) | [inline] |
Cast Constructor for a standard_circuit.
With this constructor the standard_circuit constructor is automatically converted to a circuit, e.g. by calling
circuit circ( 3 );
a circuit with 3 lines is created.
std_circ | standard_circuit implementation |
circuit | ( | const subcircuit & | sub_circ | ) | [inline] |
Cast Constructor for a subcircuit.
This constructor is used, so that subcircuits are detected as circuits in algorithms and can passed as circuit parameter to other functions and algorithms.
sub_circ | subcircuit implementation |
circuit | ( | subcircuit & | sub_circ | ) | [inline] |
Cast Constructor for a subcircuit.
This constructor is used, so that subcircuits are detected as circuits in algorithms and can passed as circuit parameter to other functions and algorithms.
sub_circ | subcircuit implementation |
gate& append_gate | ( | ) |
Inserts a gate at the end of the circuit.
This method inserts a gate at the end of the circuit.
iterator begin | ( | ) |
Mutable begin iterator pointing to gates.
const_iterator begin | ( | ) | const |
Constant begin iterator pointing to gates.
const std::string& circuit_name | ( | ) | const |
Returns the name of the circuit.
Returns the name of the circuit which is empty initially.
const std::vector<constant>& constants | ( | ) | const |
Returns the constant input line specification.
This method returns the constant input line specification.
iterator end | ( | ) |
Mutable end iterator pointing to gates.
const_iterator end | ( | ) | const |
Constant end iterator pointing to gates.
std::pair<unsigned, std::vector<unsigned> > filter | ( | ) | const |
Returns the filter of a sub-circuit.
This method returns a pair (l, f). In case the circuit is sub-circuit restricted on the lines, l is the original number of lines of the base circuit and f is the filter, i.e. a vector of lines which are used for the sub-circuit. In other cases s is always 0 and f is empty.
const std::vector<bool>& garbage | ( | ) | const |
Returns whether outputs are garbage or not.
This method returns the garbage line specification.
const std::vector<std::string>& inputs | ( | ) | const |
Returns the input names of the lines in a circuit.
This method returns the input names of the lines in a circuit. This is useful for functions when writing them to a file, printing them, or creating images.
gate& insert_gate | ( | unsigned | pos | ) |
Inserts a gate into the circuit.
This method inserts a gate at an arbitrary position in the circuit
pos | Position where to insert the gate |
bool is_subcircuit | ( | ) | const |
Returns whether the circuit is a sub-circuit or not.
Both standard_circuit and subcircuit are used in the context as a circuit in other algorithms. To determine what kind of circuit it is, this method returns true
if the circuit is a sub-circuit, false
otherwise.
false
otherwiseunsigned lines | ( | ) | const |
Returns the number of lines.
This method returns the number of lines.
unsigned num_gates | ( | ) | const |
Returns the number of gates.
This method returns the number of gates in the circuit.
unsigned offset | ( | ) | const |
Returns the offset of the circuit (sub-circuit).
For a standard_circuit, the offset is always 0, but for a sub-circuit, the offset is the index of the starting gate in respect to its base circuit.
const std::vector<std::string>& outputs | ( | ) | const |
Returns the output names of the lines in a circuit.
This method returns the output names of the lines in a circuit. This is useful for functions when writing them to a file, printing them, or creating images.
gate& prepend_gate | ( | ) |
Inserts a gate at the beginning of the circuit.
This method inserts a gate at the beginning of the circuit.
reverse_iterator rbegin | ( | ) |
Mutable begin reverse iterator pointing to gates.
const_reverse_iterator rbegin | ( | ) | const |
Constant begin reverse iterator pointing to gates.
void remove_gate_at | ( | unsigned | pos | ) |
Removes a gate at a given index.
If the index is not valid, no gate is removed.
pos | Index |
reverse_iterator rend | ( | ) |
Mutable end reverse iterator pointing to gates.
const_reverse_iterator rend | ( | ) | const |
Constant end reverse iterator pointing to gates.
void set_circuit_name | ( | const std::string & | name | ) |
Sets a name of the circuit.
Sets a name for the circuit which is empty initially.
name | Name |
void set_constants | ( | const std::vector< constant > & | constants | ) |
Sets the constant input line specifications.
This method sets the constant input line specification.
Lines are by default not constant. If less values are given than lines exist, the last ones will be not constant. If more values are given than lines exist, they will be truncated.
constants | Constant Lines |
void set_garbage | ( | const std::vector< bool > & | garbage | ) |
Sets whether outputs are garbage or not.
If an output is garbage it means, that the resulting output value is not necessary for the function.
Lines are by default not garbage. If less values are given than lines exist, the last ones will be not garbage. If more values are given than lines exist, they will be truncated.
garbage | Garbage line specification |
void set_inputs | ( | const std::vector< std::string > & | inputs | ) |
Sets the input names of the lines in a circuit.
This method sets the input names of the lines in a circuit. This is useful for functions when writing them to a file, printing them, or creating images.
inputs | Input names |
void set_lines | ( | unsigned | lines | ) |
Sets the number of line.
This method sets the number of lines of the circuit.
Changing this number will not affect the data in the gates. For example: If there is a gate with a control on line 3, and the number of lines is reduced to 2 in the circuit, then the control is still on line 3 but not visible in this circuit.
So, changing the lines after already adding gates can lead to invalid gates.
lines | Number of lines |
void set_outputs | ( | const std::vector< std::string > & | outputs | ) |
Sets the output names of the lines in a circuit.
This method sets the output names of the lines in a circuit. This is useful for functions when writing them to a file, printing them, or creating images.
outputs | Output names |