cirq.has_unitary

Determines whether the value has a unitary effect.

Used in the notebooks

Used in the tutorials

Determines whether val has a unitary effect by attempting the following strategies:

  1. Try to use val.has_unitary(). Case a) Method not present or returns NotImplemented. Inconclusive. Case b) Method returns True. Unitary. Case c) Method returns False. Not unitary.

  2. Try to use val._decompose_(). Case a) Method not present or returns NotImplemented or None. Inconclusive. Case b) Method returns an OP_TREE containing only unitary operations. Unitary. Case c) Method returns an OP_TREE containing non-unitary operations. Not Unitary.

  3. Try to use val._apply_unitary_(args). Case a) Method not present or returns NotImplemented. Inconclusive. Case b) Method returns a numpy array. Unitary. Case c) Method returns None. Not unitary.

  4. Try to use val._unitary_(). Case a) Method not present or returns NotImplemented. Continue to next strategy. Case b) Method returns a numpy array. Unitary. Case c) Method returns None. Not unitary.

It is assumed that, when multiple of these strategies give a conclusive result, that these results will all be consistent with each other. If all strategies are inconclusive, the value is classified as non-unitary.

The value that may or may not have a unitary effect.

Whether or not val has a unitary effect.