Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- I do not get to solve a system using sparse matrices

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

felipin85

Beginner

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

02-07-2011
11:45 AM

132 Views

I do not get to solve a system using sparse matrices

In the file PROGRAMA07021011PIVOTGAUSS.f90 I'm usinggetrfand getrs.In the file PROGRAMA07022011SPARSE.f90 I'm resolved by sparse matrices.The sparse file, once run

generates five files val.dat, col.dat, rowindex.dat, ld.dat and sp.txt.SP.txt file is the matrix Ax = b, A system.ld.txt is the vector b.While val.dat are non-zero values of A,

rowIndex col.dat your column and row index.I have found these three on hand, and appear well.

The solution is given in the file solutionsparse.dat and are huge numbers.The solution of the file PROGRAMA07021011PIVOTGAUSS.f90 (apparently correct) iscalled solutiongauss.dat.

I tried to solve the system with matlab, inverting the matrix A and multiplying by solutiongauss.dat by match.

Does anyone know why I get these results?

Compile files with this line:

ifort-openmp-O3-o $ MKLINCLUDE PROGRAMA07022011SPARSE-I-L $ MKLPATH PROGRAMA07022011SPARSE.f90-lmkl_lapack95-Wl, - start-group $ MKLPATH / libmkl_intel.a $ MKLPATH / libmkl_intel_thread.a $ MKLPATH / libmkl_core.a-Wl,- end-group-lpthread-liomp5

and with:

ifort-openmp-O3-o $ MKLINCLUDE PROGRAMA07022011PIVOTGAUSS-I-L $ MKLPATH PROGRAMA07022011PIVOTGAUSS.f90-lmkl_lapack95-Wl, - start-group $ MKLPATH / libmkl_intel.a $ MKLPATH / libmkl_intel_thread.a $ MKLPATH / libmkl_core.a-Wl,- end-group-lpthread-liomp5

1 Solution

Konstantin_A_Intel

Employee

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

02-11-2011
02:57 AM

132 Views

!---------------------------):

OPEN(4,FILE='Col.dat')

OPEN(3,FILE='Val.dat')

OPEN(2,FILE='RowIndex.dat')

DO i=1,NVALUES

write(4,*)(COL(i))

write(3,52)(VAL(i)) !---------------------------

END DO

52 FORMAT (10000F10.3) !---------------------------

DO i=1,total

write(*,*)(P(i))

END DO

DO i=1,total+1

write(2,*)(rowindex(i))

END DO

close(4)

close(3)

close(2)

OPEN(3,FILE='Val.dat')!---------------------------

DO i=1,NVALUES !---------------------------

read(3,*)(VAL(i)) !---------------------------

END DO !---------------------------

close(3)

I hope it will help you to resolve your problems!

Best regards,

Konstantin

Link Copied

10 Replies

Konstantin_A_Intel

Employee

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

02-07-2011
09:42 PM

132 Views

Your matrix is almost singular:

Singular values:

max= 52.7334033722656 min= 3.009615796461843E-014

Condition number = 1.752163961734249E+015

Theoretically, solving such matrices in double precision cannot produce stable results.

Results,

Konstantin

felipin85

Beginner

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

02-09-2011
02:33 AM

132 Views

Quoting Konstantin Arturov (Intel)

Your matrix is almost singular:

Singular values:

max= 52.7334033722656 min= 3.009615796461843E-014

Condition number = 1.752163961734249E+015

Theoretically, solving such matrices in double precision cannot produce stable results.

Results,

Konstantin

Moreover, in the archives of triangulation would have a bug, right?

Thanks for your help

Konstantin_A_Intel

Employee

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

02-09-2011
03:44 AM

132 Views

Of course, term "almost singular" is not exact.. It's better to call this matrix ill-conditioned. So, determinant is not important here.. it doesn't correlate with the condition number that's the main factor of solution stability.

Let's assume:

X_rel -relative error of solution

Cond(A) - matrix condition number

B_rel - relative error of right-hand side.

Following statement is true:

X_rel <= Cond(A)*B_rel, or moving to machine arithmetics:

X_rel <= Cond(A)*eps, where eps is the smallest number representing by double precision type and rougly it's equal to 1e-16 (as mantissa of double precision type has 53 bits and 2^-53 ~= 1e-16). So, having Cond(A)=1e+15 we can write:

