Skip to content

Commit

Permalink
no truncation when circuit is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Sep 11, 2024
1 parent 41ae7d5 commit f46b08e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/framework/circuit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ void Circuit::reset_metadata() {
void Circuit::add_op_metadata(const Op &op) {
has_conditional |= op.conditional;
opset_.insert(op);
if (op.type == OpType::save_expval || op.type == OpType::save_expval_var) {
if (!qubitset_.empty() &&
(op.type == OpType::save_expval || op.type == OpType::save_expval_var)) {
for (int_t j = 0; j < op.expval_params.size(); j++) {
const std::string &pauli = std::get<0>(op.expval_params[j]);
for (int_t i = 0; i < op.qubits.size(); i++) {
Expand Down Expand Up @@ -609,7 +610,9 @@ void Circuit::set_params(bool truncation) {
int_t nparams = ops[pos].expval_params.size();
for (int_t i = 0; i < nparams; i++) {
std::string &pauli = std::get<0>(ops[pos].expval_params[i]);
pauli.assign(pauli.end() - qubitmap_.size(), pauli.end());
std::string new_pauli;
new_pauli.assign(pauli.end() - qubitmap_.size(), pauli.end());
pauli = new_pauli;
}
ops[pos].qubits.resize(qubitmap_.size());
}
Expand Down

0 comments on commit f46b08e

Please sign in to comment.