Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
non-sorting SVD

Subject: non-sorting SVD

From: Duccio Testa

Date: 23 May, 2007 11:18:50

Message: 1 of 9

i need to have the singular values diag(S) as in X=U*S*V' in a
non-sorted order: is there a modified svd-like function that does
this?
thanks for your help
duccio testa

Subject: non-sorting SVD

From: Titus

Date: 23 May, 2007 17:30:13

Message: 2 of 9

Hi,
the usual svd does not nessessarily "order" the singular
values, although they often are. But whats wrong with that?

Titus

"Duccio Testa" <duccio.testa@epfl.ch> schrieb im Newsbeitrag
news:ef57d97.-1@webcrossing.raydaftYaTP...
>i need to have the singular values diag(S) as in X=U*S*V' in a
> non-sorted order: is there a modified svd-like function that does
> this?
> thanks for your help
> duccio testa

Subject: non-sorting SVD

From: ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford)

Date: 23 May, 2007 19:00:28

Message: 3 of 9

In article <f31mm5$bcb$1@fred.mathworks.com>, "Titus"
<titus.edelhofer@mathworks.de> wrote:

> Hi,
> the usual svd does not nessessarily "order" the singular
> values, although they often are. But whats wrong with that?
>
> Titus
--------------------
  Hmm! Are you sure you're not thinking of the 'eig' function, Titus?
According to TMW's website, "[U,S,V] = svd(X) produces a diagonal matrix S
of the same dimension as X, with nonnegative diagonal elements in
decreasing order, and .....". I and many other matlab users have been
counting on this to be true for a long time now.

Roger Stafford

Subject: non-sorting SVD

From: Titus

Date: 24 May, 2007 11:38:17

Message: 4 of 9


"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> schrieb im
Newsbeitrag
news:ellieandrogerxyzzy-2305071200280001@dialup-4.232.0.21.dial1.losangeles1.level3.net...
> In article <f31mm5$bcb$1@fred.mathworks.com>, "Titus"
> <titus.edelhofer@mathworks.de> wrote:
>
>> Hi,
>> the usual svd does not nessessarily "order" the singular
>> values, although they often are. But whats wrong with that?
>>
>> Titus
> --------------------
> Hmm! Are you sure you're not thinking of the 'eig' function, Titus?
> According to TMW's website, "[U,S,V] = svd(X) produces a diagonal matrix S
> of the same dimension as X, with nonnegative diagonal elements in
> decreasing order, and .....". I and many other matlab users have been
> counting on this to be true for a long time now.
>
> Roger Stafford

Oops, thanks Roger for pointing this out! This is indeed what I mixed it up
with,
because the question of eigenvalues being sorted comes up quite often...
Yes, you can rely on the singular values being sorted.

I should have gone home earlier yesterday ;-)

But my question is still somewhat right: what is wrong with them being
sorted?
What other order do you want to have them?

Titus

Subject: non-sorting SVD

From: Duccio Testa

Date: 24 May, 2007 05:47:54

Message: 5 of 9

one example: 1000 frequency points, 11 probes: i have therefore 11
elements in diag(S) that svd.m sorts out for me in descending order,
which is very useful if you want to find principal components to
regularise a fit.
however, i need to know the position of these 11 elements in diag(S)
before sorting, because i need to associate these 11 (non-sorted)
eigenvectors to equivalent Fourier harmonics, and which specific ones
are dominant is what i must determine before further calculations.
thanks for your help,
duccio testa

 Titus wrote:
>
>
>
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
> schrieb im
> Newsbeitrag
>
news:ellieandrogerxyzzy-2305071200280001@dialup-4.232.0.21.dial1.los
> angeles1.level3.net...
>> In article <f31mm5$bcb$1@fred.mathworks.com>, "Titus"
>> <titus.edelhofer@mathworks.de> wrote:
>>
>>> Hi,
>>> the usual svd does not nessessarily "order" the singular
>>> values, although they often are. But whats wrong with that?
>>>
>>> Titus
>> --------------------
>> Hmm! Are you sure you're not thinking of the 'eig' function,
> Titus?
>> According to TMW's website, "[U,S,V] = svd(X) produces a
diagonal
> matrix S
>> of the same dimension as X, with nonnegative diagonal elements
in
>> decreasing order, and .....". I and many other matlab users
have
> been
>> counting on this to be true for a long time now.
>>
>> Roger Stafford
>
> Oops, thanks Roger for pointing this out! This is indeed what I
> mixed it up
> with,
> because the question of eigenvalues being sorted comes up quite
> often...
> Yes, you can rely on the singular values being sorted.
>
> I should have gone home earlier yesterday ;-)
>
> But my question is still somewhat right: what is wrong with them
> being
> sorted?
> What other order do you want to have them?
>
> Titus
>
>
>

