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

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

[Octave-bug-tracker] [bug #61199] Allow 'char' input sets to nchoosek fo


From: Rik
Subject: [Octave-bug-tracker] [bug #61199] Allow 'char' input sets to nchoosek for Matlab compatibility
Date: Sat, 25 Sep 2021 01:02:52 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36

Follow-up Comment #34, bug #61199 (project octave):

The individual calls to nchoosek don't take very long so I put them in a loop
to benchmark it.


N = 1e4;

for i = 1:N
  y = nchoosek (63,19);
endfor


Results are an average of 380 microseconds for the patched code and 85
microseconds for the original code.  Even 380 microseconds is pretty
acceptable, but if you see room for improvement that would be a bonus.  I ran
the profiler on the patched code and I got this


  bm_nchoosek: 1 calls, 5.043 total, 0.166 self
    nchoosek: 10000 calls, 4.877 total, 3.862 self
      1) gcd: 200000 calls, 0.437 total, 0.437 self
      2) max: 200000 calls, 0.387 total, 0.387 self
      3) binary >: 50000 calls, 0.036 total, 0.036 self
      4) prefix !: 50000 calls, 0.026 total, 0.026 self
      5) min: 10000 calls, 0.019 total, 0.019 self
      6) isempty: 30000 calls, 0.014 total, 0.014 self
      7) prod: 10000 calls, 0.013 total, 0.013 self
      8) isscalar: 20000 calls, 0.009 total, 0.009 self
      9) length: 20000 calls, 0.009 total, 0.009 self
      10) fix: 20000 calls, 0.007 total, 0.007 self
      11) isvector: 10000 calls, 0.007 total, 0.007 self
      12) isnumeric: 20000 calls, 0.005 total, 0.005 self
      13) binary !=: 20000 calls, 0.005 total, 0.005 self
      14) prefix -: 20000 calls, 0.004 total, 0.004 self
      15) flintmax: 10000 calls, 0.004 total, 0.004 self
      16) binary ==: 20000 calls, 0.004 total, 0.004 self
      17) nargin: 10000 calls, 0.004 total, 0.004 self
      18) binary <: 20000 calls, 0.004 total, 0.004 self
      19) binary -: 20000 calls, 0.004 total, 0.004 self
      20) isreal: 10000 calls, 0.003 total, 0.003 self
      21) iscomplex: 10000 calls, 0.003 total, 0.003 self
      22) numel: 10000 calls, 0.003 total, 0.003 self
      23) binary >=: 10000 calls, 0.003 total, 0.003 self
      24) binary +: 10000 calls, 0.002 total, 0.002 self


Items 1 (gcd) and 2 (max) are the things to concentrate on.

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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