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_;
96 const SymEngine::map_basic_basic &)
const override {
97 return std::make_shared<OpaqueClassicalOp>(*
this);
103 nlohmann::json
serialize()
const override;
113 bool is_equal(
const Op &other)
const override;
132 OpType type,
unsigned n_i,
unsigned n_io,
unsigned n_o,
133 const std::string &name =
"");
142 virtual std::vector<bool>
eval(
const std::vector<bool> &x)
const = 0;
147 bool is_equal(
const Op &other)
const override;
169 unsigned n,
const std::vector<uint64_t> &values,
170 const std::string &name =
"ClassicalTransform");
173 const SymEngine::map_basic_basic &)
const override {
174 return std::make_shared<ClassicalTransformOp>(*
this);
177 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
182 const std::vector<uint64_t> values_;
203 unsigned _n,
unsigned _ww_n, std::vector<unsigned> _width_i_parameter,
204 std::vector<unsigned> _width_o_parameter,
const std::string &_func_name,
205 const std::string &_wasm_uid);
208 const SymEngine::map_basic_basic &)
const override {
209 return std::make_shared<WASMOp>(*
this);
220 nlohmann::json
serialize()
const override;
230 bool is_equal(
const Op &other)
const override;
235 unsigned get_n()
const {
return n_; }
252 return width_i_parameter_;
260 return width_o_parameter_;
283 const unsigned ww_n_;
288 const unsigned n_i32_;
293 const std::vector<unsigned> width_i_parameter_;
298 const std::vector<unsigned> width_o_parameter_;
303 const std::string func_name_;
308 const std::string wasm_file_uid_;
326 const SymEngine::map_basic_basic &)
const override {
327 return std::make_shared<SetBitsOp>(*
this);
330 std::string
get_name(
bool latex)
const override;
334 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
337 std::vector<bool> values_;
351 const SymEngine::map_basic_basic &)
const override {
352 return std::make_shared<CopyBitsOp>(*
this);
355 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
392 unsigned n, uint64_t a = 0,
393 uint64_t b = std::numeric_limits<uint64_t>::max())
397 const SymEngine::map_basic_basic &)
const override {
398 return std::make_shared<RangePredicateOp>(*
this);
401 std::string
get_name(
bool latex)
const override;
403 uint64_t
upper()
const {
return b; }
405 uint64_t
lower()
const {
return a; }
407 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
412 bool is_equal(
const Op &other)
const override;
437 unsigned n,
const std::vector<bool> &values,
438 const std::string &name =
"ExplicitPredicate");
441 const SymEngine::map_basic_basic &)
const override {
442 return std::make_shared<ExplicitPredicateOp>(*
this);
445 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
450 const std::vector<bool> values_;
488 unsigned n,
const std::vector<bool> &values,
489 const std::string &name =
"ExplicitModifier");
492 const SymEngine::map_basic_basic &)
const override {
493 return std::make_shared<ExplicitModifierOp>(*
this);
496 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
501 const std::vector<bool> values_;
512 MultiBitOp(std::shared_ptr<const ClassicalEvalOp> op,
unsigned n);
515 const SymEngine::map_basic_basic &)
const override {
516 return std::make_shared<MultiBitOp>(*
this);
519 std::string
get_name(
bool latex)
const override;
521 std::shared_ptr<const ClassicalEvalOp>
get_op()
const {
return op_; }
523 unsigned get_n()
const {
return n_; }
525 std::vector<bool>
eval(
const std::vector<bool> &x)
const override;
530 bool is_equal(
const Op &other)
const override;
533 std::shared_ptr<const ClassicalEvalOp> op_;
540std::shared_ptr<ClassicalTransformOp>
ClassicalX();
545std::shared_ptr<ClassicalTransformOp>
ClassicalCX();
550std::shared_ptr<ExplicitPredicateOp>
NotOp();
555std::shared_ptr<ExplicitPredicateOp>
AndOp();
560std::shared_ptr<ExplicitPredicateOp>
OrOp();
565std::shared_ptr<ExplicitPredicateOp>
XorOp();
570std::shared_ptr<ExplicitModifierOp>
AndWithOp();
575std::shared_ptr<ExplicitModifierOp>
OrWithOp();
580std::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.
An opaque classical operation with no parameters and fixed signature.
static Op_ptr deserialize(const nlohmann::json &j)
Deserialize from JSON.
nlohmann::json serialize() const override
Serialize to JSON.
Op_ptr symbol_substitution(const SymEngine::map_basic_basic &) const override
Operation with values for symbols substituted.
bool is_equal(const Op &other) const override
Equality check between two OpaqueClassicalOp instances.
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.