qrisp.QuantumVariable.duplicate#
- QuantumVariable.duplicate(name=None, qs=None, init=False)[source]#
Duplicates the QuantumVariable in the sense that a new QuantumVariable is created with same type and parameters but initialized in the \(\ket{0}\) state.
- Parameters:
- namestring, optional
A unique name to identify that QuantumVariable. If not given, a name will be generated.
- qsQuantumSession, optional
A QuantumSession, where the result should be registered. If not given, a new QuantumSession will be generated.
- initbool, optional
If set to True, the
init_from
method of the result will be called on self. The default is False.
- Returns:
- duplicateType of self
The duplicated QuantumVariable.
Examples
We create a QuantumFloat and duplicate:
>>> from qrisp import QuantumFloat >>> qf_0 = QuantumFloat(4, signed = False) >>> qf_1 = qf_0.duplicate() >>> type(qf_1) qrisp.qtypes.quantum_float.QuantumFloat >>> qf_1.size 4