Giter VIP home page Giter VIP logo

Comments (3)

doichanj avatar doichanj commented on July 19, 2024 1

I think AerState is designed to simulate each operation interactively from Python.
And implementations of amplitude and probability is not well optimized and they get only one value per call and they convert binary -> string -> binary inside.
I think we can have some shortcut function to access statevector directly, but I have no idea if it is right way or not and it will be useful. @hhorii how do you think?

from qiskit-aer.

hhorii avatar hhorii commented on July 19, 2024 1

As @doichanj mentioned, AerState is not a public API. But if you want to it to get amplitudes of statevector somehow, I recommend to use move_to_vector. With moved ndarray, a new AerState can be constructed with initialize() method.

aer_state = AerState()
options = AerSimulator._default_options()
for config_key, config_value in configs.items():
if options.get(config_key):
aer_state.configure(config_key, config_value)
if len(init_data) == 0:
raise AerError("initial data must be larger than 0")
num_qubits = int(np.log2(len(init_data)))
aer_state.allocate_qubits(num_qubits)
aer_state.initialize(data=init_data, copy=do_copy)

Again, AerState is an internal class and use it at your own risk.

from qiskit-aer.

aromanro avatar aromanro commented on July 19, 2024

I'm already using move_to_vector as a workaround.

AerState is actually exposed in contrib/runtime (indeed, casted to a void*) and both aer_probability and aer_amplitude call the corresponding functions in AerState.

from qiskit-aer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.