bugGNU Octave - Bugs: bug #60274, GSVD reordering (matlab...

 
 

bug #60274: GSVD reordering (matlab compatibility)

Submitted by:  Leonardo <pocker>
Submitted on:  Tue 23 Mar 2021 11:21:31 AM UTC  
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 16 Nov 2021 07:05:05 PM UTC, comment #1: 

looking specifically at Matlab's Example 1:

A = reshape(1:15,5,3);
B = magic(3);
...
The generalized singular values are the ratios of the diagonal elements of C and S.

sigma = gsvd(A,B)
sigma =
        0.0000
        0.3325
        5.0123

These values are a reordering of the ordinary singular values

svd(A/B)
ans =
        5.0123
        0.3325
        0.0000

in Octave 6.4.0:

>> sigma = gsvd(A,B)
sigma =

   5.0123e+00
   3.3252e-01
   2.5093e-16

>> sigma = svd(A/B)
sigma =

   5.0123e+00
   3.3252e-01
   6.6963e-17

Noting that the other gsvd outputs differ quite a bit from matlab as i believe bug #60273 is addressing, and this did not appear to be mentioned there.

Nicholas Jankowski <nrjank>
Project Member
Tue 23 Mar 2021 11:21:31 AM UTC, original submission:  

Hi.

The ordering of the elements in the output of gsvd is in reverse order compared to Matlab.

After commands

>> A = [1 1 3; 3 1 2; 2 1 1];
>> B = [2 0 1; 2 1 -1;1 0 0];
>> [U, V, X, C, S] = gsvd (A, B);
>> diag(C)

ans =

0.9968
0.6072
0.3022

while in matlab diag(C) produces 0.3022, 0.6072, 0.9968.

A simple workaround is

>> C = diag(flipud(diag(C)));
>> S = diag(flipud(diag(S)));
>> U = fliplr(U);
>> V = fliplr(V);
>> X = fliplr(X);


Side note: matrix X has wrong results. See bug #60273.
https://savannah.gnu.org/bugs/?60273

This affects, at least, v. 6.2.0 and 7.0.0 (4a516dce916c+). Both compiled from source, debian 10.

Kind regards,
Leonardo

Leonardo <pocker>

 

(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 nrjank (Posted a comment)
  • -email is unavailable- added by pocker (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-16 nrjank StatusNone => Confirmed

    Back to the top


    Powered by Savane 3.7