diff --git a/src/qibo/callbacks.py b/src/qibo/callbacks.py index 2b45212824..d50c291159 100644 --- a/src/qibo/callbacks.py +++ b/src/qibo/callbacks.py @@ -186,7 +186,7 @@ def apply(self, backend, state): return norm def apply_density_matrix(self, backend, state): - norm = backend.calculate_matrix_norm_density_matrix(state) + norm = backend.calculate_matrix_norm(state) self.append(norm) return norm diff --git a/src/qibo/quantum_info/entropies.py b/src/qibo/quantum_info/entropies.py index 07e77c15f8..f859e07567 100644 --- a/src/qibo/quantum_info/entropies.py +++ b/src/qibo/quantum_info/entropies.py @@ -784,7 +784,7 @@ def renyi_entropy(state, alpha: Union[float, int], base: float = 2, backend=None return ( -1 * backend.np.log2( - backend.calculate_matrix_norm_density_matrix(state, order=2) + backend.calculate_matrix_norm(state, order=2) ) / np.log2(base) ) @@ -892,7 +892,7 @@ def relative_renyi_entropy( new_target = matrix_power(target, 0.5, backend=backend) log = backend.np.log2( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( new_state @ new_target, order=1 ) ) diff --git a/src/qibo/quantum_info/metrics.py b/src/qibo/quantum_info/metrics.py index c67b2655fc..2bd97a595c 100644 --- a/src/qibo/quantum_info/metrics.py +++ b/src/qibo/quantum_info/metrics.py @@ -109,7 +109,7 @@ def trace_distance(state, target, check_hermitian: bool = False, backend=None): if check_hermitian is True: hermitian = bool( float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( backend.np.transpose(backend.np.conj(difference), (1, 0)) - difference, order=2, @@ -440,7 +440,7 @@ def process_fidelity(channel, target=None, check_unitary: bool = False, backend= if check_unitary is True: norm_channel = float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( backend.np.matmul( backend.np.conj(backend.np.transpose(channel, (1, 0))), channel ) @@ -929,7 +929,7 @@ def _check_hermitian(matrix, backend=None): """ backend = _check_backend(backend) - norm = backend.calculate_matrix_norm_density_matrix( + norm = backend.calculate_matrix_norm( backend.np.conj(matrix).T - matrix, order=2 ) diff --git a/src/qibo/quantum_info/quantum_networks.py b/src/qibo/quantum_info/quantum_networks.py index 084eb00571..b37bb63fa6 100644 --- a/src/qibo/quantum_info/quantum_networks.py +++ b/src/qibo/quantum_info/quantum_networks.py @@ -298,7 +298,7 @@ def is_hermitian( adjoint = self._backend.np.transpose(reshaped) mat_diff = self._backend.np.conj(adjoint) - reshaped - norm = self._backend.calculate_matrix_norm_density_matrix(mat_diff, order=order) + norm = self._backend.calculate_matrix_norm(mat_diff, order=order) return float(norm) <= precision_tol diff --git a/src/qibo/quantum_info/superoperator_transformations.py b/src/qibo/quantum_info/superoperator_transformations.py index 7ee898f029..de3d1e4c53 100644 --- a/src/qibo/quantum_info/superoperator_transformations.py +++ b/src/qibo/quantum_info/superoperator_transformations.py @@ -517,7 +517,7 @@ def choi_to_kraus( if validate_cp: norm = float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( choi_super_op - backend.np.conj(choi_super_op).T, order=2 ) ) @@ -2133,7 +2133,7 @@ def function(x0, operators): operator = operator + prob * oper return float( - backend.calculate_matrix_norm_density_matrix(target - operator, order=2) + backend.calculate_matrix_norm(target - operator, order=2) ) # initial parameters as flat distribution diff --git a/src/qibo/transpiler/unitary_decompositions.py b/src/qibo/transpiler/unitary_decompositions.py index 7d109fd473..02668fa7b2 100644 --- a/src/qibo/transpiler/unitary_decompositions.py +++ b/src/qibo/transpiler/unitary_decompositions.py @@ -98,7 +98,7 @@ def calculate_single_qubit_unitaries(psi, backend=None): psi_magic = backend.np.matmul(backend.np.conj(backend.cast(magic_basis)).T, psi) if ( backend.np.real( - backend.calculate_matrix_norm_density_matrix(backend.np.imag(psi_magic)) + backend.calculate_matrix_norm(backend.np.imag(psi_magic)) ) > 1e-6 ): # pragma: no cover diff --git a/tests/test_gates_channels.py b/tests/test_gates_channels.py index 69311c93e5..13bb6a3923 100644 --- a/tests/test_gates_channels.py +++ b/tests/test_gates_channels.py @@ -108,7 +108,7 @@ def test_kraus_channel(backend, pauli_order): backend.assert_allclose( float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( channel.to_liouville(backend=backend) - test_superop, order=2 ) ) @@ -117,7 +117,7 @@ def test_kraus_channel(backend, pauli_order): ) backend.assert_allclose( float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( channel.to_choi(backend=backend) - test_choi, order=2 ) ) @@ -240,7 +240,7 @@ def test_pauli_noise_channel(backend, pauli_order): normalize=True, pauli_order=pauli_order, backend=backend ) norm = float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( backend.to_numpy(liouville) - test_representation, order=2 ) ) @@ -384,7 +384,7 @@ def test_thermal_relaxation_channel(backend, t_1, t_2, time, excpop): backend.assert_allclose( float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( final_state - target_state, order=2 ) ) diff --git a/tests/test_quantum_info_entropies.py b/tests/test_quantum_info_entropies.py index a97a55f0f0..6fe04d756d 100644 --- a/tests/test_quantum_info_entropies.py +++ b/tests/test_quantum_info_entropies.py @@ -590,7 +590,7 @@ def test_renyi_entropy(backend, alpha, base): elif alpha == 1.0: target = von_neumann_entropy(state, base=base, backend=backend) elif alpha == np.inf: - target = backend.calculate_matrix_norm_density_matrix(state, order=2) + target = backend.calculate_matrix_norm(state, order=2) target = -1 * backend.np.log2(target) / np.log2(base) else: target = np.log2( @@ -687,7 +687,7 @@ def test_relative_renyi_entropy(backend, alpha, base, state_flag, target_flag): new_target = matrix_power(target_outer, 0.5, backend=backend) log = backend.np.log2( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( new_state @ new_target, order=1 ) ) diff --git a/tests/test_quantum_info_random.py b/tests/test_quantum_info_random.py index 58a0ecfbc4..84c4216353 100644 --- a/tests/test_quantum_info_random.py +++ b/tests/test_quantum_info_random.py @@ -113,7 +113,7 @@ def test_random_hermitian(backend): matrix = random_hermitian(dims, backend=backend) matrix_dagger = backend.np.conj(matrix).T norm = float( - backend.calculate_matrix_norm_density_matrix(matrix - matrix_dagger, order=2) + backend.calculate_matrix_norm(matrix - matrix_dagger, order=2) ) backend.assert_allclose(norm < PRECISION_TOL, True) @@ -122,7 +122,7 @@ def test_random_hermitian(backend): matrix = random_hermitian(dims, semidefinite=True, backend=backend) matrix_dagger = backend.np.conj(matrix).T norm = float( - backend.calculate_matrix_norm_density_matrix(matrix - matrix_dagger, order=2) + backend.calculate_matrix_norm(matrix - matrix_dagger, order=2) ) backend.assert_allclose(norm < PRECISION_TOL, True) @@ -135,7 +135,7 @@ def test_random_hermitian(backend): matrix = random_hermitian(dims, normalize=True, backend=backend) matrix_dagger = backend.np.conj(matrix).T norm = float( - backend.calculate_matrix_norm_density_matrix(matrix - matrix_dagger, order=2) + backend.calculate_matrix_norm(matrix - matrix_dagger, order=2) ) backend.assert_allclose(norm < PRECISION_TOL, True) @@ -184,7 +184,7 @@ def test_random_unitary(backend, measure): else np.linalg.inv(matrix) ) norm = float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( matrix_inv - matrix_dagger, order=2 ) ) @@ -283,7 +283,7 @@ def test_random_density_matrix(backend, dims, pure, metric, basis, normalize): test = random_density_matrix(dims=dims, normalize=True) else: norm_function = ( - backend.calculate_matrix_norm_density_matrix + backend.calculate_matrix_norm if basis is None else backend.calculate_norm ) @@ -424,7 +424,7 @@ def test_pauli_single(backend): backend.assert_allclose( np.abs( backend.to_numpy( - backend.calculate_matrix_norm_density_matrix(matrix - result, order=2) + backend.calculate_matrix_norm(matrix - result, order=2) ) ) < PRECISION_TOL, @@ -465,7 +465,7 @@ def test_random_pauli( if subset is None: backend.assert_allclose( float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( matrix - result_complete_set, order=2 ) ) @@ -475,7 +475,7 @@ def test_random_pauli( else: backend.assert_allclose( float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( matrix - result_subset, order=2 ) ) @@ -490,7 +490,7 @@ def test_random_pauli( if subset is None: backend.assert_allclose( float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( matrix - result_complete_set, order=2 ) ) @@ -500,7 +500,7 @@ def test_random_pauli( else: backend.assert_allclose( float( - backend.calculate_matrix_norm_density_matrix( + backend.calculate_matrix_norm( matrix - result_subset, order=2 ) )