There is no direct method in Qutip to convert a sparse matrix into a Qobject. However, you can create a Qobj instance using the qutip.Qobj
constructor and passing the sparse matrix as an argument.
Here's an example:
import scipy.sparse as sp
import qutip
# create a sparse matrix
sparse_mat = sp.random(5, 5, density=0.5)
# convert sparse matrix to Qobj
qobj = qutip.Qobj(sparse_mat)
# print Qobj
print(qobj)
This will output something like:
Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = False
Qobj data =
[[ 0.34539206+0.j 0. +0.5881239j 0. +0.j
0. +0.j -0.08114777+0.j ]
[ 0. +0.5881239j -0.22347069+0.j 0. +0.15403432j
0. +0.j -0.09806432+0.j ]
[ 0. +0.j 0. +0.15403432j 0.47391806+0.j
0. +0.j -0.10039413+0.09877974j]
[ 0. +0.j 0. +0.j 0. +0.j
-0.23454739+0.j -0.10518025+0.j ]
[-0.08114777+0.j -0.09806432+0.j -0.10039413-0.09877974j
-0.10518025+0.j -0.48012117+0.j ]]
As you can see, the sparse matrix has been converted to a Qobj instance with the same dimensions and shape.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-13 20:59:54 +0000
Seen: 9 times
Last updated: Jun 13 '23
What is the method for altering the color of the input text in a TextFormField in Flutter?
What is the procedure for utilizing the node-rdpjs library?
What is the method to change a PDF file to an Excel file using C#?
What is the method to make a TextButton inactive when the text field has no text?
What is the method to alter the background image in HTML?
What is the method for saving an entity with @EmbeddedId as its primary key in Hibernate?
What is the method to superimpose two seaborn density plots?