Skip to main content
Functions:

binary_to_one_hot

binary_to_one_hot(
binary: Input[QNum],
one_hot: Output[QArray]
) -> None
Conversion of binary encoded value to one-hot encoding. The output one_hot variable is of size 2^n, where n is the number of bits in the binary representation. For example, the state |01>=|2> will be converted to |0010> (one-hot for 2). Parameters:

binary_to_unary

binary_to_unary(
binary: Input[QNum],
unary: Output[QArray]
) -> None
Conversion of binary encoded value to unary encoding. The output unary variable is of size 2^n - 1, where n is the number of bits in the binary representation. For example, the state |01>=|2> will be converted to |110> (unary for 2). Parameters:

one_hot_to_unary

one_hot_to_unary(
one_hot: Input[QArray],
unary: Output[QArray]
) -> None
Conversion of one-hot encoded value to unary encoding. The output unary variable is smaller in 1 qubit than the input one_hot variable. For example, the state |0010> (one-hot for 2) will be converted to |110> (unary for 2). Parameters:

one_hot_to_binary

one_hot_to_binary(
one_hot: Input[QArray],
binary: Output[QNum[Literal[‘ceiling(log(one_hot.len, 2))’]]]
) -> None
Conversion of one-hot encoded value to binary encoding. The output binary variable is of size log2(one_hot.size) rounded up. For example, the state |0010> (one-hot for 2) will be converted to |01>=|2>. Parameters:

unary_to_one_hot

unary_to_one_hot(
unary: Input[QArray],
one_hot: Output[QArray]
) -> None
Conversion of unary encoded value to one-hot encoding. The output one_hot variable is larger in 1 qubit than the input unary variable. For example, the state |110> (unary for 2) will be converted to |0010> (one-hot for 2). Parameters:

unary_to_binary

unary_to_binary(
unary: Input[QArray],
binary: Output[QNum]
) -> None
Conversion of unary encoded value to binary encoding. The output binary variable is of size log2(unary.size + 1) rounded up. For example, the state |110> (unary for 2) will be converted to |01>=|2>. Parameters:

inplace_binary_to_one_hot

inplace_binary_to_one_hot(
qvar: QArray
) -> None
Inplace conversion of binary encoded value to one-hot encoding. The implementation is based on https://quantumcomputing.stackexchange.com/questions/5526/garbage-free-reversible-binary-to-unary-decoder-construction. The input is assumed to be of size 2^n, where n is the number of bits in the binary representation. For example, the state |01000>=|2> will be converted to |00100> (one-hot for 2). Parameters:

inplace_one_hot_to_unary

inplace_one_hot_to_unary(
qvar: QArray
) -> None
Inplace conversion of one-hot encoded value to unary encoding. The input is assumed to be of size n, where n is the number of bits in the one-hot representation. The remaining unary representation will at the higher n-1 bits, where the lsb is cleared to 0. For example, the state |0010> (one-hot for 2) will be converted to |0>``|110> (unary for 2). Parameters:

pad_zeros

pad_zeros(
total_size: int,
qvar: Input[QArray],
padded: Output[QArray]
) -> None
Pad the input qvar with additional qubits at the end to reach the total_size. Parameters: