Showing results for

- Intel Community
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
- About linear solver dgetrs

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
##

FortCpp

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-26-2013
04:39 PM

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.

4 Replies

Highlighted
##

Chao_Y_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-26-2013
05:17 PM

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

Highlighted
##

FortCpp

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-26-2013
05:45 PM

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.)

Highlighted
##

Chao_Y_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-27-2013
12:50 AM

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

Highlighted
##

FortCpp

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-27-2013
04:30 PM

17 Views

Thanks Chao. I'll try it.

For more complete information about compiler optimizations, see our Optimization Notice.