Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28590 Discussions

How to use mkl_sparse_d_syprd function in fortran

nvh10
New Contributor I
631 Views
I need to calculate this operation in Fortran: P=APA'. A is sparse and B is the dense matrix. I want to use the function mkl_sparse_d_syprd but I don't understand well the input argument. Here is my program, please help me.
Thank you very much!
 
! Matrix
!A= [10, 20, 0, 0, 0, 0;
!    0, 30, 0, 40, 0, 0;
!    0, 0, 50, 60, 70, 0;
!    0, 0, 0, 0, 0, 80;
!    0, 0, 0, 0, 0, 0; 
!    0, 0, 0, 0, 0, 0]
!
!P= [1, 0, 0, 0, 0, 0;
!    0, 1, 0, 0, 0, 0;
!    0, 0, 1, 0, 0, 0;
!    0, 0, 0, 1, 0, 0;
!    0, 0, 0, 0, 1, 0;
!    0, 0, 0, 0, 0, 1]
!    
program test
use mkl_spblas
implicit none
double precision, allocatable, dimension (:,:):: P,A,APAT
integer, allocatable, dimension (:):: c_A,pB_A,pE_A,r_A
double precision, allocatable, dimension (:)::v_A
integer stat,nstate,i
type(sparse_matrix_t) :: A_s
allocate(v_A(8),c_A(8),pB_A(6),pE_A(6))
pB_A = [1,3,5,8,9,9]
pE_A = [3,5,8,9,9,9]
c_A = [1,2,2,4,3,4,5,6]
v_A = [10d0, 20d0, 30d0, 40d0, 50d0, 60d0, 70d0, 80d0]
nstate=6
allocate(P(nstate,nstate),APAT(nstate,nstate))
do i=1,nstate
P(i,i)=1
enddo
stat = mkl_sparse_d_create_csr(A_s,SPARSE_INDEX_BASE_ONE,6,6,pB_A,pE_A,c_A,v_A)
stat = mkl_sparse_d_syprd (SPARSE_OPERATION_NON_TRANSPOSE,&
A_s, P, SPARSE_LAYOUT_COLUMN_MAJOR, nstate, 1d0, 0d0, &
APAT,SPARSE_LAYOUT_COLUMN_MAJOR, nstate)
end program test
0 Kudos
1 Solution
1 Reply
Steve_Lionel
Honored Contributor III
601 Views
0 Kudos
Reply