kernel observe() when operator is fermion operator
Created by: amccaskey
__qpu__ void ansatz(qreg q, double theta) {
X(q[0]);
X(q[2]);
compute {
Rx(q[0], constants::pi / 2);
for (auto i : range(3)) H(q[i + 1]);
for (auto i : range(3)) {
CX(q[i], q[i + 1]);
}
}
action { Rz(q[3], theta); }
}
int main() {
std::string h2_geom = R"#(H 0.000000 0.0 0.0
H 0.0 0.0 .7474)#";
auto H =
createOperator("pyscf", {{"basis", "sto-3g"}, {"geometry", h2_geom}});
OptFunction opt_function(
[&](std::vector<double> x) {
return ansatz::observe(H, qalloc(4), x[0]);
},
1);
opt_function({2.2});
}
This will result in an error stating that nChildren buffers is not equal to n Observable terms. This is due to the fact that the code is executed with a JW Pauli observable but we are still trying to use the fermion observable at qreg.weighted_sum()