How to re-index of the firstneigh?

Dear lammps developer:
I want to figure out whether list->firstneigh in lammps can be re-indexed. If I want to re-select a list:
I have a list->ilist; I want ilist[2]=13 to become my own defined new_list[2]=2, then for the original ilist[firstneigh[13][i]], this firstneigh[13][i] index should be redefined to new_list[index]. I would like to ask if there is any way for lammps to achieve this?

Your question is rather confusing and missing context. Can you please explain in more detail what you are trying to achieve.

If you want to create a new list from the existing neighbor list, you have to do that yourself. The LAMMPS way of indexing neighbor lists is chosen so that a) memory allocation can be done efficiently in “pages” and b) so that the neighbor list construction can be multi-threaded (each thread works on a different set of “pages”).

The main reason for point a) goes back to the very beginning of when LAMMPS was conceived where some high-end supercomputers had malloc() implementations that were particularly inefficient doing many small allocations.

Of course! Dear Axel,you are always so patient and quick to respond in the community.
I want to write a pair_style for a machine learning potential NEP, in the pair_nep.cpp file void PairNEP::compute have a function nep_model.compute_for_lammps( list->inum, list->ilist, list->numneigh, list->firstneigh, atom->type, atom->x, total_potential, total_virial, per_atom_potential, atom->f, per_atom_virial), if I don’t use the hybrid pair_style, everything is OK, but when I use the hybrid pair_style, this function can’t give a potential and force correctly. So I check the function and find a memory loss, but I don’t know how to solve it, because I’m not very clear about the principle of the equation.
So I thought of a way: If the energy and force can be given correctly in pure pair_style, can I process the data in advance and then add it to my equation, let the function think the input is a pure input and then return the output energy and force to the pointer of lammps?
If I can, which values will return after the part of the pair_style? For example forces, energy and coordination(I’m not sure)?

You are not making any sense here.

When you set up your pair style correctly, the neighbor list should only contain the pairs of the substyles.
For that you pair style needs to define the Pair:setflag array correctly so that for all atom types (or rather elements) that are skipped the setflag[i][j] value is 0 and for all others 1.

See for example the PairAIREBO::coeff() function. Several manybody pair styles (e.g. sw or tersoff) use the convenience function Pair::map_element2type() to do the same.

What do you mean by that?

Using the memcheck tool of valgrind may be helpful here.

This sounds extremely convoluted and hackish. More importantly, it would be unnecessary if your pair style is otherwise programmed correctly.