Skip to content

Commit

Permalink
Use stdlib ilog2
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelishman authored Jan 12, 2024
1 parent 1b2bea3 commit 0ebec77
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions crates/accelerate/src/sparse_pauli_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ pub fn decompose_dense(
operator: PyReadonlyArray2<Complex64>,
tolerance: f64,
) -> PyResult<ZXPaulis> {
// Can't use `{integer}::ilog2` until Rust 1.67+.
let ilog2 = |val: usize| std::mem::size_of::<usize>() * 8 - val.leading_zeros() as usize - 1;
let num_qubits = ilog2(operator.shape()[0]);
let num_qubits = operator.shape()[0].ilog2() as usize;
let size = 1 << num_qubits;
if operator.shape() != [size, size] {
return Err(PyValueError::new_err(format!(
Expand Down

0 comments on commit 0ebec77

Please sign in to comment.