Skip to content

Commit 589137b

Browse files
committed
Optimise SparsePauliOp.from_operator
This rewrites the `from_operator` handling (again!) from the initial Rust implementation of the recursive matrix-addition form into an iterative approach that re-uses the same scratch memory all the way down. This is significantly faster, and allocates far less often, although in practice the peak heap memory usage will be not dissimilar. The algorithm is rewritten to be a manual stack-based iteration, rather than a functional recursion. The size of a single stack entry in the iteration is one `usize`, which is drastically smaller than whatever per-function-call stack will have been used before.
1 parent f14e0b2 commit 589137b

2 files changed

Lines changed: 463 additions & 151 deletions

File tree

0 commit comments

Comments
 (0)