- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am having an issue with dynamic input arguements to the following functions;
LAPACKE_dgelss();
dgetrf();dgetri();
ippmInvert_m_64f();
When the input vector is static A[10 * 10] = {...}; the output is correct namely A inverse. If the same data values are read into a dynamic vector the output is incorrect. Why am I getting this anomally?
Thanks
Vince
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With the very limited information you provided, it's hard to reproduce the problem or guess an explanation. Would you provide a small reproducer? Or, at least show a code snippet calling these functions using static and dynamic arrays? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I will concentrate on one of the functions that I listed, it is used for LU factorization;
lapack_int info;
MKL_INT* ipiv;
double dVandSize = 10;
double* c = ( double * ) malloc ( dVandSize * dVandSize * sizeof ( double ) );
//If input vector c[10 * 10] is a static array with initialized values the function works, if c is dynamic and contains the same values it doesn't work; I included a file called c_vector that contains c;
ipiv = ( MKL_INT * ) malloc ( dVandSize * sizeof ( MKL_INT ) );
dgetrf(&dVandSize,&dVandSize,c,&dVandSize,ipiv,&info); //Computes the LU factorization
double* workspace = new double [dVandSize* sizeof(double)];
dgetri(&dVandSize, c, &dVandSize, ipiv, workspace, &dVandSize, &info);
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, I was not able to reproduce the problem. Both static and dynamic arrays worked fine and gave identical results. See my test code attached.
But a careful look at your code snippet revealed this problem:
[cpp]double dVandSize = 10;[/cpp]
Why was this variable declared as double when it should be an integer? Didn't you get compiler warnings?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But all you did was take a static vector and copy it to a dynamic vector, this works for me too. But how about using
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, dVandSize,ldB, iStrideB, beta , b, iStrideB, a, ldA, alpha, c, ldC); as indicated in my last post, take this c vector and put it into dgetrf() dgetri( ).
Regards,
Vince
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vince,
What do you mean by "c vector"? How is it different than a staitc vector and a dynamic vector? And what does cblas_dgemm have to do with this? Instead of having all of us guessing what you want, it would be much easier to post your whole test code here, please?
By the way, have you got a chance to look at the issue pointed out by other replies on this post? Why is 'dVandSize' a double floating point variable? If you follow DGETRF and DGETRI signatures, this argument should be an integer. Have you tried to make it an integer? Does this solve the problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
the c vector is the dyamic vector that you created, and cblas_dgemm () uses the a vector and b vector to produce the c vector and that is what you use for LU. I have given the 'a' and 'b' vectors in the file c_vector.txt
Regards,
Vince
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe you certainly have taken care of this, and it's probably not related to your original question. But just in case ..., the matrix order in cblas_dgemm can be either row major or column major, but dgetrf and dgetri assume column major matrix order as they are FORTRAN routines.
I'll take another look at it and let you know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
int iVandSize = 10;
double alpha = 1.0;
double beta = 1.0;
int ldA = iVandSize;
int ldB = iVandSize;
int ldC = iVandSize;
int iStrideB = 4;
//cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, iVandSize,ldB, iStrideB, beta , b, iStrideB, a, ldA, alpha, c, ldC);
Thansk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vince,
The matrix produced by cblas_dgemm is very different than the original static matrix you provided. After cblas_dgemm, if you compare the result against the orignal static matrix, the root mean square error is more than 1.5e+02. Therefore, the inputs to the dgetrf call and the subsequent dgetri call are different, and different results are expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
When I use dgemm with vector 'a' and 'b' provided from the file you do not get 'c' with the same data as provided, that makes no sense becasue 'c' is a copy and paste from that function, the order of arguements are;
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, iVandSize,ldB, iStrideB, beta , b, iStrideB, a, ldA, alpha, c, ldC);
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
vincent.ferri wrote:
Hi,
When I use dgemm with vector 'a' and 'b' provided from the file you do not get 'c' with the same data as provided,
This is exactly what I was talking about. Multiplying 'a' and 'b' do not produce the same 'c'. It's not cblas_dgemm problem. I think the call to cblas_dgemm is correct. The order of arguments is correct. The problem is 'a' and 'b'. You need to check why your 'a' and 'b' do not produce the 'c' you expect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Do you get a 10 X 10 matrix or 4 X 4 it should be 10 X 10 since the product is b [10X4] * a[4 X 10].
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I copy/paste exactly the cblas_dgemm call you gave in your post. The result is a 10x10 matrix. But it is different than your reference matrix (the one you gave in your earlier post).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I apoligize for going back and forth, but with the given c_vector file that I attached with vector 'a' and 'b' if you multiply them you do not get vetor 'c' the one in the file. In Matlab b * a = c and cblas_dgemm also gives me the same 'c'. Here is my snippet;
double alpha = 1.0;
double beta = 1.0;
int iVandSize = 10;
int ldA = iVandSize;
int ldB = iVandSize;
int ldC = iVandSize;
int iStrideB = 4;
//C = aphla*A*B + beta*C
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, iVandSize,ldB, iStrideB, beta , b, iStrideB, a, ldA, alpha, c, ldC);
Regards,
P.S is it possible to show me your out put from this call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I apoligize for going back and forth, but with the given c_vector file that I attached with vector 'a' and 'b' if you multiply them you do not get vetor 'c' the one in the file.
I have read this thread with increasing dismay. The use of misleading terms such as "c vector", illogical statements such as this quotation (in mathematics, the product of two vectors is either a scalar -- inner product-- or a matrix -- outer product) makes for much confusion.
Add to that apparent changes in topic from one post to another within the same thread, and we have a thread that should be quarantined, and a new thread opened with some attention to clarity and precision in problem statement.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page