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

add output type to qobj.eigenstate #2351

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rochisha0
Copy link
Contributor

Description
Add output_type to qobj.eigenstate() to add return type as both operator as well as kets

Related issues or PRs
fix #2338

Copy link
Member

@Ericgig Ericgig left a comment

Choose a reason for hiding this comment

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

@rochisha0
Please tell us when this is ready to review.
It will need tests with the new option and a towncrier entry.

@coveralls
Copy link

Coverage Status

coverage: 85.863% (-0.05%) from 85.908%
when pulling bd6e70a on rochisha0:edit-eig
into 5cbeb1d on qutip:master.

@rochisha0
Copy link
Contributor Author

@Ericgig I have made the changes upto best of my knowledge, I am not able to figure out how to apply phase fixing to the new operator type.

Also after a few iterations my local build seems to give cython errors, is there a wiki on how to sort that out?

@Ericgig
Copy link
Member

Ericgig commented Mar 18, 2024

Cython error are quite vague, but there should not be any cython error here.
It could be errors inside a cython function. Could you send the log if it persist.

Comment on lines +1545 to +1546
ekets = Qobj(evecs)
norm = ekets.norm()
Copy link
Member

Choose a reason for hiding this comment

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

Closer but still not there.
Dimensions are not set.

The output should be the same as the kets concatenated in a single matrices:

op = qutip.rand_herm(N)
_, kets = op.eigenstates(output_type='kets', phase_fix=M)
_, oper = op.eigenstates(output_type='operator', phase_fix=M)
qutip.Qobj(np.hstack([vec.full() for vec in kets]), dims) == oper

The norm of a matrix, per default it the trace norm: tr(sqrt(A @ A.adjoint())), while for the ket it's l2 norm: sqrt(sum(|a_i|**2)).

For normalization and phase_fix, you may want to take a look into Qobj.inv, qutip.qdiags.

@Ericgig
Copy link
Member

Ericgig commented Apr 10, 2024

@rochisha0 are you still working on this?

@rochisha0
Copy link
Contributor Author

@Ericgig Yes, I'm working on this. Caught up in some tasks, will try to complete over weekend.

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.

Allow returning eigenstates as an operator.
3 participants