qiskit-nature icon indicating copy to clipboard operation
qiskit-nature copied to clipboard

Relabel indices of FermionicOp

Open kevinsung opened this issue 3 years ago • 2 comments
trafficstars

What should we add?

FermionicOp should support relabeling its indices according to a permutation. This is useful for performing fermionic swaps virtually.

kevinsung avatar Feb 07 '22 21:02 kevinsung

I believe this would be a useful operation to be implemented on #665

Do you agree, @kevinsung?

mrossinek avatar May 30 '22 06:05 mrossinek

Sure, it could be useful on any class used to represent fermionic operators.

kevinsung avatar May 31 '22 08:05 kevinsung

In order to start planning the implementation of this feature, it would be good to obtain a few usage example/suggestions.

@kevinsung how would you envision this to be used? Are you thinking of something along the lines of what np.transpose can do:

>>> x = np.ones((1, 2, 3))
>>> np.transpose(x, (1, 0, 2)).shape
(2, 1, 3)

Or something entirely different?

mrossinek avatar Nov 14 '22 15:11 mrossinek

Yes, something like that is good. It could be a standalone function or a method. Example: function:

permuted = permute_indices(op, (1, 0, 3, 2))

method:

permuted = op.permute_indices((1, 0, 3, 2))

kevinsung avatar Nov 14 '22 16:11 kevinsung

We need to pick a convention for the permutation ordering, I think whatever np.transpose uses is fine.

kevinsung avatar Nov 14 '22 16:11 kevinsung

I think having this implemented as class methods is preferable as it will need operator-type specific handling unless we only want to (e.g.) support SpinOp labels without exponents. Also the handling in the case of VibrationalOp will need special care as I would expect this to permute modes and not their modals.

So I would go with your second suggestion: op.permute_indices(...). I agree that the ordering can be done the same way as np.transpose does it.

Since this is again a comparatively small feature, I will rename the issue to reflect that any SparseLabelOp subclass should support this in order to ensure feature parity.

mrossinek avatar Nov 14 '22 16:11 mrossinek