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

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

[Octave-bug-tracker] [bug #39370] contourc adds duplicates to the start


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #39370] contourc adds duplicates to the start and end of the 1st level
Date: Mon, 25 Jul 2022 16:25:08 -0400 (EDT)

Follow-up Comment #9, bug #39370 (project octave):

ok, according to the discussion linked below, the change in contourc occurred
sometime around matlab 7.4 (2009a).

https://www.mathworks.com/matlabcentral/answers/95263-why-do-contour-and-contourc-produce-different-results-in-matlab-7-8-r2009a

This seems to confirm the problem isn't that contourc _adds_ duplicates, as
that's expected by contour, it's that octave's contourc doesn't trim the dupes
from the matrix. 

a compatibility hack/fix for contourc may just involve applying a unique check
and trim on the output. unfortunately contour still expects the full contourc
output unmodified. perhaps adding a 'legacy' flag to contourc that defaults to
false with the new trimmed output. that would enable continued use of the code
by contour and other functions without breaking them.

Regarding any other issues with the two functions - I also notice  that the
outputs seems to have the same number of points for larger cases, the ordering
is sometimes but not always different (may have the same points but one sorts
with increasing in y while the other sorts decreasing), and contour seems to
throw out some levels that contourc keeps. 

slightly expanding on the simple 3pt example with other levels:

matlab 2022a:

>> x = 0:2;
>> y = x;
>> z = x' * y
z =
     0     0     0
     0     1     2
     0     2     4
>> b = contour (x, y, z, 0:4)
b =
  Columns 1 through 14
    1.0000    0.5000    1.0000    1.0000    2.0000    2.0000    1.0000   
1.0000    2.0000    2.0000    3.0000    1.5000    2.0000    4.0000
    4.0000    2.0000    1.0000    1.0000    0.5000    4.0000    2.0000   
2.0000    1.0000    1.0000    2.0000    2.0000    1.5000    2.0000
  Columns 15 through 16
    2.0000    2.0000
    2.0000    2.0000
>> c = contourc (x, y, z, 0:4)
c =
  Columns 1 through 14
         0         0         0    1.0000    2.0000    1.0000    0.5000   
1.0000    2.0000    2.0000    1.0000    2.0000    3.0000    1.5000
    4.0000    2.0000    1.0000         0         0    3.0000    2.0000   
1.0000    0.5000    2.0000    2.0000    1.0000    2.0000    2.0000
  Columns 15 through 17
    2.0000    4.0000    2.0000
    1.5000    1.0000    2.0000


note contourc keeps the 0 level while contour doesn't, and contourc trims the
dupes from each level while contour leaves them in.  octave currently matches
the output of contour, with no 0 level and dupes left in.  (so maybe the
'legacy' flag would also have to somehow prevent clipping some data levels.
haven't finished stepping through to see where the 0 level currently gets
trimmed out. 


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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