Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Sharing statics variable between Threads

by BrowserUk (Pope)
on Sep 02, 2013 at 10:14 UTC ( #1051920=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Sharing statics variable between Threads
in thread Sharing statics variable between Threads

Your code is full of silly inefficiencies; like these 3 calculations:

$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.


Comment on Re^3: Sharing statics variable between Threads
Select or Download Code
Re^4: Sharing statics variable between Threads
by rodeo (Initiate) on Sep 02, 2013 at 11:37 UTC
    You are right, but is Perl effective and fast in sorting the data of the structure? There are functions to do it?
      but is Perl effective and fast in sorting the data of the structure?

      Honorable monk Salva provides numerous functions that can sort just about any perl structure, in just about any way possible, (almost) as fast as C; with a simple and intuitive interface.

      So, yes. Perl can order your data in what ever way you require and save you scads of time.


      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1051920]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (14)
As of 2014-09-30 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (375 votes), past polls