Subject: non-sorting SVD

From: ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford)

Date: 24 May, 2007 15:34:38

Message: 6 of 9

In article <ef57d97.3@webcrossing.raydaftYaTP>, "duccio testa"
<duccio.testa@epfl.ch> wrote:

> one example: 1000 frequency points, 11 probes: i have therefore 11
> elements in diag(S) that svd.m sorts out for me in descending order,
> which is very useful if you want to find principal components to
> regularise a fit.
> however, i need to know the position of these 11 elements in diag(S)
> before sorting, because i need to associate these 11 (non-sorted)
> eigenvectors to equivalent Fourier harmonics, and which specific ones
> are dominant is what i must determine before further calculations.
> thanks for your help,
> duccio testa
-----------------
  Duccio, what I think you are saying about the eigenvectors from 'svd'
being unsorted is untrue!

  There is always a correspondence in the ordering between the singular
values of 'svd' and its left and right singular vectors. If [u,s,v] =
svd(m), then the first columns of u and v are the left and right singular
vectors, respectively, that correspond to the first singular value in the
diagonal of s, and similarly for the other columns.

  In case the matrix is Hermitian positive semi-definite, these coincide
with the eigenvectors and eigenvalues. Thus, when 'svd' is giving
eigenvectors and eigenvalues, they are both sorted so as to correspond in
this way. The i-th column of u and v give the eigenvector corresponding
to the i-th diagonal eigenvalue in s.

  This contrasts with the 'eig' function which does not necessarily sort
the eigenvalues, (though it does maintain the correspondence in
positioning between eigenvectors and eigenvalues.)

Roger Stafford

Subject: non-sorting SVD

From: Masakazu Iwamura

Date: 18 Nov, 2007 11:43:40

Message: 7 of 9

Hi,

> i need to have the singular values diag(S) as in X=U*S*V' in a
> non-sorted order: is there a modified svd-like function
that does
> this?

I believe you can find the answer from a similar problem:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/156868

Best,
Masakazu

Subject: non-sorting SVD

From: Masakazu Iwamura

Date: 18 Nov, 2007 12:30:13

Message: 8 of 9

Hi,

> I believe you can find the answer from a similar problem:
>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/156868

This seems to be my misunderstanding. Sorry.

Best,
Masakazu

Subject: non-sorting SVD

From: Bruno Luong

Date: 18 Nov, 2007 14:06:20

Message: 9 of 9

"duccio testa" <duccio.testa@epfl.ch> wrote in message
<ef57d97.3@webcrossing.raydaftYaTP>...
> one example: 1000 frequency points, 11 probes: i have
therefore 11
> elements in diag(S) that svd.m sorts out for me in
descending order,
> which is very useful if you want to find principal
components to
> regularise a fit.
> however, i need to know the position of these 11 elements
in diag(S)
> before sorting, because i need to associate these 11
(non-sorted)
> eigenvectors to equivalent Fourier harmonics, and which
specific ones
> are dominant is what i must determine before further
calculations.
> thanks for your help,
> duccio testa
>

But why an "unsorted" singular values is better than sorted
? In which aspect a sorted output causes issue to you ???

If you want an unsorted spectrum, just swap two arbitrary
two singular vectors and values of the output (e.g., the 1st
and 2nd) !

Notice that many of the eigen-algorithms do naturally this
kind of sorting, because the algorithm first search for the
dominant EV/SV space, then deflate this space by changing
the input matrix, then loop until all EV/SV are found.
Naturally those algorithms return a sorted output. However
if it doesn't say in the documentation, then no one should
rely on this property if you care about compatibility, since
Mathworks is free to change the algorithm in the future.

Bruno

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us