@property
def matrix(self):
    'Matrix representation of the tensor operator\n        in the computational basis.\n\n        **Example:**\n\n        Note that the returned matrix *only includes explicitly\n        declared observables* making up the tensor product;\n        that is, it only returns the matrix for the specified\n        subsystem it is defined for.\n\n        >>> O = qml.PauliZ(0) @ qml.PauliZ(2)\n        >>> O.matrix\n        array([[ 1,  0,  0,  0],\n               [ 0, -1,  0,  0],\n               [ 0,  0, -1,  0],\n               [ 0,  0,  0,  1]])\n\n        To get the full :math:`2^3\\times 2^3` Hermitian matrix\n        acting on the 3-qubit system, the identity on wire 1\n        must be explicitly included:\n\n        >>> O = qml.PauliZ(0) @ qml.Identity(1) @ qml.PauliZ(2)\n        >>> O.matrix\n        array([[ 1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],\n               [ 0., -1.,  0., -0.,  0., -0.,  0., -0.],\n               [ 0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.],\n               [ 0., -0.,  0., -1.,  0., -0.,  0., -0.],\n               [ 0.,  0.,  0.,  0., -1., -0., -0., -0.],\n               [ 0., -0.,  0., -0., -0.,  1., -0.,  0.],\n               [ 0.,  0.,  0.,  0., -0., -0., -1., -0.],\n               [ 0., -0.,  0., -0., -0.,  0., -0.,  1.]])\n\n        Returns:\n            array: matrix representation\n        '
    U_list = []
    for (_, g) in itertools.groupby(self.obs, (lambda x: x.wires.labels)):
        mats = [i.matrix for i in g]
        if (len(mats) > 1):
            mats = [multi_dot(mats)]
        U_list.append(mats[0])
    return functools.reduce(np.kron, U_list)
Matrix representation of the tensor operator
in the computational basis.

**Example:**

Note that the returned matrix *only includes explicitly
declared observables* making up the tensor product;
that is, it only returns the matrix for the specified
subsystem it is defined for.

>>> O = qml.PauliZ(0) @ qml.PauliZ(2)
>>> O.matrix
array([[ 1,  0,  0,  0],
       [ 0, -1,  0,  0],
       [ 0,  0, -1,  0],
       [ 0,  0,  0,  1]])

To get the full :math:`2^3\times 2^3` Hermitian matrix
acting on the 3-qubit system, the identity on wire 1
must be explicitly included:

>>> O = qml.PauliZ(0) @ qml.Identity(1) @ qml.PauliZ(2)
>>> O.matrix
array([[ 1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0., -1.,  0., -0.,  0., -0.,  0., -0.],
       [ 0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.],
       [ 0., -0.,  0., -1.,  0., -0.,  0., -0.],
       [ 0.,  0.,  0.,  0., -1., -0., -0., -0.],
       [ 0., -0.,  0., -0., -0.,  1., -0.,  0.],
       [ 0.,  0.,  0.,  0., -0., -0., -1., -0.],
       [ 0., -0.,  0., -0., -0.,  0., -0.,  1.]])

Returns:
    array: matrix representation
@property
def matrix(self):
    'Matrix representation of the tensor operator\n        in the computational basis.\n\n        **Example:**\n\n        Note that the returned matrix *only includes explicitly\n        declared observables* making up the tensor product;\n        that is, it only returns the matrix for the specified\n        subsystem it is defined for.\n\n        >>> O = qml.PauliZ(0) @ qml.PauliZ(2)\n        >>> O.matrix\n        array([[ 1,  0,  0,  0],\n               [ 0, -1,  0,  0],\n               [ 0,  0, -1,  0],\n               [ 0,  0,  0,  1]])\n\n        To get the full :math:`2^3\\times 2^3` Hermitian matrix\n        acting on the 3-qubit system, the identity on wire 1\n        must be explicitly included:\n\n        >>> O = qml.PauliZ(0) @ qml.Identity(1) @ qml.PauliZ(2)\n        >>> O.matrix\n        array([[ 1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],\n               [ 0., -1.,  0., -0.,  0., -0.,  0., -0.],\n               [ 0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.],\n               [ 0., -0.,  0., -1.,  0., -0.,  0., -0.],\n               [ 0.,  0.,  0.,  0., -1., -0., -0., -0.],\n               [ 0., -0.,  0., -0., -0.,  1., -0.,  0.],\n               [ 0.,  0.,  0.,  0., -0., -0., -1., -0.],\n               [ 0., -0.,  0., -0., -0.,  0., -0.,  1.]])\n\n        Returns:\n            array: matrix representation\n        '
    U_list = []
    for (_, g) in itertools.groupby(self.obs, (lambda x: x.wires.labels)):
        mats = [i.matrix for i in g]
        if (len(mats) > 1):
            mats = [multi_dot(mats)]
        U_list.append(mats[0])
    return functools.reduce(np.kron, U_list)