Skip to content

Commit ca6dca8

Browse files
author
Thien Nguyen
committed
Fixes for #91
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]>
1 parent 7f9fcee commit ca6dca8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tnqvm/visitors/itensor/mps/ITensorMPSVisitor.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,11 @@ void ITensorMPSVisitor::visit(U &u) {
501501
auto ind_in = ind_for_qbit(iqbit_in);
502502
auto ind_out = itensor::Index(u.name(), 2);
503503
auto tGate = itensor::ITensor(ind_in, ind_out);
504-
tGate.set(ind_in(1), ind_out(1), std::cos(theta / 2.0));
505-
tGate.set(ind_in(1), ind_out(2), -std::exp(std::complex<double>(0, lambda)) *
504+
tGate.set(ind_out(1), ind_in(1), std::cos(theta / 2.0));
505+
tGate.set(ind_out(1), ind_in(2), -std::exp(std::complex<double>(0, lambda)) *
506506
std::sin(theta / 2.0));
507-
tGate.set(ind_in(2), ind_out(1), std::exp(std::complex<double>(0, phi)) * std::sin(theta / 2.0));
508-
tGate.set(ind_in(2), ind_out(2), std::exp(std::complex<double>(0, phi + lambda)) *
507+
tGate.set(ind_out(2), ind_in(1), std::exp(std::complex<double>(0, phi)) * std::sin(theta / 2.0));
508+
tGate.set(ind_out(2), ind_in(2), std::exp(std::complex<double>(0, phi + lambda)) *
509509
std::cos(theta / 2.0));
510510
legMats[iqbit_in] = tGate * legMats[iqbit_in];
511511
printWavefunc();

0 commit comments

Comments
 (0)