octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #61912] Slow performance of complex()


From: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #61912] Slow performance of complex()
Date: Mon, 24 Jan 2022 17:48:42 -0500 (EST)

Follow-up Comment #2, bug #61912 (project octave):

I am getting the opposite result: calling complex (re, im) is faster than
doing the calculation re + i*im.

Scalar, N = 1:

>> N = 1; re = rand(N,1); im = rand(N,1); tic; z1 = re + i*im; toc, tic; z2 =
complex (re, im); toc, assert(all(z1==z2))
Elapsed time is 1.21593e-05 seconds.     ## time to do re + i*im
Elapsed time is 5.96046e-06 seconds.     ## time to do complex (re, im)


Vector, N = 1e7:

>> N = 1e7; re = rand(N,1); im = rand(N,1); tic; z1 = re + i*im; toc, tic; z2
= complex (re, im); toc, assert(all(z1==z2))

Elapsed time is 0.0973542 seconds.     ## time to do re + i*im
Elapsed time is 0.059479 seconds.      ## time to do complex (re, im)



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61912>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]