Re: null(single_row_vector) causes spurious warning in 6.1.0

Etienne Grossmann via Help-octave <[email protected]>
Newsgroups gmane.comp.gnu.octave.general
Message-ID <[email protected]>

  Hello, 

just to add: below is a snippet that re-creates what null() does. 

It seems the warning in 6.1.0 is legit; 5.2.0 seems lax about the argument of the : operator.

The problem is that diag() has two distinct operations: it turns a vector to a matrix, or vice-versa.

  The patch below fixes this. 

========================
--- /usr/local/share/octave/6.1.0/m/linear-algebra/null.m    2020-12-28 13:16:50.326141734 -0800
+++ null.m    2020-12-31 14:41:11.179056624 -0800
@@ -56,7 +56,11 @@
     [U, S, V] = svd (A);
     out_cls = class (V);

-    s = diag (S);
+    if isvector(S)
+      s = S(:);
+    else
+      s = diag (S);
+    end
     if (nargin == 1)
       tol = max (size (A)) * s (1) * eps (out_cls);
     endif
===========================

  Alternatively, we could have safer diag_matrix() and diag_elements() functions, the latter being used instead of diag() in null(). 

  HTH, 

  Etienne

Etienne Grossmann <[email protected]> (Thu, 31 Dec 2020 13:53:11 -0800) wrote: 

> Hello, 
>
> I see that when null() is passed a single-row vector in Octave 6.1.0, it produces a spurious warning. This warning did not exist in 5.2.0. 
>
>   Thanks for making Octave available, 
>
>   Etienne
>
> -- 
> http://www.isr.ist.utl.pt/~etienne
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.

-- 
http://www.egdn.net/etienne.html

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.