Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

qiskit.aqua.algorithms.BernsteinVazirani

class BernsteinVazirani(oracle, quantum_instance=None)

GitHub

The Bernstein-Vazirani algorithm.

The Bernstein-Vazirani algorithm is an extension / restriction of the Deutsch-Jozsa algorithm. The goal of the algorithm is to determine a secret string s{0,1}ns \in \{0,1\}^n, given a black box oracle function, that maps f:{0,1}n{0,1}f:\{0,1\}^n \rightarrow \{0,1\} such that f(x)=sx(mod2)f(x)=s \cdot x (\bmod 2).

Parameters

  • oracle (Oracle) – The oracle component
  • quantum_instance (Union[QuantumInstance, Backend, BaseBackend, None]) – Quantum Instance or Backend

__init__

__init__(oracle, quantum_instance=None)

Parameters

  • oracle (Oracle) – The oracle component
  • quantum_instance (Union[QuantumInstance, Backend, BaseBackend, None]) – Quantum Instance or Backend

Methods

__init__(oracle[, quantum_instance])type oracleOracle
construct_circuit([measurement])Construct the quantum circuit
run([quantum_instance])Execute the algorithm with selected backend.
set_backend(backend, **kwargs)Sets backend with configuration.

Attributes

backendReturns backend.
quantum_instanceReturns quantum instance.
randomReturn a numpy random.

backend

Returns backend.

Return type

Union[Backend, BaseBackend]

construct_circuit

construct_circuit(measurement=False)

Construct the quantum circuit

Parameters

measurement (bool) – Boolean flag to indicate if measurement should be included in the circuit.

Returns

the QuantumCircuit object for the constructed circuit

Return type

QuantumCircuit

quantum_instance

Returns quantum instance.

Return type

Optional[QuantumInstance]

random

Return a numpy random.

run

run(quantum_instance=None, **kwargs)

Execute the algorithm with selected backend.

Parameters

  • quantum_instance (Union[QuantumInstance, Backend, BaseBackend, None]) – the experimental setting.
  • kwargs (dict) – kwargs

Returns

results of an algorithm.

Return type

dict

Raises

AquaError – If a quantum instance or backend has not been provided

set_backend

set_backend(backend, **kwargs)

Sets backend with configuration.

Return type

None

Was this page helpful?
Report a bug or request content on GitHub.