BasisState -> statevector array?

Given a bitstring x in [{0,1}^n ], I can compute it’s ket by invoking BasisState(x, wires = range(len(x))). How do I turn that basis state into a 2^n dimensional numpy array?

Hi @cuhrazatee! One way is to use the np.ravel_multi_index() function:

>>> basis_state = np.array([1, 1, 1, 0])
>>> np.ravel_multi_index(basis_state, [2] * len(basis_state))
14