bugGNU Octave - Bugs: bug #63512, does not define the inequality of...

 
 

bug #63512: does not define the inequality of vectors

Submitter:  None
Submitted:  Mon 12 Dec 2022 03:13:39 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Wont Fix Assigned to:  None
Originator Name:  Ruslan Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 7.3.0
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 14 Dec 2022 09:38:48 AM UTC, comment #7: 

Like already stated before, `if` conditions with a non-scalar argument imply an `all`. So, what you are essentially testing is: "Are all elements of `a` different from `b`?" The answer to that question is: No, at least one element is equal.

If you'd like to check if there is at least one element in the two vectors that doesn't compare equal, you'd need to adjust your `if` condition to `any(a != b)`.

Markus Mützel <mmuetzel>
Group administrator
Wed 14 Dec 2022 09:07:28 AM UTC, comment #6: 

Yes, of course, if you use the comparison icon ( == ) in the condition, then using the ELSE branch, you can detect non-equality of vectors.
 But the icon condition ( != ) it should also work as a logical comparison.
 So, I think this is a BUG in OCTAVE and it is desirable to fix it.
 Perhaps this BUG is sitting somewhere very deep and looks like (I checked) in the comparison operation ( != ) the last component of the vector is not checked. That is, if the vector has 3 components and more, then the last component is ignored when checking if( != )
-----------------------
RUSLAN
-----------------------

комментарий №2:

> I have re-written the test code from comment #0 in a way that it runs both under Matlab and under Octave:
>


> clearvars
>
> a(1,1) = 1;
> a(2,1) = 3;
>
> b(1,1) = 1;
> b(2,1) = 2;
>
>
> if (a(:,1) ~= b(:,1))
>  display('NOT EQUAL')
> else
>  display('Not NOT EQUAL')
> end


>
> Running this code under Octave (7.3.0) and under today's online Matlab, I get the SAME result for both: "not NOT EQUAL".
>
> So I would consider the current Octave behavior Matlab compatible, and a change of the result of the above test code would break Matlab compatibility.
>
> Do I miss the point here, or is this issue INVALID?
>
> (Please do let me know why you think that this Octave behavior is a bug, if you still have this opinion, dear original reporter of comment #0.)

Ruslan <ruslan>
Wed 14 Dec 2022 09:03:55 AM UTC, comment #5: 

Yes, of course, if you use the comparison icon ( == ) in the condition, then using the ELSE branch, you can detect non-equality of vectors.
 But the icon condition ( != ) it should also work as a logical comparison.
 So, I think this is a BUG in OCTAVE and it is desirable to fix it.
 Perhaps this BUG is sitting somewhere very deep and looks like (I checked) in the comparison operation ( != ) the last component of the vector is not checked. That is, if the vector has 3 components and more, then the last component is ignored when checking if( != )

(Ruslan - original reporter of comment #0.)

Ruslan <ruslan>
Wed 14 Dec 2022 02:00:13 AM UTC, comment #4: 

The behavior is correct as Octave needs to match Matlab behavior.  The documentation on the "if" statement is in section 10.1 of the Octave manual.  It is documented there that "if (vector) === if (all (vector(:)))".

Marking as Won't Fix and closing.

Rik <rik5>
Group administrator
Tue 13 Dec 2022 09:27:20 PM UTC, comment #3: 

Confirming, both Octave 8.0.1 and Matlab 2022b produce "Not NOT EQUAL" from the test code.

Nicholas Jankowski <nrjank>
Group Member
Tue 13 Dec 2022 08:13:58 PM UTC, comment #2: 

I have re-written the test code from comment #0 in a way that it runs both under Matlab and under Octave:


clearvars

a(1,1) = 1;
a(2,1) = 3;

b(1,1) = 1;
b(2,1) = 2;


if (a(:,1) ~= b(:,1))
 display('NOT EQUAL')
else
 display('Not NOT EQUAL')
end


Running this code under Octave (7.3.0) and under today's online Matlab, I get the SAME result for both: "not NOT EQUAL".

So I would consider the current Octave behavior Matlab compatible, and a change of the result of the above test code would break Matlab compatibility.

Do I miss the point here, or is this issue INVALID?

(Please do let me know why you think that this Octave behavior is a bug, if you still have this opinion, dear original reporter of comment #0.)

Hartmut <hardy>
Tue 13 Dec 2022 04:14:31 AM UTC, comment #1: 

Vectors use all. Use any() or all() or isequal().

Anonymous
Mon 12 Dec 2022 03:13:39 PM UTC, original submission:  

clearvars

a(1,1) = 1;
a(2,1) = 3;

b(1,1) = 1;
b(2,1) = 2;

if(a(:,1) != b(:,1)) display('NOT EQUAL') endif

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by ruslan (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-12-14 rik5 StatusNone Wont Fix
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code