Skip to content

Commit

Permalink
Fixes for #91
Browse files Browse the repository at this point in the history
It was a copy and paste error when  I tried to fix #89

I copied the leg pattern from Hadamard gate which was actually not generally correct (okay for H matrix, which is symmetric).

Effectively, it was applying U gates in reverse.

Need to swap the leg order.

Tested by: running both the Python test scripts.

Signed-off-by: Thien Nguyen <[email protected]>
  • Loading branch information
Thien Nguyen committed Feb 9, 2021
1 parent 7f9fcee commit ca6dca8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tnqvm/visitors/itensor/mps/ITensorMPSVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,11 @@ void ITensorMPSVisitor::visit(U &u) {
auto ind_in = ind_for_qbit(iqbit_in);
auto ind_out = itensor::Index(u.name(), 2);
auto tGate = itensor::ITensor(ind_in, ind_out);
tGate.set(ind_in(1), ind_out(1), std::cos(theta / 2.0));
tGate.set(ind_in(1), ind_out(2), -std::exp(std::complex<double>(0, lambda)) *
tGate.set(ind_out(1), ind_in(1), std::cos(theta / 2.0));
tGate.set(ind_out(1), ind_in(2), -std::exp(std::complex<double>(0, lambda)) *
std::sin(theta / 2.0));
tGate.set(ind_in(2), ind_out(1), std::exp(std::complex<double>(0, phi)) * std::sin(theta / 2.0));
tGate.set(ind_in(2), ind_out(2), std::exp(std::complex<double>(0, phi + lambda)) *
tGate.set(ind_out(2), ind_in(1), std::exp(std::complex<double>(0, phi)) * std::sin(theta / 2.0));
tGate.set(ind_out(2), ind_in(2), std::exp(std::complex<double>(0, phi + lambda)) *
std::cos(theta / 2.0));
legMats[iqbit_in] = tGate * legMats[iqbit_in];
printWavefunc();
Expand Down

0 comments on commit ca6dca8

Please sign in to comment.