Skip to content

Commit

Permalink
Added the iSwap gate to the clifford simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanro committed Nov 13, 2024
1 parent 8569555 commit 40bcc34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions QCSim/Clifford.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ namespace QC {
ApplyCX(qubit1, qubit2);
}

void ApplyISwap(size_t qubit1, size_t qubit2)
{
ApplyS(qubit1);
ApplyS(qubit2);
ApplyH(qubit1);
ApplyCX(qubit2, qubit1);
ApplyCX(qubit1, qubit2);
ApplyH(qubit2);
}

bool MeasureQubit(size_t qubit)
{
bool case1 = false;
Expand Down
7 changes: 6 additions & 1 deletion QCSim/CliffordTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ std::shared_ptr<QC::Gates::QuantumGateWithOp<>> GetGate(int code)
return std::make_shared<QC::Gates::ControlledZGate<>>();
case 11:
return std::make_shared<QC::Gates::SwapGate<>>();
case 12:
return std::make_shared<QC::Gates::iSwapGate<>>();
}

return nullptr;
Expand Down Expand Up @@ -81,6 +83,9 @@ void ApplyGate(QC::Clifford::StabilizerSimulator& simulator, int code, int qubit
case 11:
simulator.ApplySwap(qubit1, qubit2);
break;
case 12:
simulator.ApplyISwap(qubit1, qubit2);
break;
}
}

Expand Down Expand Up @@ -164,7 +169,7 @@ bool CliffordSimulatorTests()
const size_t nrQubits = 4;
const double errorThreshold = 0.01;

std::uniform_int_distribution gateDistr(0, 11);
std::uniform_int_distribution gateDistr(0, 12);
std::uniform_int_distribution qubitDistr(0, static_cast<int>(nrQubits) - 1);
std::uniform_int_distribution nrGatesDistr(5, 20);

Expand Down

0 comments on commit 40bcc34

Please sign in to comment.