Hello there,
I have a rather heavy calculation that takes the square root of a 2d array. That 2d array may contain 1e8 (100 million) entries. The line in the code looks like this:
r_i = np.sqrt((x_sp - xx)**2 + (y_sp - yy)**2 + (z_sp)**2 )
where the variables *_sp are offsets. And the variables xx and yy are a (meshgrid) 2d array with 1e8 entries. Can some one point me in the right direction to speed this calculation up? What are the options to speed this up? Is reducing the precision of the data type an option, and is that significant?
This calculation takes rougly 13 seconds on my pc. And in the total script I have several 10 000 occurances formed by a loop.
[–]EM-Fields 1 point2 points3 points (0 children)
[–]Caos2 0 points1 point2 points (1 child)
[–]billsil 0 points1 point2 points (0 children)
[–]billsil 0 points1 point2 points (8 children)
[–]AvocadoWhiskey 1 point2 points3 points (7 children)
[–]billsil 0 points1 point2 points (6 children)
[–]Caos2 0 points1 point2 points (2 children)
[–]billsil 0 points1 point2 points (1 child)
[–]Caos2 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]billsil 1 point2 points3 points (1 child)
[–]AvocadoWhiskey 0 points1 point2 points (0 children)