Commit 8dfbc15
committed
Use nalgebra Matrix2 internally in the TwoQubitBasisDecomposer
This commit moves to using Matrix2 as the array type used internally for
the TwoQubitBasisDecomposer. Matrix2 is a fixed size stack allocated
matrix type that has several performance advantages especially for
matmul because the compiler can reason about a fixed number of
operations and better optimize the implementation. Similarly we avoid a
lot of heap allocations. This will improve the runtime performance of
the two qubit basis decomposer.
This is part of the ongoing effort to move to using nalgebra's fixed
size matrix types Matrix4 and Matrix2 inside all of the two qubit
decomposer paths. We will still use faer for the involved linear
algebra such as eigenvalue decomposition where it is faster and more
numerically stable. This doesn't get us all the way to this goal, it's
just another step on the journey.
There are still places in the module that are using ndarray as the array
types, this is mostly because they're used with either the Weyl
decomposition or the one qubit euler decomposition. In particular there
are a couple of duplicate methods either prefixed or postfixed with
nalgebra to either return or convert to/from an nalgebra object which
are temporary while we're in the middle of the transition. The goal is
to remove these as we migrate the rest of the two qubit decomposers to
be using nalgebra for the storage type.1 parent 29fdcad commit 8dfbc15
2 files changed
Lines changed: 242 additions & 198 deletions
0 commit comments