libqasm
library for handling cQASM files
qasm_ast.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef QASM_AST_REP
3 #define QASM_AST_REP
4 
5 #include <iostream>
6 #include <vector>
7 #include <string>
8 #include <map>
9 #include <memory>
10 #include <algorithm>
11 #include <stdexcept>
12 
18 namespace compiler
19 {
20 
22  // This class takes a list of identifiers used by both bits and qubits to internal int vectors
23  {
24  public:
25  NumericalIdentifiers() = default;
26 
27  void addToVector (const int index)
28  // This is used when a single integer is encountered
29  {
30  indices_.push_back( static_cast<size_t> (index) );
31  }
32 
33  void addToVector (const int index_min, const int index_max)
34  // This is used for when a range of qubits is being defined
35  {
36  for (int index = index_min; index <= index_max; ++index)
37  indices_.push_back( static_cast<size_t> (index) );
38  }
39 
40  const std::vector<size_t>& getIndices() const
41  {
42  return indices_;
43  }
44 
46  {
47  std::sort( indices_.begin(), indices_.end() );
48  indices_.erase( std::unique( indices_.begin(), indices_.end() ), indices_.end() );
49  }
50 
51  void clear()
52  {
53  indices_.clear();
54  }
55 
56  void printMembers() const
57  {
58  std::cout << "Indices: ";
59  for (size_t elems : getIndices())
60  {
61  std::cout << elems << " ";
62  }
63  std::cout << std::endl;
64  }
65 
66  protected:
67  std::vector<size_t> indices_;
68  }; // class NumericalIdentifiers
69 
70  class Qubits
71  // This class encapsulates the participating qubits in the specified operation
72  {
73  public:
74 
75  Qubits() = default;
76  Qubits(NumericalIdentifiers indices) : selected_qubits_ (indices) {}
77 
79  {
80  selected_qubits_ = indices;
81  }
82 
84  {
85  return selected_qubits_;
86  }
87 
88  void printMembers() const
89  {
90  std::cout << "Selected Qubits - ";
91  getSelectedQubits().printMembers();
92  }
93 
94  protected:
96  };
97 
98  class Bits
99  // This class encapsulates the participating bit in the specified operation
100  {
101  public:
102 
103  Bits() = default;
104  Bits(NumericalIdentifiers indices) : selected_bits_ (indices) {}
105 
107  {
108  selected_bits_ = indices;
109  }
110 
112  {
113  return selected_bits_;
114  }
115 
116  void printMembers() const
117  {
118  std::cout << "Selected Bits - ";
119  getSelectedBits().printMembers();
120  }
121 
122  protected:
124  };
125 
126  class Operation
127  {
128  public:
129  Operation(const std::string type, Qubits qubits_involved)
130  : qubits_ (qubits_involved),
131  rotation_angle_ (std::numeric_limits<double>::max()), bit_controlled_(false)
132  // This is the most common operation, the single qubit operation, or reset_averaging
133  {
134  type_ = toLowerCase(type);
135  }
136 
137  Operation(const std::string type, Qubits qubits_involved, const double rotation_angle)
138  : qubits_ (qubits_involved),
139  rotation_angle_ (rotation_angle), bit_controlled_(false)
140  // Single qubit rotations
141  {
142  type_ = toLowerCase(type);
143  }
144 
145  Operation(const std::string type, Qubits qubit_pair1, std::string axis1, Qubits qubit_pair2, std::string axis2)
146  : rotation_angle_ (std::numeric_limits<double>::max()), bit_controlled_(false)
147  // Measure parity operation
148  {
149  type_ = toLowerCase(type);
150  measure_parity_qubits_ = std::pair<Qubits,Qubits> (qubit_pair1,qubit_pair2);
151  measure_parity_axis_ = std::pair<std::string,std::string> (toLowerCase(axis1),toLowerCase(axis2));
152  }
153 
154  Operation(const std::string type)
155  : rotation_angle_ (std::numeric_limits<double>::max()), bit_controlled_(false)
156  // Measure all operation
157  {
158  type_ = toLowerCase(type);
159  all_qubits_bits_ = true;
160  }
161 
162  Operation(const std::string type, const int waitInt)
163  : rotation_angle_ (std::numeric_limits<double>::max()), bit_controlled_(false)
164  // Wait and Skip commands
165  {
166  type_ = toLowerCase(type);
167  wait_time_ = waitInt;
168  }
169 
170  Operation(const std::string type, const Bits display_bits)
171  : rotation_angle_ (std::numeric_limits<double>::max()), bit_controlled_(false)
172  // Display command
173  {
174  type_ = toLowerCase(type);
175  bits_ = display_bits;
176  }
177 
178  Operation(const std::string type, Qubits qubit_pair1, Qubits qubit_pair2)
179  : rotation_angle_ (std::numeric_limits<double>::max()), bit_controlled_(false)
180  // Two qubit gate operations
181  {
182  type_ = toLowerCase(type);
183  two_qubit_pairs_ = std::pair<Qubits,Qubits> (qubit_pair1,qubit_pair2);
184  }
185 
186  Operation(const std::string type, Qubits qubit_pair1, Qubits qubit_pair2, double rotations)
187  : rotation_angle_ (rotations), bit_controlled_(false)
188  // Two qubit gate operations
189  {
190  type_ = toLowerCase(type);
191  two_qubit_pairs_ = std::pair<Qubits,Qubits> (qubit_pair1,qubit_pair2);
192  }
193 
194  Operation(const std::string type, Qubits qubit_pair1, Qubits qubit_pair2, Qubits qubit_pair3)
195  : rotation_angle_ (std::numeric_limits<double>::max()), bit_controlled_(false)
196  // Toffoli operations
197  {
198  type_ = toLowerCase(type);
199  toffoli_qubit_pairs_ = std::pair<Qubits, std::pair<Qubits,Qubits>> (
200  qubit_pair1,
201  std::pair<Qubits,Qubits> (qubit_pair2,qubit_pair3)
202  );
203  }
204 
205  Operation(const std::string type, const std::string state_filename)
206  : rotation_angle_ (std::numeric_limits<double>::max()), bit_controlled_(false)
207  // load_state command (This one is special because it should be case sensitive for the filename)
208  {
209  type_ = toLowerCase(type);
210  state_filename_ = removeQuotes(state_filename);
211  }
212 
213  std::string getType() const
214  {
215  return type_;
216  }
217 
218  std::string getStateFilename() const
219  {
220  return state_filename_;
221  }
222 
223  const Qubits& getQubitsInvolved() const
224  {
225  return qubits_;
226  }
227 
228  const Qubits& getQubitsInvolved(const int qubit_pair_index) const
229  {
230  if (type_ == "toffoli")
231  {
232  switch (qubit_pair_index) {
233  case 1: return toffoli_qubit_pairs_.first; break;
234  case 2: return toffoli_qubit_pairs_.second.first; break;
235  case 3: return toffoli_qubit_pairs_.second.second; break;
236  default: throw std::runtime_error( std::string("Accessing qubit pair ")
237  + std::to_string(qubit_pair_index)
238  + std::string(" on operation ") + type_ ); return qubits_;
239  }
240  }
241  else if (type_ == "cnot" || type_ == "cz" || type_ == "swap" || type_ == "cr" || type_ == "crk")
242  {
243  switch(qubit_pair_index){
244  case 1: return two_qubit_pairs_.first; break;
245  case 2: return two_qubit_pairs_.second; break;
246  default: throw std::runtime_error( std::string("Accessing qubit pair ")
247  + std::to_string(qubit_pair_index)
248  + std::string(" on operation ") + type_ ); return qubits_;
249  }
250  }
251  else
252  {
253  throw std::runtime_error( std::string("Accessing qubit pair ")
254  + std::to_string(qubit_pair_index)
255  + std::string(" on operation ") + type_ );
256  return qubits_;
257  }
258  }
259 
260  double getRotationAngle() const
261  {
262  return rotation_angle_;
263  }
264 
265  const std::pair< std::pair<Qubits,Qubits>, std::pair<std::string,std::string> > getMeasureParityQubitsAndAxis() const
266  {
267  std::pair< std::pair<Qubits,Qubits>, std::pair<std::string,std::string> > pair_result (measure_parity_qubits_, measure_parity_axis_);
268  return pair_result;
269  }
270 
271  const std::pair <Qubits,Qubits>& getTwoQubitPairs() const
272  {
273  return two_qubit_pairs_;
274  }
275 
276  const std::pair< Qubits, std::pair<Qubits,Qubits> >& getToffoliQubitPairs() const
277  {
278  return toffoli_qubit_pairs_;
279  }
280 
281  bool isBitControlled() const
282  {
283  return bit_controlled_;
284  }
285 
286  bool allQubitsBits() const
287  {
288  return all_qubits_bits_;
289  }
290 
291  void setControlBits(Bits control_bits)
292  {
293  bits_ = control_bits;
294  bit_controlled_ = true;
295  }
296 
297  const Bits& getControlBits() const
298  {
299  return bits_;
300  }
301 
302  const Bits& getDisplayBits() const
303  {
304  return bits_;
305  }
306 
307  int getWaitTime() const
308  {
309  return wait_time_;
310  }
311 
312  void setUMatrixElements(const std::vector<double> input)
313  {
314  unitary_matrix_elements_ = input;
315  }
316 
317  const std::vector<double>& getUMatrixElements() const
318  {
319  return unitary_matrix_elements_;
320  }
321 
322  void printOperation() const
323  {
324  std::cout << "Operation " << type_ << ": ";
325  if ( type_ == "rx" || type_ == "ry" || type_ == "rz" )
326  {
327  getQubitsInvolved().printMembers();
328  std::cout << "Rotations = " << getRotationAngle() << std::endl;
329  }
330  else if (type_ == "measure_parity")
331  {
332  std::cout << std::endl;
333  auto measureParityProperties = getMeasureParityQubitsAndAxis();
334  measureParityProperties.first.first.printMembers();
335  std::cout << "With axis " << measureParityProperties.second.first << std::endl;
336  measureParityProperties.first.second.printMembers();
337  std::cout << "With axis " << measureParityProperties.second.second << std::endl;
338  }
339  else if (type_ == "cnot" || type_ == "cz" || type_ == "swap")
340  {
341  std::cout << std::endl;
342  std::cout << "Qubit Pair 1: ";
343  getTwoQubitPairs().first.printMembers();
344  std::cout << "Qubit Pair 2: ";
345  getTwoQubitPairs().second.printMembers();
346  }
347  else if (type_ == "cr")
348  {
349  std::cout << std::endl;
350  std::cout << "Qubit Pair 1: ";
351  getTwoQubitPairs().first.printMembers();
352  std::cout << "Qubit Pair 2: ";
353  getTwoQubitPairs().second.printMembers();
354  std::cout << "Rotation = " << getRotationAngle() << std::endl;
355  }
356  else if (type_ == "toffoli")
357  {
358  std::cout << std::endl;
359  std::cout << "Qubit Pair 1: ";
360  getToffoliQubitPairs().first.printMembers();
361  std::cout << "Qubit Pair 2: ";
362  getToffoliQubitPairs().second.first.printMembers();
363  std::cout << "Qubit Pair 3: ";
364  getToffoliQubitPairs().second.second.printMembers();
365  }
366  else if (type_ == "skip")
367  {
368  std::cout << std::endl;
369  std::cout << "Wait time (integer) = " << getWaitTime() << std::endl;
370  }
371  else if (type_ == "wait")
372  {
373  std::cout << std::endl;
374  std::cout << "Wait time (integer) = " << getWaitTime() << std::endl;
375  }
376  else if ( (type_ == "display") || (type_ == "display_binary") )
377  {
378  std::cout << "Display bits: ";
379  getDisplayBits().printMembers();
380  }
381  else getQubitsInvolved().printMembers();
382 
383  if (isBitControlled()){
384  std::cout << "Bit controlled with bits: ";
385  getControlBits().printMembers();
386  }
387  }
388 
389  protected:
390 
391  std::string toLowerCase(const std::string& string_input)
392  {
393  std::string lower_case_input = string_input;
394  std::transform(lower_case_input.begin(), lower_case_input.end(), lower_case_input.begin(), ::tolower);
395  return lower_case_input;
396  }
397 
398  std::string removeQuotes(const std::string& string_input)
399  {
400  std::string result = string_input;
401  result.erase(result.begin());
402  result.erase(result.end()-1);
403  return result;
404  }
405 
406  std::string type_;
407  std::string state_filename_;
412  bool all_qubits_bits_ = false;
414  std::pair<Qubits,Qubits> measure_parity_qubits_;
415  std::pair<std::string,std::string> measure_parity_axis_;
416  std::pair<Qubits,Qubits> two_qubit_pairs_;
417  std::pair<Qubits, std::pair<Qubits,Qubits> > toffoli_qubit_pairs_;
418  std::vector<double> unitary_matrix_elements_;
419  }; // class Operation
420 
422  // This class enables parallel operation support
423  {
424  public:
426  {
427  isParallel_ = false;
428  }
429 
430  OperationsCluster(Operation* valid_op, int linenumber)
431  {
432  operations_.push_back(valid_op);
433  isParallel_ = false;
434  linenumber_ = linenumber;
435  }
436 
438  {
439  return operations_.back();
440  }
441 
442  void addOperation(Operation* valid_op)
443  {
444  operations_.push_back(valid_op);
445  }
446 
448  {
449  operations_.push_back(valid_op);
450  isParallel_ = true;
451  }
452 
453  bool isParallel() const
454  {
455  return isParallel_;
456  }
457 
458  const std::vector<Operation*>& getOperations() const
459  {
460  return operations_;
461  }
462 
463  void setLineNumber(int linenumber)
464  {
465  linenumber_ = linenumber;
466  }
467 
468  int getLineNumber() const
469  {
470  return linenumber_;
471  }
472 
474  {
475  if (isParallel())
476  {
477  std::cout << "Parallel operations cluster: " << std::endl;
478  for (auto elem : getOperations())
479  elem -> printOperation();
480  std::cout << "End Parallel operations \n" << std::endl;
481  }
482  else
483  {
484  std::cout << "Serial operation: " << std::endl;
485  for (auto elem : getOperations())
486  elem -> printOperation();
487  std::cout << "End Serial operation \n" << std::endl;
488  }
489  }
490 
491  protected:
492  std::vector<Operation*> operations_;
495  }; // class Operations
496 
498  // This class encapsulates the subcircuit with the number of iterations and also the statements contained in it.
499  {
500  public:
501 
503  {
504  }
505 
506  SubCircuit(const char* name, const int subcircuit_number, const int linenumber):
507  name_ ( std::string(name) ),
508  number_iterations_ ( 1 ), // By default, we run the subcircuit at least once
509  subcircuit_number_ ( subcircuit_number ),
510  linenumber_ (linenumber)
511  {
512  }
513 
514  int numberIterations() const
515  {
516  return number_iterations_;
517  }
518 
519  void numberIterations(int iterations)
520  {
521  number_iterations_ = iterations;
522  }
523 
524  int getLineNumber() const
525  {
526  return linenumber_;
527  }
528 
529  size_t rankSubCircuit() const
530  {
531  return subcircuit_number_;
532  }
533 
534  const std::string& nameSubCircuit() const
535  {
536  return name_;
537  }
538 
540  {
541  operations_cluster_.push_back(opclus);
542  }
543 
545  {
546  return operations_cluster_.back();
547  }
548 
549  const std::vector<OperationsCluster*>& getOperationsCluster() const
550  {
551  return operations_cluster_;
552  }
553 
554  void printMembers() const
555  {
556  std::cout << "Subcircuit Name = " << nameSubCircuit() << " , Rank = " << rankSubCircuit() << std::endl;
557  std::cout << nameSubCircuit() << " has " << numberIterations() << " iterations." << std::endl;
558  std::cout << "Contains these operations clusters:" << std::endl;
559  for (auto elem : getOperationsCluster())
560  elem->printOperations();
561  std::cout << "End of subcircuit " << nameSubCircuit() << std::endl << std::endl;
562  }
563 
564  protected:
565  std::string name_; // This member is the name of the subcircuit
566  int number_iterations_; // This member is the number of iterations the subcircuit is supposed to run
567  size_t subcircuit_number_; // This member provides the order of the subcircuits when it is found in the qasm file
569  std::vector<OperationsCluster*> operations_cluster_;
570  }; //class SubCircuit
571 
573  // This class groups all the subcircuits found in the cqasm file
574  {
575  public:
577  {
578  SubCircuit default_circuit("default", 0, 1);
579  subcircuits_.push_back ( default_circuit );
580  }
581 
582  void addSubCircuit(SubCircuit subcircuit)
583  {
584  subcircuits_.push_back(subcircuit);
585  }
586 
587  size_t numberOfSubCircuits() const
588  {
589  return subcircuits_.size();
590  }
591 
593  {
594  return subcircuits_.back();
595  }
596 
597  const std::vector<SubCircuit>& getAllSubCircuits() const
598  {
599  return subcircuits_;
600  }
601 
602  void clearSubCircuits() { subcircuits_.clear(); }
603 
604  protected:
605  std::vector<SubCircuit> subcircuits_;
606  }; //class SubCircuits
607 
609  // This class is supposed to provide an encapsulation of all the objects within the qasm file
610  {
611  public:
613  {
614  std::vector<double> default_param(1, 0.);
615  setErrorModel("None", default_param);
616  }
617 
618  void qubitRegister(int participating_number)
619  {
620  qubit_register_ = participating_number;
621  }
622 
623  int numQubits()
624  {
625  return qubit_register_;
626  }
627 
628  double versionNumber() const
629  {
630  return version_number_;
631  }
632 
633  void versionNumber(double version)
634  {
635  version_number_ = version;
636  }
637 
639  {
640  return subcircuits_;
641  }
642 
643  void addMappings(std::string name_key, NumericalIdentifiers indices, bool isQubit)
644  {
645  // Make sure they are all lowercase
646  std::transform(name_key.begin(), name_key.end(), name_key.begin(), ::tolower);
647  // Make pair between the indices and whether or not it is a qubit
648  std::pair<NumericalIdentifiers, bool> map_value (indices, isQubit);
649  mappings_[name_key] = map_value;
650  }
651 
652  const NumericalIdentifiers& getMappedIndices(std::string name_key, bool isQubit, int linenumber) const
653  {
654  // Make sure they are all lowercase
655  std::transform(name_key.begin(), name_key.end(), name_key.begin(), ::tolower);
656 
657  if (mappings_.find(name_key) != mappings_.end() &&
658  mappings_.find(name_key)->second.second == isQubit)
659  return mappings_.find(name_key)->second.first;
660  else
661  throw std::runtime_error(std::string("Could not get wanted mapping ") +
662  name_key + ": Line " + std::to_string(linenumber));
663  }
664 
665  void setErrorModel(std::string error_model_type, std::vector<double> error_model_num_params)
666  {
667  error_model_.first = error_model_type;
668  error_model_.second = error_model_num_params;
669  }
670 
671  const std::string getErrorModelType() const
672  {
673  return error_model_.first;
674  }
675 
676  std::vector<double> getErrorModelParameters() const
677  {
678  return error_model_.second;
679  }
680 
681  void printMappings() const
682  // This is just for debugging purposes
683  {
684  for (auto elem : mappings_)
685  {
686  std::cout << elem.first << ": ";
687  elem.second.first.printMembers(); std::cout << elem.second.second << std::endl;
688  }
689  printErrorModel();
690  }
691 
692  void printErrorModel() const
693  // This is just for debugging purposes
694  {
695  std::cout << "Current error model: " << error_model_.first
696  << "\nError Probability = " ;
697  for (auto i : getErrorModelParameters()){
698  std::cout << i << std::endl;
699  }
700  }
701 
702  protected:
706  std::map< std::string , std::pair<NumericalIdentifiers,bool> > mappings_;
707  std::pair< std::string, std::vector<double> > error_model_;
708  }; // class QasmRepresentation
709 } //namespace compiler
710 
711 
712 #endif
const Bits & getControlBits() const
Definition: qasm_ast.hpp:297
OperationsCluster * lastOperationsCluster()
Definition: qasm_ast.hpp:544
double getRotationAngle() const
Definition: qasm_ast.hpp:260
void versionNumber(double version)
Definition: qasm_ast.hpp:633
std::pair< Qubits, Qubits > measure_parity_qubits_
Definition: qasm_ast.hpp:414
void qubitRegister(int participating_number)
Definition: qasm_ast.hpp:618
std::vector< SubCircuit > subcircuits_
Definition: qasm_ast.hpp:605
std::string toLowerCase(const std::string &string_input)
Definition: qasm_ast.hpp:391
SubCircuits & getSubCircuits()
Definition: qasm_ast.hpp:638
std::string state_filename_
Definition: qasm_ast.hpp:407
void addMappings(std::string name_key, NumericalIdentifiers indices, bool isQubit)
Definition: qasm_ast.hpp:643
int getWaitTime() const
Definition: qasm_ast.hpp:307
Bits(NumericalIdentifiers indices)
Definition: qasm_ast.hpp:104
void setErrorModel(std::string error_model_type, std::vector< double > error_model_num_params)
Definition: qasm_ast.hpp:665
bool isBitControlled() const
Definition: qasm_ast.hpp:281
Operation(const std::string type, Qubits qubit_pair1, std::string axis1, Qubits qubit_pair2, std::string axis2)
Definition: qasm_ast.hpp:145
Qubits(NumericalIdentifiers indices)
Definition: qasm_ast.hpp:76
void printOperation() const
Definition: qasm_ast.hpp:322
SubCircuit & lastSubCircuit()
Definition: qasm_ast.hpp:592
STL namespace.
const std::pair< Qubits, std::pair< Qubits, Qubits > > & getToffoliQubitPairs() const
Definition: qasm_ast.hpp:276
const Qubits & getQubitsInvolved(const int qubit_pair_index) const
Definition: qasm_ast.hpp:228
Operation(const std::string type, Qubits qubits_involved)
Definition: qasm_ast.hpp:129
const NumericalIdentifiers & getSelectedQubits() const
Definition: qasm_ast.hpp:83
void addToVector(const int index)
Definition: qasm_ast.hpp:27
OperationsCluster(Operation *valid_op, int linenumber)
Definition: qasm_ast.hpp:430
std::pair< std::string, std::vector< double > > error_model_
Definition: qasm_ast.hpp:707
const Qubits & getQubitsInvolved() const
Definition: qasm_ast.hpp:223
const std::vector< SubCircuit > & getAllSubCircuits() const
Definition: qasm_ast.hpp:597
Operation(const std::string type, Qubits qubit_pair1, Qubits qubit_pair2)
Definition: qasm_ast.hpp:178
Operation(const std::string type, Qubits qubits_involved, const double rotation_angle)
Definition: qasm_ast.hpp:137
Operation(const std::string type, Qubits qubit_pair1, Qubits qubit_pair2, double rotations)
Definition: qasm_ast.hpp:186
const NumericalIdentifiers & getSelectedBits() const
Definition: qasm_ast.hpp:111
void printMembers() const
Definition: qasm_ast.hpp:554
int getLineNumber() const
Definition: qasm_ast.hpp:524
std::vector< Operation * > operations_
Definition: qasm_ast.hpp:492
const std::vector< OperationsCluster * > & getOperationsCluster() const
Definition: qasm_ast.hpp:549
const std::string & nameSubCircuit() const
Definition: qasm_ast.hpp:534
size_t rankSubCircuit() const
Definition: qasm_ast.hpp:529
std::string removeQuotes(const std::string &string_input)
Definition: qasm_ast.hpp:398
void addToVector(const int index_min, const int index_max)
Definition: qasm_ast.hpp:33
const std::pair< std::pair< Qubits, Qubits >, std::pair< std::string, std::string > > getMeasureParityQubitsAndAxis() const
Definition: qasm_ast.hpp:265
Namespace used for most of the original API.
Definition: qasm_ast.hpp:18
Operation(const std::string type, const std::string state_filename)
Definition: qasm_ast.hpp:205
const std::string getErrorModelType() const
Definition: qasm_ast.hpp:671
std::vector< OperationsCluster * > operations_cluster_
Definition: qasm_ast.hpp:569
Operation(const std::string type, Qubits qubit_pair1, Qubits qubit_pair2, Qubits qubit_pair3)
Definition: qasm_ast.hpp:194
Operation(const std::string type)
Definition: qasm_ast.hpp:154
std::vector< size_t > indices_
Definition: qasm_ast.hpp:67
std::string getType() const
Definition: qasm_ast.hpp:213
const std::pair< Qubits, Qubits > & getTwoQubitPairs() const
Definition: qasm_ast.hpp:271
std::map< std::string, std::pair< NumericalIdentifiers, bool > > mappings_
Definition: qasm_ast.hpp:706
void setSelectedQubits(NumericalIdentifiers indices)
Definition: qasm_ast.hpp:78
std::string getStateFilename() const
Definition: qasm_ast.hpp:218
const Bits & getDisplayBits() const
Definition: qasm_ast.hpp:302
double versionNumber() const
Definition: qasm_ast.hpp:628
std::string name_
Definition: qasm_ast.hpp:565
Operation(const std::string type, const int waitInt)
Definition: qasm_ast.hpp:162
void setSelectedBits(NumericalIdentifiers indices)
Definition: qasm_ast.hpp:106
size_t numberOfSubCircuits() const
Definition: qasm_ast.hpp:587
Operation * lastOperation()
Definition: qasm_ast.hpp:437
NumericalIdentifiers selected_bits_
Definition: qasm_ast.hpp:123
const std::vector< double > & getUMatrixElements() const
Definition: qasm_ast.hpp:317
const std::vector< Operation * > & getOperations() const
Definition: qasm_ast.hpp:458
std::pair< Qubits, std::pair< Qubits, Qubits > > toffoli_qubit_pairs_
Definition: qasm_ast.hpp:417
NumericalIdentifiers selected_qubits_
Definition: qasm_ast.hpp:95
std::string type_
Definition: qasm_ast.hpp:406
void addParallelOperation(Operation *valid_op)
Definition: qasm_ast.hpp:447
std::pair< std::string, std::string > measure_parity_axis_
Definition: qasm_ast.hpp:415
std::vector< double > getErrorModelParameters() const
Definition: qasm_ast.hpp:676
void addOperation(Operation *valid_op)
Definition: qasm_ast.hpp:442
std::vector< double > unitary_matrix_elements_
Definition: qasm_ast.hpp:418
void addOperationsCluster(OperationsCluster *opclus)
Definition: qasm_ast.hpp:539
void setLineNumber(int linenumber)
Definition: qasm_ast.hpp:463
std::pair< Qubits, Qubits > two_qubit_pairs_
Definition: qasm_ast.hpp:416
bool allQubitsBits() const
Definition: qasm_ast.hpp:286
void addSubCircuit(SubCircuit subcircuit)
Definition: qasm_ast.hpp:582
void setUMatrixElements(const std::vector< double > input)
Definition: qasm_ast.hpp:312
const NumericalIdentifiers & getMappedIndices(std::string name_key, bool isQubit, int linenumber) const
Definition: qasm_ast.hpp:652
SubCircuit(const char *name, const int subcircuit_number, const int linenumber)
Definition: qasm_ast.hpp:506
const std::vector< size_t > & getIndices() const
Definition: qasm_ast.hpp:40
void setControlBits(Bits control_bits)
Definition: qasm_ast.hpp:291
void printMembers() const
Definition: qasm_ast.hpp:116
void printMembers() const
Definition: qasm_ast.hpp:88
Operation(const std::string type, const Bits display_bits)
Definition: qasm_ast.hpp:170
int numberIterations() const
Definition: qasm_ast.hpp:514
void numberIterations(int iterations)
Definition: qasm_ast.hpp:519