Community
cancel
Showing results for
Did you mean: Beginner
117 Views

## Solving a system of equation

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 .
10 Replies Black Belt
117 Views
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. Beginner
117 Views
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. Moderator
117 Views
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 Beginner
117 Views Black Belt
117 Views
B={230} and send it ti the Sole the error segmentation fault appears

B={230} initializes only B, leaving B and B unset.

send it ti the Sole

???? Beginner
117 Views
sorry I mean B={2,3,0} not {230}. Moderator
117 Views
if you need I can send the VS2008 project with yourexample. Beginner
117 Views
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 . Black Belt
117 Views
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. Moderator
117 Views 