- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
I'm using MKL 6.1 on VC++.
When I use SVD(singular value decomposion) in MKL with function "dgebrd",
I get the wrong answer.
Source code is like this.
#include
#include "include/mkl_lapack.h"
#include "include/mkl_example.h"
#include "include/mkl_example.h"
#define M 4
#define N 3
int main() {
CBLAS_ORDER order = CblasColMajor;
#define N 3
int main() {
CBLAS_ORDER order = CblasColMajor;
int m = M;
int n = N;
int n = N;
double aTrans[M*N] = { 1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12 };
5, 6, 7, 8,
9, 10, 11, 12 };
int lda = m;
double work[64*(M+N)];
int lwork = 64*(M+N);
double q;
double p;
double d;
double e[N-1];
int info;
double p
double d
double e[N-1];
int info;
PrintArrayD(&order, 0, 0, &m, &n, aTrans, &m, "a");
//SVD
dgebrd ( &m, &n, aTrans, &lda,
d, e, q, p, work, &lwork, &info );
dgebrd ( &m, &n, aTrans, &lda,
d, e, q, p, work, &lwork, &info );
if (info !=0) {
printf("Error : %d", info);
return(info);
}
printf("Error : %d", info);
return(info);
}
int one=1;
int nminusone=n-1;
PrintArrayD(&order, 1, 0, &m, &n, aTrans, &lda, "a");
PrintArrayD(&order, 1, 0, &one, &n, d, &n, "d");
PrintArrayD(&order, 1, 0, &one, &nminusone, e, &nminusone, "e");
PrintArrayD(&order, 1, 0, &one, &one, work, &one, "work");
int nminusone=n-1;
PrintArrayD(&order, 1, 0, &m, &n, aTrans, &lda, "a");
PrintArrayD(&order, 1, 0, &one, &n, d, &n, "d");
PrintArrayD(&order, 1, 0, &one, &nminusone, e, &nminusone, "e");
PrintArrayD(&order, 1, 0, &one, &one, work, &one, "work");
return 1;
}
}
Sigular value calculate by MATLAB is
25.4368 1.7226 0.0000
But,the solution of MKL is
-5.477 1.537 1.183
Why do I get the wrong answer?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The function dgebrd reduces a general matrix to bidiagonal form. The function bdsqr computes the singular value decomposition of a general matrix that has been reduced to bidiagonal form. So you are not getting what you expect because you are only doing half the problem. You've reduced the general matrix to bidiagonal form, but not yet called bdsqr to compute the SVD.
I believe that dgesvd function will do all this workfor you in one function call.
-Todd
![](/skins/images/B7BA37F9CE4B52FF7CAE1FB0388839C8/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page