bugGNU Octave - Bugs: bug #61305, In linear-algebra/null.m function,...

 
 

bug #61305: In linear-algebra/null.m function, line 63 should use upper case S instead of the lower case s. rank = sum (S > tol)

Submitter:  None
Submitted:  Thu 07 Oct 2021 02:18:07 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Missed Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  Aditya Apte Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 07 Oct 2021 04:17:56 PM UTC, comment #3: 

The issue is actually with the extraction of a single value from a Diagonal Matrix.  This replacement code (diff format) silences the warning message.


-    if (rows (A) > 1)
+    ## Extract column vector from Diagonal Matrix which depends on size
+    if (rows (S) > 1)
       s = diag (S);
     else
-      s = S.';
+      s = S(1);
     end


I checked in a patch on the development branch (http://hg.savannah.gnu.org/hgweb/octave/rev/c14a536a41cd) that will become Octave 7 at the end of the year.

Marking as Fixed and closing report.

Rik <rik5>
Group administrator
Thu 07 Oct 2021 03:33:36 PM UTC, comment #2: 

The following example shows the warning messages produced as a result of using the diagonal matrix S to compute the rank in null.m. 

>> p1 = [1;1];
>> p2 = [2;2];
>> null(p1-p2)

                                                                        ans = [](1x0)

>> p1 = [1,1];
>> p2 = [2,3];
>> null(p1-p2)

warning: colon arguments should be scalars
warning: called from
    null at line 67 column 14

                                                                        ans =
                                                                          -0.8944
                                                                           0.4472

Anonymous
Thu 07 Oct 2021 02:26:48 PM UTC, comment #1: 

@OP, can you provide more context about what you were trying to do, what you got, and what you think the result should be?

For context, the function null.m is reproduced here with line numbers. The line "rank = sum (...." part is on line 66 below.


    41        function Z = null (A, tol)
    42
    43          if (nargin < 1)
    44            print_usage ();
    45          elseif (nargin == 2 && strcmp (tol, "r"))
    46            error ("null: option for rational not yet implemented");
    47          endif
    48
    49          [~, S, V] = svd (A, 0);  # Use economy-sized svd if possible.
    50
    51          ## In case of A = [], zeros (0,X), zeros (X,0) Matlab R2020b seems to
    52          ## simply return the nullspace "V" of the svd-decomposition (bug #59630).
    53          if (isempty (A))
    54            Z = V;
    55          else
    56            out_cls = class (V);
    57
    58            if (rows (A) > 1)
    59              s = diag (S);
    60            else
    61              s = S.';
    62            end
    63            if (nargin == 1)
    64              tol = max (size (A)) * s(1) * eps (out_cls);
    65            endif
    66            rank = sum (s > tol);
    67
    68            cols = columns (A);
    69            if (rank < cols)
    70              Z = V(:, rank+1:cols);
    71              Z(abs (Z) < eps (out_cls)) = 0;
    72            else
    73              Z = zeros (cols, 0, out_cls);
    74            endif
    75          endif
    76
    77        endfunction


Arun Giridhar <arungiridhar>
Group Member
Thu 07 Oct 2021 02:18:07 PM UTC, original submission:  


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 rik5 (Updated the item)
  • -email is unavailable- added by arungiridhar (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-10-07 rik5 StatusNeed Info Fixed
        Open/ClosedOpen Closed
        Release6.3.0 dev
    2021-10-07 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-0329.
    Corresponding source code