Convert to the matrix.

def to_matrix(self, n_qubits=-1):
        """Convert to the matrix."""
        if n_qubits == -1:
            n_qubits = self.max_n() + 1
        mat = I.to_matrix(n_qubits)
        for op in self.ops:
            if op.is_identity:
                continue
            mat = mat @ op.to_matrix(n_qubits)
        return mat * self.coeff