Skip to content

Commit

Permalink
Fix adding qubitset
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Sep 11, 2024
1 parent 51dadef commit b006b32
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/framework/circuit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void Circuit::reset_metadata() {
void Circuit::add_op_metadata(const Op &op) {
has_conditional |= op.conditional;
opset_.insert(op);
if (op.qubits.size() > num_original_qubits) {
if (num_original_qubits > 0 && op.qubits.size() > num_original_qubits) {
qubitset_.insert(op.qubits.begin(),
op.qubits.begin() + num_original_qubits);
} else {
Expand Down Expand Up @@ -602,10 +602,7 @@ 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]);
std::cout << " before truncate : " << pauli << std::endl;
pauli.assign(pauli.end() - qubitmap_.size(), pauli.end());
std::cout << " after truncate : "
<< std::get<0>(ops[pos].expval_params[i]) << std::endl;
}
ops[pos].qubits.resize(qubitmap_.size());
}
Expand Down Expand Up @@ -679,15 +676,12 @@ void Circuit::remap_qubits(Op &op) const {
for (int_t i = 0; i < nparams; i++) {
std::string &pauli = std::get<0>(op.expval_params[i]);
std::string new_pauli;
std::cout << " before remap : " << pauli << std::endl;
new_pauli.resize(qubitmap_.size());
for (auto q = qubitmap_.cbegin(); q != qubitmap_.cend(); q++) {
new_pauli[qubitmap_.size() - 1 - q->second] =
pauli[pauli.size() - 1 - q->first];
}
pauli = new_pauli;
std::cout << " after remap : " << std::get<0>(op.expval_params[i])
<< std::endl;
}
for (int_t i = 0; i < qubitmap_.size(); i++) {
op.qubits[i] = i;
Expand Down

0 comments on commit b006b32

Please sign in to comment.