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

Looking for Sparse Sover help

rfs6718
Beginner
809 Views

Hello,

I am trying to test out the sparse solver and learn how to code with MKL. So I inputed a 5x5 sparse matrix and a x vector

A = 1 -1 -3 0 0, -2 5 0 0 0, 0 0 4 6 4, -4 0 2 7 0, 0 -8 0 0 5

b = 1.2, 1.2, 1.2, 1.2, 1.2

Since it is a small matrix I used mathmatica to try to confirm the output of a system of linear equations Ay = b. I came up with:

0.107447, 0.282979, -0.458511, 0.36383, 0.212766

using mkl_cspblas_dcootrsv i get

3.13371, 0.624, 0.214286, 0.171429, -0.24

I used the following parameters for MKL

uplo = l

transa = t

diag = n

Thanks for the help

0 Kudos
4 Replies
Tabrez_Ali
Beginner
809 Views
MKL
radon ~> cat test.f90

program main
implicit none
real(8) :: val(13), x(5), y(5)
integer :: colind(13), rowind(13)
val=(/1.0,-1.0,-3.0,-2.0,5.0,4.0,6.0,4.0,-4.0,2.0,7.0,-8.0,5.0/)
rowind=(/1,1,1,2,2,3,3,3,4,4,4,5,5/)
colind=(/1,2,3,1,2,3,4,5,1,3,4,2,5/)
x=1.2
call mkl_dcootrsv('l','t','n',5,val,rowind,colind,13,x,y)
print*, y
end

radon ~> ifort test.f90 -L/opt/intel/mkl/9.1/lib/32 -lmkl_solver -lmkl_lapack -lmkl_ia32 -lguide -lpthread

radon ~> ./a.out
3.13371441023690 0.624000024795532 0.214285722800664 0.171428578240531 0.240000009536743


MATLAB

radon ~> matlab -nosplash -nodesktop -nojvm

< M A T L A B >
Copyright 1984-2007 The MathWorks, Inc.
Version 7.5.0.338 (R2007b)
August 9, 2007


To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

>> a=[1 -1 -3 0 0; -2 5 0 0 0; 0 0 4 6 4; -4 0 2 7 0; 0 -8 0 0 5];
>> b=[1.2 1.2 1.2 1.2 1.2]';
>> opts.LT = true; opts.TRANSA = true;
>> (linsolve(a,b,opts))'

ans =

3.1337 0.6240 0.2143 0.1714 0.2400
0 Kudos
rfs6718
Beginner
809 Views

Hey thanks for the help,

So why am I geting a different answer, I have tried other ways of solving it and I still get the same answer mathematica gave me. Is it the iterative metrhed used by MKL?

Thanks

0 Kudos
Tabrez_Ali
Beginner
809 Views
The answers are incorrect because your A probably doesnt have the required properties. What I was trying to show is that results b/w MKL and Matlab are consistent.
0 Kudos
rfs6718
Beginner
809 Views

That make sense. I was assuming that matrix that is used in the MKL example was correct. I am using a bigger matrix and its closer to the mathematica results. Thanks again for the help.

0 Kudos
Reply