qrisp.QuantumDictionary.load#

QuantumDictionary.load(key, value_qv=None, synth_method='gray')[source]#

Loads the values of the QuantumDictionary into a given QuantumVariable.

Parameters:
key_qvQuantumVariable

A QuantumVariable with a decoder supporting the keys of this QuantumDictionary.

value_qvQuantumVariable, optional

The QuantumVariable to load the values into. If given None, a new QuantumVariable is generated.

synth_methodstring, optional

The method of logic synthesis to use for loading. Currently available are “gray”, “gray_pt”, “pprm” and “pprm_pt”. The default is “gray”.

Raises:
Exception

Tried to load value from empty dictionary.

Examples

We create a QuantumDictionary with return type QuantumFloat

>>> from qrisp import QuantumDictionary, QuantumFloat, h
>>> qtype = QuantumFloat(4, -2)
>>> float_qd = QuantumDictionary(return_type = qtype)
>>> float_qd[0] = 1
>>> float_qd[1] = 2

Create the key and the value variable:

>>> key_qv = QuantumFloat(1, signed = False)
>>> h(key_qv)
>>> value_qv = qtype.duplicate()

And load the values

>>> float_qd.load(key_qv, value_qv, synth_method = "pprm")
>>> print(value_qv)
{1.0: 0.5, 2.0: 0.5}