Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DensityMatrix.partial_transpose does not preserve input dimensions #10155

Closed
diemilio opened this issue May 24, 2023 · 3 comments · Fixed by #10163
Closed

DensityMatrix.partial_transpose does not preserve input dimensions #10155

diemilio opened this issue May 24, 2023 · 3 comments · Fixed by #10163
Labels
bug Something isn't working

Comments

@diemilio
Copy link
Contributor

diemilio commented May 24, 2023

Environment

  • Qiskit Terra version: to be released in 0.24.0
  • Python version: 3.10
  • Operating system: MacOS

What is happening?

The partial_transpose should return a density matrix of the same dimensionality as the input DensityMatrix object. When the dimensions are for systems different than qubits, the dimensions are currently not preserved.

How can we reproduce the issue?

For in the following example, the dimensions of the output density matrix ρ2 are (9,) but they should be (3,3).

>>> import numpy as np
>>> from qiskit.quantum_info import Statevector, DensityMatrix
>>> ψ = Statevector(np.array([1,0,0,0,1,0,0,0,1])*1/np.sqrt(3),dims=(3,3))
>>> ρ1 = DensityMatrix(ψ)
>>> ρ1.dims()
(3, 3)
>>> ρ2 = ρ1.partial_transpose([0])
>>> ρ2.dims()
(9,)

What should happen?

It should be an easy fix. The function should return:

return DensityMatrix(rho, dims=self.dims())

instead of just:

return DensityMatrix(rho)

Any suggestions?

No response

@diemilio diemilio added the bug Something isn't working label May 24, 2023
@jakelishman
Copy link
Member

Thanks, Diego. Would you like to make the PR as well?

@diemilio
Copy link
Contributor Author

Hi @jakelishman. Will do.

@pranay1990
Copy link
Contributor

Thank you @diemilio for bringing this to our attention

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants