qiskit-documentation/docs/api/qiskit/0.26/qiskit.providers.basicaer.S...

237 lines
10 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: StatevectorSimulatorPy (v0.26)
description: API reference for qiskit.providers.basicaer.StatevectorSimulatorPy in qiskit v0.26
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.providers.basicaer.StatevectorSimulatorPy
---
<span id="qiskit-providers-basicaer-statevectorsimulatorpy" />
# qiskit.providers.basicaer.StatevectorSimulatorPy
<Class id="qiskit.providers.basicaer.StatevectorSimulatorPy" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.17/qiskit/providers/basicaer/statevector_simulator.py" signature="StatevectorSimulatorPy(configuration=None, provider=None, **fields)" modifiers="class">
Python statevector simulator.
Initialize a backend class
**Parameters**
* **configuration** ([*BackendConfiguration*](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration")) A backend configuration object for the backend object.
* **provider** ([*qiskit.providers.Provider*](qiskit.providers.Provider "qiskit.providers.Provider")) Optionally, the provider object that this Backend comes from.
* **fields** kwargs for the values to use to override the default options.
**Raises**
**AttributeError** if input field not a valid options
### \_\_init\_\_
<Function id="qiskit.providers.basicaer.StatevectorSimulatorPy.__init__" signature="__init__(configuration=None, provider=None, **fields)">
Initialize a backend class
**Parameters**
* **configuration** ([*BackendConfiguration*](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration")) A backend configuration object for the backend object.
* **provider** ([*qiskit.providers.Provider*](qiskit.providers.Provider "qiskit.providers.Provider")) Optionally, the provider object that this Backend comes from.
* **fields** kwargs for the values to use to override the default options.
**Raises**
**AttributeError** if input field not a valid options
</Function>
## Methods
| | |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------ |
| [`__init__`](#qiskit.providers.basicaer.StatevectorSimulatorPy.__init__ "qiskit.providers.basicaer.StatevectorSimulatorPy.__init__")(\[configuration, provider]) | Initialize a backend class |
| [`configuration`](#qiskit.providers.basicaer.StatevectorSimulatorPy.configuration "qiskit.providers.basicaer.StatevectorSimulatorPy.configuration")() | Return the backend configuration. |
| [`name`](#qiskit.providers.basicaer.StatevectorSimulatorPy.name "qiskit.providers.basicaer.StatevectorSimulatorPy.name")() | Return the backend name. |
| [`properties`](#qiskit.providers.basicaer.StatevectorSimulatorPy.properties "qiskit.providers.basicaer.StatevectorSimulatorPy.properties")() | Return the backend properties. |
| [`provider`](#qiskit.providers.basicaer.StatevectorSimulatorPy.provider "qiskit.providers.basicaer.StatevectorSimulatorPy.provider")() | Return the backend Provider. |
| [`run`](#qiskit.providers.basicaer.StatevectorSimulatorPy.run "qiskit.providers.basicaer.StatevectorSimulatorPy.run")(qobj, \*\*backend\_options) | Run qobj asynchronously. |
| [`run_experiment`](#qiskit.providers.basicaer.StatevectorSimulatorPy.run_experiment "qiskit.providers.basicaer.StatevectorSimulatorPy.run_experiment")(experiment) | Run an experiment (circuit) and return a single experiment result. |
| [`set_options`](#qiskit.providers.basicaer.StatevectorSimulatorPy.set_options "qiskit.providers.basicaer.StatevectorSimulatorPy.set_options")(\*\*fields) | Set the options fields for the backend |
| [`status`](#qiskit.providers.basicaer.StatevectorSimulatorPy.status "qiskit.providers.basicaer.StatevectorSimulatorPy.status")() | Return the backend status. |
## Attributes
| | |
| --------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |
| `DEFAULT_CONFIGURATION` | |
| `DEFAULT_OPTIONS` | |
| `MAX_QUBITS_MEMORY` | |
| `SHOW_FINAL_STATE` | |
| [`options`](#qiskit.providers.basicaer.StatevectorSimulatorPy.options "qiskit.providers.basicaer.StatevectorSimulatorPy.options") | Return the options for the backend |
| `version` | |
### configuration
<Function id="qiskit.providers.basicaer.StatevectorSimulatorPy.configuration" signature="configuration()">
Return the backend configuration.
**Returns**
the configuration for the backend.
**Return type**
[BackendConfiguration](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration")
</Function>
### name
<Function id="qiskit.providers.basicaer.StatevectorSimulatorPy.name" signature="name()">
Return the backend name.
**Returns**
the name of the backend.
**Return type**
str
</Function>
### options
<Attribute id="qiskit.providers.basicaer.StatevectorSimulatorPy.options">
Return the options for the backend
The options of a backend are the dynamic parameters defining how the backend is used. These are used to control the [`run()`](#qiskit.providers.basicaer.StatevectorSimulatorPy.run "qiskit.providers.basicaer.StatevectorSimulatorPy.run") method.
</Attribute>
### properties
<Function id="qiskit.providers.basicaer.StatevectorSimulatorPy.properties" signature="properties()">
Return the backend properties.
**Returns**
the configuration for the backend. If the backend does not support properties, it returns `None`.
**Return type**
[BackendProperties](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties")
</Function>
### provider
<Function id="qiskit.providers.basicaer.StatevectorSimulatorPy.provider" signature="provider()">
Return the backend Provider.
**Returns**
the Provider responsible for the backend.
**Return type**
[Provider](qiskit.providers.Provider "qiskit.providers.Provider")
</Function>
### run
<Function id="qiskit.providers.basicaer.StatevectorSimulatorPy.run" signature="run(qobj, **backend_options)">
Run qobj asynchronously.
**Parameters**
* **qobj** ([*Qobj*](qiskit.qobj.Qobj "qiskit.qobj.Qobj")) payload of the experiment
* **backend\_options** (*dict*) backend options
**Returns**
derived from BaseJob
**Return type**
[BasicAerJob](qiskit.providers.basicaer.BasicAerJob "qiskit.providers.basicaer.BasicAerJob")
**Additional Information:**
**backend\_options: Is a dict of options for the backend. It may contain**
* “initial\_statevector”: vector\_like
The “initial\_statevector” option specifies a custom initial initial statevector for the simulator to be used instead of the all zero state. This size of this vector must be correct for the number of qubits in all experiments in the qobj.
Example:
```python
backend_options = {
"initial_statevector": np.array([1, 0, 0, 1j]) / np.sqrt(2),
}
```
</Function>
### run\_experiment
<Function id="qiskit.providers.basicaer.StatevectorSimulatorPy.run_experiment" signature="run_experiment(experiment)">
Run an experiment (circuit) and return a single experiment result.
**Parameters**
**experiment** (*QobjExperiment*) experiment from qobj experiments list
**Returns**
A result dictionary which looks something like:
```python
{
"name": name of this experiment (obtained from qobj.experiment header)
"seed": random seed used for simulation
"shots": number of shots used in the simulation
"data":
{
"counts": {'0x9: 5, ...},
"memory": ['0x9', '0xF', '0x1D', ..., '0x9']
},
"status": status string for the simulation
"success": boolean
"time_taken": simulation time of this single experiment
}
```
**Return type**
dict
**Raises**
[**BasicAerError**](qiskit.providers.basicaer.BasicAerError "qiskit.providers.basicaer.BasicAerError") if an error occurred.
</Function>
### set\_options
<Function id="qiskit.providers.basicaer.StatevectorSimulatorPy.set_options" signature="set_options(**fields)">
Set the options fields for the backend
This method is used to update the options of a backend. If you need to change any of the options prior to running just pass in the kwarg with the new value for the options.
**Parameters**
**fields** The fields to update the options
**Raises**
**AttributeError** If the field passed in is not part of the options
</Function>
### status
<Function id="qiskit.providers.basicaer.StatevectorSimulatorPy.status" signature="status()">
Return the backend status.
**Returns**
the status of the backend.
**Return type**
[BackendStatus](qiskit.providers.models.BackendStatus "qiskit.providers.models.BackendStatus")
</Function>
</Class>