I need to copy the indices from one array to another in C, as efficiently as possible.
For example if I have the array:
datos = [4,8,10,12,15]
Array 2 should give me the following:
indices = [0,1,2,3,4]
In other words, somehow (in the example) the value "4" should be associated with the index "0", the value "8" with the index "1" and so on...
The data will always be ordered from smallest to largest.
The goal would be to make it as efficient as possible, I don't want to use a for, which will give me order n (O(n)).
What I tried to do is a memcpy, but all I managed to do was copy the same array (only the data).
Thank you!!
Example of a for to do what you ask but parallelized with OpenMP.
Compilation example: