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

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

[Octave-bug-tracker] [bug #65544] cross.m: vector dimension should produ


From: Rik
Subject: [Octave-bug-tracker] [bug #65544] cross.m: vector dimension should produce error, can produce erroneous result
Date: Thu, 4 Apr 2024 14:50:04 -0400 (EDT)

Follow-up Comment #3, bug #65544 (group octave):

Question on coding style, in the very latest cset of 4/1 there is


--- a/scripts/linear-algebra/cross.m
+++ b/scripts/linear-algebra/cross.m
@@ -67,14 +67,14 @@
 
   nd = ndims (x);
 
-  if (nd < 3 && ndims (y) < 3 && nargin < 3)
+  if (nargin < 3 && nd < 3 && ndims (y) < 3)
     ## COMPATIBILITY -- opposite behavior for cross(row,col)
     ## Swap x and y in the assignments below to get the matlab behavior.
     ## Better yet, fix the calling code so that it uses conformant vectors.
-    if (iscolumn (x) && isrow (y))
+    if (columns (x) == 1 && rows (y) == 1)
       warning ("cross: taking cross product of column by row");
       y = y.';
-    elseif (isrow (x) && iscolumn (y))
+    elseif (rows (x) == 1 && columns (y) == 1)
       warning ("cross: taking cross product of row by column");
       x = x.';
     endif


Why is it better to use "rows (x) == 1" rather than "isrow (x)"?  I think
isrow () is clearer, but maybe I'm missing something.  This section is already
constrained only to operate when the objects are 2-D.


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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