Post AXMEKo2kO9NJhVXYJM by kkremitzki@mastodon.social
 (DIR) More posts by kkremitzki@mastodon.social
 (DIR) Post #AXMEKnHxC7wdMNeBNI by juliank@mastodon.social
       2023-07-04T16:31:38Z
       
       0 likes, 0 repeats
       
       So in numpy, if my x is a np.linspace, and I want to write something like:sum k*(i**x) for i from 0 to xhow do I do that
       
 (DIR) Post #AXMEKo2kO9NJhVXYJM by kkremitzki@mastodon.social
       2023-07-04T16:44:30Z
       
       0 likes, 0 repeats
       
       @juliank Assuming one of those x's should be an n, something like `sum(map(lambda i: k*(i**n), x))`
       
 (DIR) Post #AXMEKollglO5x8bVU8 by reto@pleroma.labrat.space
       2023-07-04T17:26:17.961999Z
       
       0 likes, 0 repeats
       
       @kkremitzki @juliank for a numpy array? certainly not right?Using pythons built in map and sum means you force an iterator over the numpy array, rather than using the optimized C code.You really do want to use the numpy functions for that