Add a helper in math/quantum
to calculate the matrix square root of sparse, hermitian matrices
#6976
+39
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context:
This need arose from #6963 where we realized that
scipy.sparse
could NOT help with a sparsity-preservedsqrtm
as a sparse counterpart of its ownscipy.linalg.sqrtm
using Schur decomposition. Soon we realized that there could be a long list of lost functionality, e.g.eigh
,sqrtm
etc. We would like to update step by step such that when we implement the sparse representation for various matrices we do not have to convert them into dense repr, but this might involve quite some effort considering performance benchmark and lack of references. Therefore, we need some temporary solution that helps with specificOperator
such asBlockEncode
to avoid an explicit cast back to dense, thought the performance might vary.For the$Id - A^\dagger A$ where $A$ is the input matrix to encode into quantum circuits. This is very close to our own
BlockEncode
considered in this PR, it specifically usedsqrtm
for a special class of matricessqrt_matrix
inqml.math.quantum
that deals with the square root computation of a density matrix; our previous dense-matrix algorithm also made this assumption and directly calledsqrt_matrix
in the needed place. Hence we put forward a commonly used iterative method here suitable for similar Hermitian matrices to have square roots.A quick introduction of what is the Denman–Beavers iteration used by this PR can be found at Wikipedia.
Description of the Change:
Provide a new helper in
quantum.py
Benefits:
Enable the sparse version of
BlockEncode
Possible Drawbacks:
No major. This method might have poor performance if used improperly.
Related GitHub Issues:
[sc-84693]