graphix
graphix copied to clipboard
Add methods to `Statevec`
The following methods may improve the utility of Statevec:
- [ ]
.inner(): calculate the inner product of two state vectors- return
np.abs(np.dot(sv1.flatten().conjugate(), sv2.flatten()))
- return
- [ ]
.equiv(): checks the equality of two state vectors up to the global phase- add
atolandrtolto parameters to set precision -
ignore_global_phaseoption to ignore the global phase, setTrueas default
- add
- [ ]
.draw(): show state vector in latex format (in jupyter notebook) or text (in command line)- add
formatto parameter ("latex"or"text")
- add
- [ ]
.to_dict(): convertStatevectodictformat
@king-p3nguin
Hi! I have a question about one of the methods you show.
Would you explain the more detail of .to_dict()? I don't grasp the overview of this method.
@masa10-f I was thinking of what Qiskit does in its method: https://qiskit.org/documentation/stubs/qiskit.quantum_info.Statevector.html#qiskit.quantum_info.Statevector.to_dict
The only difference is that graphix adopts bit-endian, whereas Qiskit uses little-endian.