manaakiwhenua / compGeometeR

Implementation of computational geometry algorithms for use in R
GNU General Public License v3.0
5 stars 0 forks source link

find-simplex.R needs optimisation #3

Closed tretherington closed 4 years ago

tretherington commented 4 years ago

The find-simplex.R function isn't executing fast enough to be useful in application - though I can confirm that it is working correctly in 2 and 3 dimensions.

I suspect the nested for loops initiating on lines 62 and 66 are the issue, so it would be great to explore how this process could be optimised through using things like the apply function in R to avoid the for loops and multi-core processing.

It would be ideal if we could keep as much of the code in R so that it is readily accessible, but we could also consider moving the whole process into a C script.

tretherington commented 4 years ago

This has been resolved by reworking the code primarily to:

  1. leverage the matrix algebra that calculates the barycentric coordinates,
  2. process the data by simplex rather than test point, and
  3. using a bounding box data screening process by simplex to reduce the number of test points.

This issue is being closed as the speed up is sufficient for current purposes. If further speed gains are required then parallelisation could be a good option, but we decided this was probably best done by the user level by applying the function to subsets of the desired test points.