Showing results for 
Search instead for 
Did you mean: 

Problem while solving Ax=B with Pardiso

I have a problem with solving system of linear equations using Pardiso. I have application in which one of the processes loads dll where system of linear equations Ax=B is solved using Pardiso. There are two cases:
- First case - Application is started. Matrix A and B are populated with some values, and after that matrix A is factorized so that equation Ax=B can be solved. After resolving, I get solution x and write it to the file. Values in x are very suspicious, there is a lot of values which are larger than 10^4. They will be used later for some calculation in iterations.
- Second case - After execution in first case, I kill the process (in Task Manager) which loads dll (in which equations are solved), and process is restarted and the same dll is loaded. After executing my application again, same equation is solved, but x is not the same (and this new values seem better). I don't get it why solution is not the same in both cases when everything about matrix is the same?
I have logged all the matrices and vectors (and attached them). What can be seen is that when I compare A, x and B there is a difference in x, and A and B are the same in both cases. How can solver for two same inputs give two different solutions? I don't now what killing the process and loading dll did, but after that x is not same when equation is solved. Maybe there is some problem with memory or something similar. 
Matrix A is sparse matrix and is indefinite. Matrix type is -2 and Pardiso call is as following:
call pardiso(matrix%handle, 1, 1, & !handle
   matrix%matrixType,      & !Matrix type
   33,                                & !3 = solve
   matrix%numRows,         & !Dimension
   matrix%values,                     & !Values
   matrix%firstInRow,      & !Row cummulative
   matrix%columns,         & !Column indices
   [0],                               & !permutation (none)
   1,                                 & !Number of RHS equations (1)
   opt,                               & !Options (default)
   0,                                 & !Message level (none)
   rhs,                               & !RHS
   solution,                          & !LHS
Does anyone have idea what happened or how could I try to debug the problem?
0 Kudos
1 Reply
Black Belt

If you suspect that the solution x in your "first case" contains incorrect values, you should check whether the matrix A and the vector b have been given correct values.

For the data that you supplied for "case 1", I find that there are only two items in A.x - b that are larger than 1E-11 in absolute value, and none that  exced 1E-10.

Thus, MKL/Pardiso is giving you a reasonable solution, but you have to look into the question of whether the matrix is well-conditioned or not.