Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Solving a system of equation

majides
초급자
1,083 조회수
I'm a beginner in using MKL library , Actually I want to solve a system of equation by calling dgetf and dgetrs function , but the segmentation fault error always appear when I run my program. The equation is Ax=B, which A is a dim*dim array and B is a dim array. Here is the part of my program which solves the system of equation
void Solve(int dim, double* A, double* B)
{
int* piv = new int [dim];
int info = 0;
int nhrs = 1;
char p = 'T';
dgetrf(&dim, &dim, A, &dim, piv, &info);
if(info)
{
printf("Fact failed -- %d\\n", info);
for(int i = 0; i < dim; i ++)
{
for(int j = 0; j < dim; j ++)
printf("%e\\t", A[i*dim+j]);
printf("\\n");
}
exit(0);
}
cout<<"\\n","\\n";
dgetrs(&p, &dim, &nhrs, A,&dim, piv, B, &dim, &info);
if(info)
{
printf("Solve failed -- %d\\n", info);
exit(0);
}
free(piv);
}
It would be highly appreciated if you can hel me .
0 포인트
10 응답
mecej4
명예로운 기여자 III
1,083 조회수
You have posted a fragment of a program. There is no point in listing all the possible ways in which that fragment could be expanded into a runnable program that causes a runtime error. Nor is there much to gain from posting one example of code that runs correctly, even though this is quite a bit easier to do.

Present a complete example and you will improve the chances that someone will tell you what the mistakes are.
0 포인트
majides
초급자
1,083 조회수
Thanksfor your comment , I didn't get your meaning , here is the function which should solve my system of equation Ax=B, where A is the Matrix ofcoefficient, and in a n*n array , and b is the right side of my equation which is a n array . This is a complete example forexampleif youputA={1,2,1,2,1,1,1,1,0} and B={230} and send it ti the Sole the error segmentation fault appears.
0 포인트
Gennady_F_Intel
중재자
1,083 조회수
I checked the problem with the version 10.2 Update7. win7. 32bit. No exceptions were found with the inputs you pointed.
for example - see the results after dgetrf
dgetrf passed -- 0
2.000000e+000 5.000000e-001 5.000000e-001
1.000000e+000 1.500000e+000 3.333333e-001
1.000000e+000 5.000000e-001 -6.666667e-001
--Gennady
0 포인트
majides
초급자
1,083 조회수
Thanks for your reply , can you please say me the libraries you have linked ?
0 포인트
mecej4
명예로운 기여자 III
1,083 조회수
B={230} and send it ti the Sole the error segmentation fault appears

B={230} initializes only B[0], leaving B[1] and B[2] unset.

send it ti the Sole

????

0 포인트
majides
초급자
1,083 조회수
sorry I mean B={2,3,0} not {230}.
0 포인트
Gennady_F_Intel
중재자
1,083 조회수
"mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib"
if you need I can send the VS2008 project with yourexample.
0 포인트
majides
초급자
1,083 조회수
Thank you so much, my question is that do you know which libraries are equal to this library in linux version , I'm using a linux version of mkl library so I don't know which library I should link for this new version because the guide library for last version is omitted in this version .
0 포인트
TimP
명예로운 기여자 III
1,083 조회수
Enough has changed since the MKL which had libguide, and enough depends on input from you, that the link advisor at the top of this forum would be better than taking a guess, although basically there's a direct correspondence between libraries needed for Windows and those for linux.
0 포인트
Gennady_F_Intel
중재자
1,083 조회수
See here the direct link to the adviser
0 포인트
응답