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

More fixes for the new SDK



Add generic rotation impl (preferred LLVM instruction from Q#)

Added check for Deuteron sweeping test

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent a3a5ed13
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
namespace QCOR 
{   
// Using QCOR Intrinsic instruction set
// see QirTarget.qs    
open Microsoft.Quantum.Intrinsic;
@EntryPoint()
operation TestBell(count : Int) : Int {
+4 −2
Original line number Diff line number Diff line
namespace QCOR 
{
open QCOR.Intrinsic;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Convert;
// Estimate energy value in a FTQC manner.
@EntryPoint()
operation Deuteron(theta : Double, shots: Int) : Double {
    mutable numParityOnes = 0;
    use (qubits = Qubit[2])
    use qubits = Qubit[2]
    {
        for test in 1..shots {
            X(qubits[0]);
+5 −2
Original line number Diff line number Diff line
@@ -2,7 +2,9 @@
#include <vector>

// Include the external QSharp function.
qcor_include_qsharp(QCOR__Deuteron__body, double, double, int64_t);
// Use the Interop entry point to get the result, not logging.
// Note: the __body function is marked as internal (cannot be linked against)
qcor_include_qsharp(QCOR__Deuteron__Interop, double, double, int64_t);

// Compile with:
// Include both the qsharp source and this driver file
@@ -21,9 +23,10 @@ int main() {
  for (size_t i = 0; i < angles.size(); ++i) {

    const double angle = angles[i];
    const double exp_val_xx = QCOR__Deuteron__body(angle, 1024);
    const double exp_val_xx = QCOR__Deuteron__Interop(angle, 1024);
    std::cout << "<X0X1>(" << angle << ") = " << exp_val_xx
              << " vs. expected = " << expectedResults[i] << "\n";
    qcor_expect(std::abs(exp_val_xx - expectedResults[i]) < 0.1);
  }
  return 0;
}
 No newline at end of file
+23 −5
Original line number Diff line number Diff line
@@ -50,9 +50,27 @@ void __quantum__qis__h__ctl(Array *ctls, Qubit *q) {
    std::cout << "CALL: " << __PRETTY_FUNCTION__ << "\n";
}
void __quantum__qis__r__body(Pauli pauli, double theta, Qubit *q) {
  // TODO
  if (verbose)
    std::cout << "CALL: " << __PRETTY_FUNCTION__ << "\n";
  switch (pauli) {
  case Pauli::Pauli_I:
    // nothing to do
    break;
  case Pauli::Pauli_X: {
    __quantum__qis__rx(theta, q);
    break;
  }
  case Pauli::Pauli_Y: {
    __quantum__qis__ry(theta, q);
    break;
  }
  case Pauli::Pauli_Z: {
    __quantum__qis__rz(theta, q);
    break;
  }
  default:
    __builtin_unreachable();
  }
}
void __quantum__qis__r__adj(Pauli pauli, double theta, Qubit *q) {
  // TODO
@@ -142,15 +160,15 @@ void __quantum__qis__x__ctladj(Array *ctls, Qubit *q) {
  return __quantum__qis__x__ctl(ctls, q);
}
void __quantum__qis__y__body(Qubit *q) {
  // TODO
  if (verbose)
    std::cout << "CALL: " << __PRETTY_FUNCTION__ << "\n";
  __quantum__qis__y(q);
}
void __quantum__qis__y__adj(Qubit *q) {
  // TODO
  if (verbose)
    std::cout << "CALL: " << __PRETTY_FUNCTION__ << "\n";
  // Self-adjoint
  __quantum__qis__y__body(q);
}
void __quantum__qis__y__ctl(Array *ctls, Qubit *q) {
  // TODO
@@ -163,15 +181,15 @@ void __quantum__qis__y__ctladj(Array *ctls, Qubit *q) {
    std::cout << "CALL: " << __PRETTY_FUNCTION__ << "\n";
}
void __quantum__qis__z__body(Qubit *q) {
  // TODO
  if (verbose)
    std::cout << "CALL: " << __PRETTY_FUNCTION__ << "\n";
  __quantum__qis__z(q);
}
void __quantum__qis__z__adj(Qubit *q) {
  // TODO
  if (verbose)
    std::cout << "CALL: " << __PRETTY_FUNCTION__ << "\n";
  // Self-adjoint
  __quantum__qis__z__body(q);
}
void __quantum__qis__z__ctl(Array *ctls, Qubit *q) {
  // TODO