Note that there are some explanatory texts on larger screens.

plurals
  1. POCalculation - numpy python bug
    text
    copied!<p>I am using NumPy to do some calculation on finding the Y intercept, through an Aperture between a big box and a small box. I have over 100.000 particles in the big box, and around 1000 in the small one. And it's taking a lot of time to do so. All the self.YD, self.XD are very large arrays that i'm multiplying. </p> <p>PS: The ind are indexes of the values that need to be multiplied. I had a nonzero condition before that line in my code. </p> <p>Any ideas how I would do this calculation in a simpler way?</p> <pre><code>YD_zero = self.oldYD[ind] - ((self.oldYD[ind]-self.YD[ind]) * self.oldXD[ind])/(self.oldXD[ind]-self.XD[ind]) </code></pre> <p>Thanks!</p> <p><strong>UPDATE</strong></p> <p>Would using multiply, divide, subtract and all that stuff of Numpy. make it faster? Or if maybe if i split the calculation. for example.</p> <p>to do this first:</p> <pre><code> YD_zero = self.oldYD[ind] - ((self.oldYD[ind]-self.YD[ind])*self.oldXD[ind]) </code></pre> <p>and then the next line would be:</p> <pre><code> YD_zero /= (self.oldXD[ind]-self.XD[ind]) </code></pre> <p>Any suggestions?!</p> <p><strong>UPDATE 2</strong></p> <p>I have been trying to figure this out, in a while now, but not much progress. My concern is that the denominator :</p> <pre><code> self.oldXL[ind]-self.XL[ind] == 0 </code></pre> <p>and I am getting some weird results.</p> <p>The other thing is the nonzero function. I have been testing it for a while now. Could anybody tell me that it is almost the same as find in Matlab</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload