qrisp.QuantumArray.encoder#
- QuantumArray.encoder(encoding_array)[source]#
The encoder reverses the decoder, it turns arrays into integers based on the encoder of the
qtype
of this array.- Parameters:
- encoding_array
An array where the entries can be read by the decoder of qtype.
- Returns:
- iint
The integer encoding the given array.
- Raises:
- Exception
Tried to call encoder on array with mismatching shape.
Examples
We create a QuantumArray and inspect it’s encoder:
>>> from qrisp import QuantumArray, QuantumFloat >>> qtype = QuantumFloat(3) >>> q_array = QuantumArray(qtype, (2,2)) >>> print(q_array.encoder(np.eye(2))) 513