X_rel <= 1.0e+15 * 1.0e-16, or

X_rel <= 1.0e-1

So, only 1 significant decimal digit is guaranteed to be correct in the relative error of solution of this matrix.

Regards,

Konstantin

felipin85

Beginner

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

02-09-2011
04:46 AM

132 Views

if (dss_solve_real( hDSS, MKL_DSS_FORWARD_SOLVE, P, 1, X) &

-------------------------------------------------------^

PROGRAMA09022011.f90(661): error #6633: The type of the actual argument differs from the type of the dummy argument.

if (dss_solve_real( hDSS, MKL_DSS_BACKWARD_SOLVE, P, 1, X ) &

--------------------------------------------------^

PROGRAMA09022011.f90(661): error #6633: The type of the actual argument differs from the type of the dummy argument.

if (dss_solve_real( hDSS, MKL_DSS_BACKWARD_SOLVE, P, 1, X ) &

--------------------------------------------------------^

PROGRAMA09022011.f90(668): error #6633: The type of the actual argument differs from the type of the dummy argument.

if (dss_solve_real( hDSS, MKL_DSS_DEFAULTS, P, 1, X ) &

--------------------------------------------^

PROGRAMA09022011.f90(668): error #6633: The type of the actual argument differs from the type of the dummy argument.

if (dss_solve_real( hDSS, MKL_DSS_DEFAULTS, P, 1, X ) &

--------------------------------------------------^

compilation aborted for PROGRAMA09022011.f90 (code 1)

Thanks, for your help.

Regards

Konstantin_A_Intel

Employee

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

02-09-2011
09:56 AM

132 Views

Regards,

Konstantin

felipin85

Beginner

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

02-09-2011
10:11 AM

132 Views

The program will have to solve very large sparse systems, from a finite difference scheme. For this case, I can resolution with getrfand getrs, but when I grow up I'll have to calculate the system with sparse.

In theory, Is it normal that the system of good results using getfrf (and getrs) and bad results using sparse?

On Other hand, How matrix ill-conditioned test them? For viewing the finite difference schemes should have a good ill-conditioned?

Sorry for the inconvenience

Thanks and Regards!

Konstantin_A_Intel

Employee

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

02-11-2011
12:40 AM

132 Views

I'm sorry for the late response. It seems I have an answer why youdid get completely different solution with PARDISO/DSS and LAPACK. The problem is that you wrote a matrix in the file SP.txt in the following way:

WRITE(52,52)(P(j),j=1,total)

52 FORMAT (10000F10.3)

That means that you lost all significant digits to the left of floating point except 3 ones. That changed the matrix so that its condition number became ~36000 instead of 1e+15 in the initial matrix. That "modified" matrix was passed to dgetf and dgetrs that resulted in good solution (but it was a solution of another matrix). On the other hand, data passed to sparse solver was correct: array Val.dat contains numbers with many significant digits.

So, if you replace line

WRITE(52,52)(P(j),j=1,total)

in PROGRAMA07022011PIVOTGAUSS.f90 with more correct

WRITE(52,*)(P(j),j=1,total)

you will get about the same solution with big numbers as DSS produced.

Regards,

Konstantin

felipin85

Beginner

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

02-11-2011
02:26 AM

132 Views

How I can get dss values, as I do with the file SP.txt (write (52.52)?

Thanks, and I'm sorry for the inconvenience

Regards

Konstantin_A_Intel

Employee

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

02-11-2011
02:57 AM

133 Views

!---------------------------):

OPEN(4,FILE='Col.dat')

OPEN(3,FILE='Val.dat')

OPEN(2,FILE='RowIndex.dat')

DO i=1,NVALUES

write(4,*)(COL(i))

write(3,52)(VAL(i)) !---------------------------

END DO

52 FORMAT (10000F10.3) !---------------------------

DO i=1,total

write(*,*)(P(i))

END DO

DO i=1,total+1

write(2,*)(rowindex(i))

END DO

close(4)

close(3)

close(2)

OPEN(3,FILE='Val.dat')!---------------------------

DO i=1,NVALUES !---------------------------

read(3,*)(VAL(i)) !---------------------------

END DO !---------------------------

close(3)

I hope it will help you to resolve your problems!

Best regards,

Konstantin

felipin85

Beginner

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

02-11-2011
03:15 AM

132 Views

Anyway, thank you very much Konstantine

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

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