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

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

[Octave-bug-tracker] [bug #59850] uniquetol missing, so I implemented it


From: Rik
Subject: [Octave-bug-tracker] [bug #59850] uniquetol missing, so I implemented it
Date: Thu, 21 Jan 2021 23:14:51 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36

Update of bug #59850 (project octave):

                  Status:          Ready For Test => In Progress            

    _______________________________________________________

Follow-up Comment #8:

I did some further cleanup of the function in this changeset:
http://hg.savannah.gnu.org/hgweb/octave/rev/83fe13ca9ce3.

uniquetol now validates the inputs more tightly which is in keeping with
Matlab.

I think the algorithm still needs some attention.  I note that 

1. Matlab returns zeros(0,1) rather than [] for empty input.

This is a small consideration.  We could implement this or not.

2. Matlab returns sorted results.

This is a more important consideration.


uniquetol ([3 2 1])
ans = [1 2 3]


3. Matlab returns just one Inf value when multiple occur.


uniquetol ([Inf 1 Inf])
ans = [1 Inf]


4. Performance is very slow (for loop).

I benchmarked uniquetol with this code


tic; c = uniquetol (rand (1e3,1e2), 0.1); toc


Matlab: 0.03 seconds
Octave: 14.0 seconds

This isn't complete (needs to handle ia, ic outputs as well as Inf), but it
points the way to an efficient algorithm.


xs = sort (A(:));
dx = diff (xs);
idx = (dx <= tol);
xs([false; idx]) = [];


This code runs in .03 seconds for me on the benchmark data above.

5. I didn't find "rows" keyword was valid input to uniquetol.

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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