A gate simulation implementation of gate_simulation_func. More...
Public Member Functions | |
boost::dynamic_bitset & | operator() (const gate &g, boost::dynamic_bitset<> &input) const |
Simulation for a single gate g . |
A gate simulation implementation of gate_simulation_func.
This functor performs simulation on a boost::dynamic_bitset<> for Toffoli, Fredkin, and Peres gates for binary values only.
When adding new simulation functors, you can make use of this one, for example when extending the gate library. Note, that you do not have to derive from this class for this purpose, but can use the following:
// somewhere a new target tag struct my_gate_tag {}; bool is_my_gate( const gate& g ) { return is_type<my_gate>( g.type() ); } // ... // extend simulation struct extended_gate_simulation { boost::dynamic_bitset<>& operator()( const gate& g, boost::dynamic_bitset<>& input ) const { if ( is_my_gate( g ) { // change input according to the semantics of the new gate type // ... // and return it finally return input; } else { // it is a core gate return core_simulation( g, input ); } } private: core_gate_simulation core_simulation; }; // use it somewhere circuit circ( ... ); // some circuit with my_gate gates boost::dynamic_bitset<> output; boost::dynamic_bitset<> input( 4, 10 ); // value 1010 properties::ptr settings( new properties() ); settings.set( "gate_simulation", extended_gate_simulation() ); simple_simulation( output, circ, input, settings );
boost::dynamic_bitset& operator() | ( | const gate & | g, | |
boost::dynamic_bitset<> & | input | |||
) | const |
Simulation for a single gate g
.
This operator performs simulation for a single gate and is called by simple_simulation.
Important: The return value always has to be input
, and the operator should modify input
directly.
g | The gate to be simulated | |
input | An input pattern |
input