47 OpType type,
unsigned n_i,
unsigned n_io,
unsigned n_o,
48 const std::string &name =
"");
51 unsigned n_qubits()
const override {
return 0; }
55 nlohmann::json
serialize()
const override;
59 std::string
get_name(
bool latex =
false)
const override;
80 std::vector<EdgeType>
sig_;
99 OpType type,
unsigned n_i,
unsigned n_io,
unsigned n_o,
100 const std::string &name =
"");
109 virtual std::vector<bool>
eval(
const std::vector<bool> &x)
const = 0;
114 bool is_equal(
const Op &other)
const override;
136 unsigned n,
const std::vector<uint64_t> &values,
137 const std::string &name =
"ClassicalTransform");
140 const SymEngine::map_basic_basic &)
const override {
141 return std::make_shared<ClassicalTransformOp>(*
this);
144 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
149 const std::vector<uint64_t> values_;
170 unsigned _n,
unsigned _ww_n, std::vector<unsigned> _width_i_parameter,
171 std::vector<unsigned> _width_o_parameter,
const std::string &_func_name,
172 const std::string &_wasm_uid);
175 const SymEngine::map_basic_basic &)
const override {
176 return std::make_shared<WASMOp>(*
this);
187 nlohmann::json
serialize()
const override;
197 bool is_equal(
const Op &other)
const override;
202 unsigned get_n()
const {
return n_; }
219 return width_i_parameter_;
227 return width_o_parameter_;
250 const unsigned ww_n_;
255 const unsigned n_i32_;
260 const std::vector<unsigned> width_i_parameter_;
265 const std::vector<unsigned> width_o_parameter_;
270 const std::string func_name_;
275 const std::string wasm_file_uid_;
293 const SymEngine::map_basic_basic &)
const override {
294 return std::make_shared<SetBitsOp>(*
this);
297 std::string
get_name(
bool latex)
const override;
301 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
304 std::vector<bool> values_;
318 const SymEngine::map_basic_basic &)
const override {
319 return std::make_shared<CopyBitsOp>(*
this);
322 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
359 unsigned n, uint64_t a = 0,
360 uint64_t b = std::numeric_limits<uint64_t>::max())
364 const SymEngine::map_basic_basic &)
const override {
365 return std::make_shared<RangePredicateOp>(*
this);
368 std::string
get_name(
bool latex)
const override;
370 uint64_t
upper()
const {
return b; }
372 uint64_t
lower()
const {
return a; }
374 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
379 bool is_equal(
const Op &other)
const override;
404 unsigned n,
const std::vector<bool> &values,
405 const std::string &name =
"ExplicitPredicate");
408 const SymEngine::map_basic_basic &)
const override {
409 return std::make_shared<ExplicitPredicateOp>(*
this);
412 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
417 const std::vector<bool> values_;
455 unsigned n,
const std::vector<bool> &values,
456 const std::string &name =
"ExplicitModifier");
459 const SymEngine::map_basic_basic &)
const override {
460 return std::make_shared<ExplicitModifierOp>(*
this);
463 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
468 const std::vector<bool> values_;
479 MultiBitOp(std::shared_ptr<const ClassicalEvalOp> op,
unsigned n);
482 const SymEngine::map_basic_basic &)
const override {
483 return std::make_shared<MultiBitOp>(*
this);
486 std::string
get_name(
bool latex)
const override;
488 std::shared_ptr<const ClassicalEvalOp>
get_op()
const {
return op_; }
490 unsigned get_n()
const {
return n_; }
492 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
497 bool is_equal(
const Op &other)
const override;
500 std::shared_ptr<const ClassicalEvalOp> op_;
507std::shared_ptr<ClassicalTransformOp>
ClassicalX();
512std::shared_ptr<ClassicalTransformOp>
ClassicalCX();
517std::shared_ptr<ExplicitPredicateOp>
NotOp();
522std::shared_ptr<ExplicitPredicateOp>
AndOp();
527std::shared_ptr<ExplicitPredicateOp>
OrOp();
532std::shared_ptr<ExplicitPredicateOp>
XorOp();
537std::shared_ptr<ExplicitModifierOp>
AndWithOp();
542std::shared_ptr<ExplicitModifierOp>
OrWithOp();
547std::shared_ptr<ExplicitModifierOp>
XorWithOp();
bool is_equal(const Op &other) const override
Equality check between two ClassicalEvalOp instances.
virtual std::vector< bool > eval(const std::vector< bool > &x) const =0
Evaluation.
A purely classical operation.
unsigned get_n_io() const
Number of input-output bits.
std::vector< EdgeType > sig_
nlohmann::json serialize() const override
op_signature_t get_signature() const override
Vector specifying type of data for each port on op.
SymSet free_symbols() const override
Set of all free symbols occurring in operation parameters.
bool is_equal(const Op &other) const override
Equality check between two ClassicalEvalOp instances.
static Op_ptr deserialize(const nlohmann::json &j)
unsigned get_n_o() const
Number of output-only bits.
std::string get_name(bool latex=false) const override
String representation.
unsigned get_n_i() const
Number of input-only bits.
unsigned n_qubits() const override
An operation to copy some bit values.
std::vector< bool > eval(const std::vector< bool > &x) const override
Evaluation.
Op_ptr symbol_substitution(const SymEngine::map_basic_basic &) const override
Operation with values for symbols substituted.
A modifying operation defined explicitly by a truth table.
std::vector< bool > get_values() const
Op_ptr symbol_substitution(const SymEngine::map_basic_basic &) const override
Operation with values for symbols substituted.
std::vector< bool > eval(const std::vector< bool > &x) const override
Evaluation.
A predicate defined explicitly by a truth table.
std::vector< bool > eval(const std::vector< bool > &x) const override
Evaluation.
Op_ptr symbol_substitution(const SymEngine::map_basic_basic &) const override
Operation with values for symbols substituted.
std::vector< bool > get_values() const
A classical operation with one output bit which is also an input bit.
ModifyingOp(OpType type, unsigned n, const std::string &name)
Construct a ModifyingOp of specified arity.
A classical operation applied simultaneously to multiple bits.
Op_ptr symbol_substitution(const SymEngine::map_basic_basic &) const override
Operation with values for symbols substituted.
std::string get_name(bool latex) const override
String representation.
std::vector< bool > eval(const std::vector< bool > &x) const override
Evaluation.
bool is_equal(const Op &other) const override
Equality check between two MultiBitOp instances.
std::shared_ptr< const ClassicalEvalOp > get_op() const
Abstract class representing an operation type.
A classical operation with single output bit.
PredicateOp(OpType type, unsigned n, const std::string &name="")
Construct a PredicateOp of specified arity.
A predicate defined by a range of values in binary encoding.
std::vector< bool > eval(const std::vector< bool > &x) const override
Evaluation.
bool is_equal(const Op &other) const override
Equality check between two RangePredicateOp instances.
RangePredicateOp(unsigned n, uint64_t a=0, uint64_t b=std::numeric_limits< uint64_t >::max())
Construct from a lower and upper bound.
Op_ptr symbol_substitution(const SymEngine::map_basic_basic &) const override
Operation with values for symbols substituted.
std::string get_name(bool latex) const override
String representation.
An operation to set some bits to specified values.
SetBitsOp(const std::vector< bool > &values)
Construct from values.
std::vector< bool > get_values() const
std::string get_name(bool latex) const override
String representation.
Op_ptr symbol_substitution(const SymEngine::map_basic_basic &) const override
Operation with values for symbols substituted.
std::vector< bool > eval(const std::vector< bool > &x) const override
Evaluation.
Op containing a classical wasm function call.
bool is_equal(const Op &other) const override
Equality check between two WASMOp instances.
std::vector< unsigned > get_width_o_parameter() const
returns the vector of number of bit used for each of the output i32 variables
bool is_extern() const override
return if the op is external
static Op_ptr deserialize(const nlohmann::json &j)
deserialize json to wasmop
std::string get_wasm_file_uid() const
returns the uid of the wasm file the op is using, the file is stored on the python layer
unsigned get_ww_n() const
returns the number of wasm wire in the op
unsigned get_n_i32() const
returns the number of i32 the function is acting on
std::vector< unsigned > get_width_i_parameter() const
returns the vector of number of bit used for each of the input i32 variables
Op_ptr symbol_substitution(const SymEngine::map_basic_basic &) const override
Operation with values for symbols substituted.
unsigned get_n() const
returns the number of classical bits the wasm op is acting on
std::string get_func_name() const
returns the name of the function the wasm op is using
nlohmann::json serialize() const override
serialize wasmop to json
Defines tket::DeviceCharacterisation, used in NoiseAwarePlacement and in commute_SQ_gates_through_SWA...
std::shared_ptr< ExplicitModifierOp > OrWithOp()
In-place OR with another input.
std::shared_ptr< ExplicitPredicateOp > AndOp()
Binary AND operator.
OpType
Named operation types.
@ RangePredicate
A classical predicate defined by a range of values in binary encoding.
@ SetBits
An operation to set some bits to specified values.
@ CopyBits
An operation to copy some bit values.
std::shared_ptr< ExplicitModifierOp > AndWithOp()
In-place AND with another input.
std::shared_ptr< ClassicalTransformOp > ClassicalCX()
Classical CNOT transform.
std::shared_ptr< ExplicitPredicateOp > OrOp()
Binary OR operator.
std::shared_ptr< const Op > Op_ptr
std::shared_ptr< ExplicitPredicateOp > NotOp()
Unary NOT operator.
std::shared_ptr< ClassicalTransformOp > ClassicalX()
Classical NOT transform.
std::set< Sym, SymCompareLess > SymSet
std::shared_ptr< ExplicitModifierOp > XorWithOp()
In-place XOR with another input.
std::vector< EdgeType > op_signature_t
std::shared_ptr< ExplicitPredicateOp > XorOp()
Binary XOR operator.