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

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

[Octave-bug-tracker] [bug #53605] (minor) nonzeros.m can be made twice a


From: Dave Goel
Subject: [Octave-bug-tracker] [bug #53605] (minor) nonzeros.m can be made twice as fast, as follows:
Date: Tue, 10 Apr 2018 14:43:10 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36

URL:
  <http://savannah.gnu.org/bugs/?53605>

                 Summary: (minor) nonzeros.m can be made twice as fast, as
follows: 
                 Project: GNU Octave
            Submitted by: deego
            Submitted on: Tue 10 Apr 2018 06:43:09 PM UTC
                Category: Performance
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
             Assigned to: None
         Originator Name: deego
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.2.2
        Operating System: GNU/Linux

    _______________________________________________________

Details:

It uses the [~,~,b] = find(a) invocation, whereas find doesn't bother to check
if the first two argouts are ignored, and does the calculation any way.


Either find() could be fixed, or nonzeros should switch to the a=find(a)
invocation. 
                                                                              
               



a = randi([0 1], 1e3, 1e3); ## random matrix of 0s and 1s.

tic; 
for ii=1:10;
  [~,~,b] = find(a); ## method used by nonzeros.
  ## Or, b = nonzeros(a);
endfor
toc ## 0.2s

tic; 
for ii=1:10;
  b = a(find(a));
endfor
toc ## 0.2s







    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?53605>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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