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

Fix complex cast warning #329

Merged

Conversation

DanPuzzuoli
Copy link
Collaborator

Summary

This PR modifies the code to eliminate complex -> real casting warnings that have popped up at various places.

Details and comments

To do this I've changed code in a couple places in which a tensordot occurs between a real and complex array. The change is essentially converting np.tensordot(x, y) to np.tensordot(x, y.real) + 1j * np.tensordot(x, y.imag) (where x is typically real and y is the complex array).

This eliminated all of the warnings - I'm not 100% sure about efficiency but I'm hoping it shouldn't change anything, as I assume the cost of arithmetic of np.tensordot(x, y) for y complex is twice that of when y is imaginary.

@DanPuzzuoli DanPuzzuoli requested a review from to24toro February 26, 2024 15:20
Copy link
Contributor

@to24toro to24toro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@DanPuzzuoli DanPuzzuoli merged commit 3ed9a11 into qiskit-community:main Mar 1, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants