bugGNU Octave - Bugs: bug #65424, svds(A) returns singular values in...

 
 

bug #65424: svds(A) returns singular values in reversed order for complex A

Submitter:  None
Submitted:  Wed 06 Mar 2024 07:17:42 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Angelika i Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * 8.4.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 09 Mar 2024 05:03:22 AM UTC, comment #3: 

The algorithm switching is probably based on whether a full decomposition is requested (3 output argument) or just the singular values themselves (1 output argument).  Both svds (z) and svds (z,2) sort the singular values in descending order when there is only one output.

Rik <rik5>
Group administrator
Fri 08 Mar 2024 08:49:13 PM UTC, comment #2: 


svds(z,2)

breaks the integer example.

I suspect that there is an algorithm switch. When the full SVD is sought, some other routine such as svd() is called. By default, the leading 6 singular values are returned, i.e., svds(A) without additional arguments seeks a full SVD when n <= 6.

Best,
Angelika

Anonymous
Thu 07 Mar 2024 09:18:15 PM UTC, comment #1: 

Confirmed.  Changing Item Group to "Matlab Compatibility".

Additional information, svds() can return just the singular values, rather than the full decomposition.  When only one output is requested, Octave does return a list sorted in descending order.

Secondly, not all complex matrices are sorted in ascending order.  The example below (generated with random integers), works.


x = [
   35   19   41   29
   25    4   30   50
   55   49    5   37
   59   47   22    9
];

y = [
   63   53    1   33
   13   38   24   17
   20   54   32   57
   25   17   60   59
];
z = complex (x,y);

[U,S,V] = svds (z)



Rik <rik5>
Group administrator
Wed 06 Mar 2024 07:17:42 PM UTC, original submission:  

svds() returns the singular values in ascending order for complex matrices. By definition, the singular values should appear in descending order.

Reproducer:

n = 8;
A = rand(n,n) + 1i * rand(n,n);
[U, S, V] = svds(A);
diag(S)  % sorted from small to large, should be sorted from large to small


Notes:
(1) For a real input matrix A, the singular values are sorted as expected in descending order.
(2) svds() in Matlab 2022 returns S in descending order for both real and complex matrices.






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 (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-03-07 rik5 Item GroupIncorrect Result Matlab Compatibility
        StatusNone Confirmed
        Originator NameAngelika Angelika i

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code