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

Bra-ket products produce 1x1 Qobj #63

Closed
stared opened this issue Nov 11, 2013 · 1 comment
Closed

Bra-ket products produce 1x1 Qobj #63

stared opened this issue Nov 11, 2013 · 1 comment
Assignees
Milestone

Comments

@stared
Copy link
Contributor

stared commented Nov 11, 2013

As I see bra-ket products, e.g.

c = basis(2, 0).dag() * basis(2, 0)

result in 1x1 Qobjects, not numbers.

(I know why, as it is compatible with matrix multiplication of 1xn times nx1.)

However, it behaves differently

For example, for

basis(2, 0) * c

works fine, but

c * basis(2, 0)

throws an exception.

On paper, once we get a c-number, we shouldn't care if about its order in the multiplication.

Are there any reasons not to automatically convert 1x1 Qobj into a (complex) number?

@ghost ghost assigned jrjohansson Nov 12, 2013
@jrjohansson
Copy link
Member

Thanks for the bug report. Yes, it should be possible to left and right multiply any Qobj with a 1x1 Qobj, so that's a bug.

Regarding returning a C number, it has been discussed in #28. There is no question that psi.dag() * psi is a C number, but in my opinion it should be a C number represented as 1x1 Qobj, not a Python complex. The reason is that arithmetics with Qobj should form an algebra. It can be important that if x and y is a Qobj then we should always have that x_y is a Qobj as well, so that one always can do for example z=x_y and then z.dims or call some Qobj method on z. If z is not a Qobj this breaks. This is my opinion on this matter, but not everyone agreed. See #28.

jrjohansson added a commit that referenced this issue Nov 12, 2013
splch pushed a commit to splch/qutip that referenced this issue Nov 21, 2023
* supporting orgs updated

* move numfocus to affilliated

* Numfocus in sidebar

* Numfocus sidebar link

* correct spelling affiliated
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

No branches or pull requests

2 participants