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

TensoredOp's to_matrix() returns a wrong value if coeff is not 1 #9398

Closed
y-masaomi opened this issue Jan 20, 2023 · 2 comments · Fixed by #9404
Closed

TensoredOp's to_matrix() returns a wrong value if coeff is not 1 #9398

y-masaomi opened this issue Jan 20, 2023 · 2 comments · Fixed by #9404
Labels
bug Something isn't working mod: opflow Related to the Opflow module

Comments

@y-masaomi
Copy link

Environment

  • Qiskit Terra version:
    0.22.4
  • Python version:
    3.10.4
  • Operating system:
    Ubuntu 20.04.5 LTS

What is happening?

TensoredOp's to_matrix() returns a wrong value if coeff is not 1.

How can we reproduce the issue?

Run the following code:

from qiskit.opflow import Plus, Zero
print((0.5 * (Plus ^ Zero)).to_matrix())

Then, the following will be printed:

[0.1767767+0.j 0.       +0.j 0.1767767+0.j 0.       +0.j]

What should happen?

The following should be printed:

[0.35355339+0.j, 0.        +0.j, 0.35355339+0.j, 0.        +0.j]

Any suggestions?

I think this problem is related to #9283.

@y-masaomi y-masaomi added the bug Something isn't working label Jan 20, 2023
@y-masaomi y-masaomi changed the title TensoredOp's to_matrix() returns a wrong answer. TensoredOp's to_matrix() returns a wrong value if coeff is not 1 Jan 20, 2023
@Cryoris
Copy link
Contributor

Cryoris commented Jan 20, 2023

Good catch! Indeed it seems to be the same kind of error as for the ComposedOp, #9404 should fix this.

@y-masaomi
Copy link
Author

Thank you for your quick response!

@woodsp-ibm woodsp-ibm added the mod: opflow Related to the Opflow module label Jan 20, 2023
@mergify mergify bot closed this as completed in #9404 Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mod: opflow Related to the Opflow module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants