'Represent the SWAP gate in the computational basis.
The following representation is used to compute this:
SWAP = |1><1|x|1><1| + |0><0|x|0><0| + |1><0|x|0><1| + |0><1|x|1><0|'

def _represent_ZGate(self, basis, **options):

    format = options.get('format', 'sympy')
    targets = [int(t) for t in self.targets]
    min_target = _min(targets)
    max_target = _max(targets)
    nqubits = options.get('nqubits', self.min_qubits)
    op01 = matrix_cache.get_matrix('op01', format)
    op10 = matrix_cache.get_matrix('op10', format)
    op11 = matrix_cache.get_matrix('op11', format)
    op00 = matrix_cache.get_matrix('op00', format)
    eye2 = matrix_cache.get_matrix('eye2', format)
    result = None
    for (i, j) in ((op01, op10), (op10, op01), (op00, op00), (op11, op11)):
        product = (nqubits * [eye2])
        product[((nqubits - min_target) - 1)] = i
        product[((nqubits - max_target) - 1)] = j
        new_result = matrix_tensor_product(*product)
        if (result is None):
            result = new_result
        else:
            result = (result + new_result)
    return result
