Finding the index of elements of a vector in a mesh quite fast
1 view (last 30 days)
Mohammad Shojaei Arani on 7 Jun 2022
I would like to find the index of vector of numbers A being closest in a mesh. I know how to do this but I hope you have a better idea to speed up the calculations.
An example: Consider a mesh of 10^6 regularly spaced numbers in the interval [0 10] and 10^4 random points A in this interval and we wish to find their corresponding index in our mesh (in the sense of being closest).
So, on average it takes around 0.016923 seconds. I think that there should be a very smart way to do the same task with a much reduced computational time.
Any idea is greatly appreciated!
Thanks in advance,