Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: SVD output

Subject: SVD output

From: Bryan

Date: 6 May, 2008 13:22:03

Message: 1 of 5

Matlab's SVD() function yields a result very close to, but
different than the result when using LAPACK's sgesvd()
method in C++. Any idea why? By default, svd uses double-
precision, but I'm using the single precision version of
svd, which, according to Matlab's documentation, utilizes
sgesvd in its computation. Since they both use sgesvd,
shouldn't the results be equal?

I'm using ACML v4.0.1 and Matlab 7.4.0

Thanks,
Bryan

Subject: SVD output

From: Greg Heath

Date: 6 May, 2008 13:30:34

Message: 2 of 5

On May 6, 9:22=A0am, "Bryan " <bdg146.removeT...@gmail.com> wrote:
> Matlab's SVD() function yields a result very close to, but
> different than the result when using LAPACK's sgesvd()
> method in C++. =A0Any idea why? =A0By default, svd uses double-
> precision, but I'm using the single precision version of
> svd, which, according to Matlab's documentation, utilizes
> sgesvd in its computation. =A0Since they both use sgesvd,
> shouldn't the results be equal?
>
> I'm using ACML v4.0.1 and Matlab 7.4.0

How are the results different?

Greg

Subject: SVD output

From: Bryan

Date: 6 May, 2008 13:46:02

Message: 3 of 5

Greg Heath <heath@alumni.brown.edu> wrote in message
> How are the results different?
>
> Greg


Given a <168 x 2> input of single-precision values between
0 and 1:

The max difference between the V output matrices is
1.7881e-7 and the max difference between the U output
matrices is 3.7625e-7. The sigma values are the same.

Computing X(input) - U*S*V' shows that the C++ sgesvd()
output is better than the Matlab SVD() output. However,
that may be pure coincidence and a different input may
yield different results.

Subject: SVD output

From: carlos lopez

Date: 6 May, 2008 15:49:04

Message: 4 of 5

"Bryan " <bdg146.removeThis@gmail.com> wrote in message
<fvpm1r$bps$1@fred.mathworks.com>...
> Matlab's SVD() function yields a result very close to, but
> different than the result when using LAPACK's sgesvd()
> method in C++. Any idea why? By default, svd uses double-
> precision, but I'm using the single precision version of
> svd, which, according to Matlab's documentation, utilizes
> sgesvd in its computation. Since they both use sgesvd,
> shouldn't the results be equal?
>
> I'm using ACML v4.0.1 and Matlab 7.4.0
>
> Thanks,
> Bryan
The uniqueness of SVD decomposition is a recurrent topic.
Google for "svd decomposition not unique".
Anyway, I agree that same routines should (on principle)
agree in their results... unless they resort to other
routines (like rand()) which might differ from machine to
machine and explain the issue.
To be convinced you should check whether or not your present
results agree with the definition (i.e. check that the
product equals the original matrix).
Hope this helps.
Regards

Subject: SVD output

From: Bryan

Date: 6 May, 2008 16:02:31

Message: 5 of 5

"carlos lopez" <clv2clv_00000000_@adinet.com.uy> wrote in
message <fvpulg$rdh$1@fred.mathworks.com>...
> The uniqueness of SVD decomposition is a recurrent topic.
> Google for "svd decomposition not unique".
> Anyway, I agree that same routines should (on principle)
> agree in their results... unless they resort to other
> routines (like rand()) which might differ from machine to
> machine and explain the issue.
> To be convinced you should check whether or not your
present
> results agree with the definition (i.e. check that the
> product equals the original matrix).
> Hope this helps.
> Regards

Thanks for the input.

I understood that the SVD is not unique, but I assumed
that, since the underlying computations are both being
conducted with LAPACK, their solution should be unique. I
understand your point though regarding relying on other,
non-uniform routines though.

I have checked the solution via X-U*S*V' and comparing
that result to 0. However, there seems to be no definite
conclusion as to which gives the better result. For some
data, the C++ output is closer to 0, while for others,
Matlab is closer.

So I suppose getting the C++ svd output to equal the
Matlab svd output isn't really possible?

Tags for this Thread

Everyone's Tags:

svd(2), sgesvd

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
svd carlos lopez 6 May, 2008 11:50:43
sgesvd Bryan 6 May, 2008 09:25:09
svd Bryan 6 May, 2008 09:25:09
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics