Dear MKL developers and users,
I am learning and coding with MKL linear solver. I went to some tutorials online such as the tutorials for eigensolvers. I am using MSVS 2010 and intel cluster studio. So I think using MKL linear solver dgetrs in a c++ program would like this:
#include <mkl.h> #include <iostream> int _tmain(int argc, _TCHAR* argv[]) { char trans='N'; int n = 3, nrhs = 1, lda = 3, info = 0, ldb = 3; int *ipiv = new int[3](); double a[] = {1.,0.,0.,0.,1.,0.,0.,0.,1.}; double b[] = {3.,4.,5.}; dgetrs( &trans, &n, &nrhs, a, &lda, ipiv, b, &ldb, &info ); std::cout << b[0] << ""<< b[1] << ""<< b[2] << ""<< b[3] << std::endl; }
But the linear solver doesn't work correctly. Since matrix "a" is Identity matrix (row/column major doesn't matter here), I should be able to get 3, 4, 5 as the solution. However, I got two errors:
1. After executed, the numbers in b are
[0] -9.2559631349317831e+061 double
[1] 3.0000000000000000 double
[2] 4.0000000000000000 double
2. On exit, there is a run-time error: Run-Time Check Failure #2 - Stack around the variable 'b' was corrupted.
How do I fix these errors?
Thanks.