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

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

[Octave-bug-tracker] [bug #60928] Performance of sort unexpectedly slow


From: anonymous
Subject: [Octave-bug-tracker] [bug #60928] Performance of sort unexpectedly slow for DIM=2
Date: Mon, 19 Jul 2021 18:32:12 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0

Follow-up Comment #6, bug #60928 (project octave):

1. The permute approach has the advantage that it can be written once in
libinterp/corefcn/data.cc and it would work for all data types. Doing the skip
calculations and loops looks like it would need to be implemented in multiple
places inside octave-value/ for real, complex, double, single, integer, etc,
even if the code is the same. Is this correct? Or can it too be written in
only one place with templating?

2. A generic permute approach could be:

# arr is the array to be sorted along dimension D
n = ndims(arr);
p = 1:n;
p([1 D]) = p([D 1]);   # p is now the permutation vector exchanging D and 1
returnvalue = ipermute (sort (permute (arr, p), 1), p);   # always sorts on
dimension 1

>From some numerical experiments, this seems to be at least as fast than
calling "sort (arr, D)" directly.

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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