qrisp.multi_measurement#

multi_measurement(qv_list, shots=None, backend=None)[source]#

This functions facilitates the measurement of multiple QuantumVariables at the same time. This can be used if the entanglement structure between several QuantumVariables is of interest.

Parameters:
qv_listlist[QuantumVariable]

A list of QuantumVariables.

shotsint, optional

The amount of shots to perform. The default is given by the backend used.

backendBackendClient, optional

The backend to evaluate the compiled QuantumCircuit on. By default, the backend from default_backend.py will be used.

Returns:
counts_listlist

A list of tuples. The first element of each tuple is a tuple again and contains the labels of the QuantumVariables. The second element is a float and indicates the probability of measurement.

Raises:
Exception

Tried to perform measurement with open environments.

Examples

We entangle three QuantumFloats via addition and perform a multi-measurement:

>>> from qrisp import QuantumFloat, h, multi_measurement
>>> qf_0 = QuantumFloat(4)
>>> qf_1 = QuantumFloat(4)
>>> qf_0[:] = 3
>>> qf_1[:] = 2
>>> h(qf_1[0])
>>> qf_sum = qf_0 + qf_1
>>> multi_measurement([qf_0, qf_1, qf_sum])
{(3, 2, 5): 0.5, (3, 3, 6): 0.5}