I have a system of $N$ qubits and want to construct a quantum operator $Z_i Z_j + Z_k$, where $Z_i$ denotes the Pauli-Z operator acting on the $i$th qubit. Is there any direct way in qiskit, how I could implement this?
I know that I can construct an operator by e.g. saying
op = Z^Z, if I have a system of 2 qubits and want the operator being the Pauli-Z on each qubit. But I would like to tell qiskit the indices of the qubits that $Z$ should act on (such that on all the other qubits Identity is applied).
My way so far consists of constructing a Quantum Circuit and converting this to an operator by
circZZ = QuantumCircuit(N) # circuit for Z_i Z_j circZ = QuantumCircuit(N) # circuit for Z_k circZZ.z(i) circZZ.z(j) circZ.z(k) opZZ = CircuitOp(circZZ) # convert circuit to operator opZ = CircuitOp(circZ) # convert circuit to operator op = opZZ + opZ
But that means I have to create quantum circuits everytime I want to get this operator. Is there any shorter and more elegant way to create such an operator?