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: Rik
Subject: [Octave-bug-tracker] [bug #61912] Slow performance of complex()
Date: Mon, 24 Jan 2022 17:00:33 -0500 (EST)

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

                 Summary: Slow performance of complex()
                 Project: GNU Octave
            Submitted by: rik5
            Submitted on: Mon 24 Jan 2022 02:00:31 PM PST
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Performance
                  Status: Confirmed
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: dev
         Discussion Lock: Any
        Operating System: GNU/Linux

    _______________________________________________________

Details:

I recently benchmarked the complex() function for a scalar and found it very
slow.  I don't know why that is, but either it should be improved or we should
add something to the documentation about alternative constructs to create a
complex number.

Benchmark code was


N = 1e5;

val = pi;

tic;
for i = 1 : N
  z = complex (0, val); 
  #z = 1i * val; 
endfor
bm = toc


Timing on my machine were

complex() : 0.33 seconds
multiply  : 0.08 seconds

It is 4x faster to use multiply to create a complex scalar than the
alternative.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Mon 24 Jan 2022 02:00:31 PM PST  Name: bm_complex.m  Size: 99B   By:
rik5

<http://savannah.gnu.org/bugs/download.php?file_id=52720>

    _______________________________________________________

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]