Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
17 Views

About linear solver dgetrs

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:

[cpp]

#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;

}

[/cpp]

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.

 

0 Kudos
4 Replies
Highlighted
Employee
17 Views

Hello, 

dgetrs solver the  LU-factored square matrix. It needs first call dgetrf to factor the matrix, then call the function. 

Thanks,
Chao 

0 Kudos
Highlighted
Beginner
17 Views

Hi Chao,

Thanks for the response, dgetrs solved both of them.

Two more questions: 1. does dsytry and dsytrs work in the same way (dsytry goes before dsytrs.)? Does dsytrs take an upper/lower triangle matrix as input or a full matrix? (I tried a bit. But I still cannot make it right.)

 

0 Kudos
Highlighted
Employee
17 Views

Hello,

dsytrf and dsytrs work in the same way: dsytrf goes before dsytrs.

dsytrf/dsytrs take ither the upper or the lower triangular part of the matrix A, depends on the 'uplo' settings, not the full matrix.

Thanks,
Chao

0 Kudos
Highlighted
Beginner
17 Views

Thanks Chao. I'll try it.

0 Kudos