- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
I have a dense matrix A. I know the structure of A is sparse and I don't know the number or the location of non-zero elements in A.
I want to cover A to the sparse matrix by CSR format. The array of pointerB, pointerE, column index, and nonzero value is the target output.
Here is my program:
program Console24
implicit none
double precision A(5,5)
INTEGER nnz_A,i,j,t,k
integer, allocatable, dimension (:)::c_A
INTEGER ia(6),pB_A(5),pE_A(5)
double precision, allocatable, dimension (:)::v_A
A=0d0
A(3,4)=1.2d0
A(3,1)=1.2d0
A(3,3)=1.3d0
A(5,1)=1.7d0
A(2,4)=0.2d0
A(2,1)=4.2d0
A(2,3)=5.3d0
A(2,1)=3.7d0
nnz_A=count(A/=0)
allocate (c_A(nnz_A),v_A(nnz_A))
k=1
t=1
ia(1)=1
do j=1,5
do i=1,5
if (A(j,i)/=0) then
v_A(t)=A(j,i)
c_A(t)=i
t=t+1
endif
enddo
ia(j+1)=ia(j)+count(A(j,:)/=0)
enddo
pB_A=ia(1:5)
pE_A=ia(2:6)
end program Console24
The code runs well but it takes so long time for the large size of A, for example A(100000,100000). Is there any function in mkl library similar to my program or is there any way to speed up the calculation?
Please help me!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @nvh10 ,
Thanks for reaching out to us about this. Have you tried using mkl_?dnscsr function for this purpose? Note that that function is deprecated, so I would not advise its long-term use as it may be removed from oneMKL in the future. However, it is unlikely the removal would happen without first providing an alternative function in its place, so it may be temporarily safe for use for now.
Regards,
Gajanan
(Developer in oneMKL team)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page