eclipse / xacc

XACC - eXtreme-scale Accelerator programming framework
https://xacc.readthedocs.io
BSD 3-Clause "New" or "Revised" License
167 stars 86 forks source link

Pauli and Fermion operators add Identity offset when there is a leading +/- sign character #547

Open 1tnguyen opened 2 years ago

1tnguyen commented 2 years ago

Test cases:

  1. Pauli
    TEST(PauliOperatorTester, checkLeadingSignCharacter) {
    std::string src = "- 0.5 Z0 Z1 + 1.2 Z1 Z2";
    PauliOperator op(src);
    std::cout << op.toString() << "\n";
    }

The printout contains an extra +1 offset: (1,0) + (-0.5,-0) Z0 Z1 + (1.2,0) Z1 Z2

  1. Fermion
    TEST(FermionOperatorTester, checkLeadingSignCharacter) {
    std::string src = "+ 0.5 1^ 0 + 1.2 2^ 3";
    FermionOperator op(src);
    std::cout << op.toString() << "\n";
    }

    The printout contains an extra +1 offset: (1,0) + (0.5,0) 1^ 0 + (1.2,0) 2^ 3