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?
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
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.
"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
"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?
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.