$data->{magX}[ $dataIdx ] * cos( $data->{phX}[ $dataIdx ] )
$data->{magY}[ $dataIdx ] * cos( $data->{phY}[ $dataIdx ] )
$data->{magZ}[ $dataIdx ] * cos( $data->{phZ}[ $dataIdx ] )
being performed for all 50 million $data points; and all 50 million being repeated for every one of the "thousands" of $center points. That's 3 * "thousands" * "50.000.000" of redundant, repeated calculations.
Also, whilst I won't pretend to fully understand your code in isolation of what TransfNorVec(), coordSystTransf() & Check() subs do, it seems fairly clear you are checking a bunch of 3D points against another bunch of 3D points and accumulating statistics about how many of the former are within some distance of some of the latter.
And you are going about it by brute force.
With a clearer picture of the data (in $data (what an awful name) and $center), it ought to be possible to order (sort or structure -- perhaps 3-dimensionally) them, so that for any given $input only a small subset of the 'thousands by millions' of comparisons (and associated calculations) need be done.
For example, if the point's X value is 50 and the radius of the compare is 5, there is no point in comparing against any other point who's X-value is outside of 45 thru 55. Sub-setting the larger range early could save billions of calculations, comparisons, object constructions and function calls.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|