get_z_basis_m

Contents

get_z_basis_m#

iqm.qaoa.tree_calculation.generate_basis.get_z_basis_m(m)#

Generate an array containing the Z basis on a qubit.

Basically, this function is the same as get_z_basis(), but instead of specifying p, here one specifies the length of the basis elements directly. Effectively, the function implements the following line of code, but in a numba-compatible way. .. code-block:: python

return np.array(list(itertools.product([-1, 1], repeat=2 * m)), dtype=np.int8)

Parameters:

m (int) – The length of the basis elements to be generated. There will be \(4^m\) total elements generated.

Returns:

A numpy array of size \(4^m \times 2m\) containing the Z basis.

Return type:

ndarray[tuple[Any, …], dtype[int8]]