Commit 92921510 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Added pass manager demos



Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 9e221f40
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
// simple_circuit.cpp: Demonstrate runtime optimization passes (acting on XACC IR)
// $qcor -opt 1 -print-opt-stats simple_circuit.cpp -print-final-submission
__qpu__ void do_nothing(qubit q) {
  // This is Z Z = I
  // (H - X - H == Z)
  Z(q);
  H(q);
  X(q);
  H(q);
}

int main() {
  // get a qubit
  auto qbits = qalloc(1);
  do_nothing(qbits[0]);
  std::cout << "Unitary matrix: \n" << do_nothing::as_unitary_matrix(qbits[0]) << "\n";
}
 No newline at end of file
+16 −0
Original line number Diff line number Diff line
// trotter_decompose.cpp: Demonstrate runtime optimization passes (acting on XACC IR)
// Simplify Trotter circuit with many iterations to a shorter form
// $qcor -opt 1 -print-opt-stats -print-final-submission trotter_decompose.cpp
__qpu__ void trotter_evolve(qreg q, Operator hamiltonian, double dt, int nbSteps) {
  for (int i = 0; i < nbSteps; ++i) {
    exp_i_theta(q, dt, hamiltonian);
  }
}

int main() {
  auto qbits = qalloc(2);
  auto H = X(0) * X(1);
  double dt = 0.01;
  int nbSteps = 100;
  trotter_evolve(qbits, H, dt, nbSteps);
}
 No newline at end of file