Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
P is for Practical
 
PerlMonks  

Re: Sharing statics variable between Threads

by BrowserUk (Pope)
on Aug 30, 2013 at 13:32 UTC ( #1051629=note: print w/ replies, xml ) Need Help??


in reply to Sharing statics variable between Threads

How big are:

  1. @ySurf
  2. @alfas
  3. $data->{count}

How big, or what range of sizes does $center->{count} take?


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: Sharing statics variable between Threads
Select or Download Code
Re^2: Sharing statics variable between Threads
by rodeo (Initiate) on Sep 02, 2013 at 08:05 UTC
    The sizes of @ysurf and @alfas are round about 10...15. $data->{count} more than 50.000.000. The count of center is thousands and more

      Where does $data come from?


      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.

      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.
        You are right, but is Perl effective and fast in sorting the data of the structure? There are functions to do it?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (16)
As of 2014-04-17 16:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (453 votes), past polls