Fastest way to calculate exponential [exp()] function of large complex array in Python
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzling Curiosities
--
Chapters
00:00 Fastest Way To Calculate Exponential [Exp()] Function Of Large Complex Array In Python
01:05 Accepted Answer Score 4
01:32 Thank you
--
Full question
https://stackoverflow.com/questions/4652...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #numpy #optimization #ode #numba
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzling Curiosities
--
Chapters
00:00 Fastest Way To Calculate Exponential [Exp()] Function Of Large Complex Array In Python
01:05 Accepted Answer Score 4
01:32 Thank you
--
Full question
https://stackoverflow.com/questions/4652...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #numpy #optimization #ode #numba
#avk47
ACCEPTED ANSWER
Score 4
We could leverage numexpr module, which works really efficiently on large data involving transcendental operations -
In [91]: arr = np.random.rand(2**14) + 1j *np.random.rand(2**14)
...: float_value = 0.5
...:
In [92]: %timeit np.exp(float_value * arr)
1000 loops, best of 3: 739 µs per loop
In [94]: import numexpr as ne
In [95]: %timeit ne.evaluate('exp(float_value*arr)')
1000 loops, best of 3: 241 µs per loop
This seems to be coherent with the expected performance as stated in the docs.