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

Update example files for tutorial



Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 4d71c67f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -8,10 +8,10 @@ int main() {
  // Create the Hamiltonian
  auto H = -2.1433 * X(0) * X(1) - 2.1433 * Y(0) * Y(1) + .21829 * Z(0) -
           6.125 * Z(1) + 5.907;

  std::cout << "H = " << H.toString() << "\n";
  const double test_theta = 1.2345;
  auto q = qalloc(2);
  const double energy = ansatz::observe(H, q, test_theta);
  std::cout << "E(" << test_theta << ") = " << energy << "\n";
  q.print();
  // q.print();
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ def ansatz(q: qreg, x: List[float], exp_args: List[Operator]):
        exp_i_theta(q, x[i], exp_args[i])

# Create OpenFermion operators for our quantum kernel...
exp_args_openfermion = [FOp('0^ 1') - FOp('1^ 0'), FOp('0^ 2') - FOp('2^ 0')]
exp_args_openfermion = [FOp('0^ 2') - FOp('2^ 0')]

# We need to translate OpenFermion ops into qcor Operators to use with kernels...
exp_args_qcor = [createOperator('fermion', fop) for fop in exp_args_openfermion]
+0 −3
Original line number Diff line number Diff line
@@ -40,8 +40,5 @@ int main(int argc, char **argv) {
                                              {"n-electrons", nElectrons}});
  auto result = workflow->execute(problemModel);
  std::cout << "Final energy: " << result.get<double>("energy") << "\n";
  auto final_ansatz =
      result.getPointerLike<xacc::CompositeInstruction>("circuit");
  std::cout << "HOWDY: \n" << final_ansatz->toString() << "\n";
  return 0;
}
 No newline at end of file
+1 −4
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
// iterative QPE procedure.

// Compile and run with:
/// $ qcor -qpu qpp IterativeQpeVqe.cpp
/// $ qcor IterativeQpeVqe.cpp
/// $ ./a.out

/// Ansatz to bring the state into an eigenvector state of the Hamiltonian.
@@ -37,8 +37,5 @@ int main(int argc, char **argv) {
  std::cout << "Final phase = " << phaseValue << "\n";
  // Expect: ~ -1.7 (due to limited bit precision)
  std::cout << "Energy = " << energy << "\n";

  print("N Instructions at Iter:");
  for (auto [i,n] : enumerate(n_insts)) print("iter", i, ":" , n);
  return 0;
}
 No newline at end of file
+41 KiB
Loading image diff...
Loading