Skip to content

Commit

Permalink
update_ops_npair: assert -> runtime_error
Browse files Browse the repository at this point in the history
  • Loading branch information
Glacialte committed Jan 18, 2024
1 parent 5dd3f42 commit 9c6f128
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qulacs/gate/update_ops_npair_qubit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ void fusedswap_gate(UINT target_qubit_index_0,
UINT upper_index, lower_index;
upper_index = std::max(target_qubit_index_0, target_qubit_index_1);
lower_index = std::min(target_qubit_index_0, target_qubit_index_1);
assert(upper_index > (lower_index + block_size - 1));
assert(n_qubits > (upper_index + block_size - 1));
if (n_qubits > (upper_index + block_size - 1)) {
throw std::runtime_error(
"FusedSwap: num of qubits must be bigger than upper_index + block_size - 1");
}
const UINT mask_block = (1 << block_size) - 1;
auto amplitudes = state.amplitudes_raw();
const UINT kblk_mask = mask_block << upper_index;
Expand Down

0 comments on commit 9c6f128

Please sign in to comment.