Skip to content

Commit

Permalink
replaced threshold by isclose
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoRenaud committed Jun 28, 2024
1 parent a58c041 commit 2039b81
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions vqls_prototype/matrix_decomposition/matrix_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ def __init__(
] = None,
load: Optional[str] = None,
sparse: Optional[bool] = False,
threshold: float = 1e-6,
):
"""Decompose a matrix representing quantum circuits
Expand All @@ -391,10 +390,8 @@ def __init__(
valid only for a circuit with 1 element. Defaults to None.
load (Optional[str]): filename to load the decomposition from
sparse (optional[bool]): use a sparse decomposition
threshold (optional[float]): elements with coefficients smaller than this value will be ignored
"""
self.use_sparse = sparse
self.threshold = threshold
super().__init__(matrix, circuits, coefficients, load)

@staticmethod
Expand Down Expand Up @@ -467,7 +464,7 @@ def decompose_matrix(
coef: complex_array_type = self._get_pauli_coefficient(
self.matrix, pauli_string, self.sparse_matrix
)
if coef * np.conj(coef) >= self.threshold:
if np.isclose(coef * np.conj(coef), 0):
self.strings.append(pauli_string)
coeffs.append(prefactor * coef)
circuits.append(self._create_circuit(pauli_string))
Expand Down

0 comments on commit 2039b81

Please sign in to comment.