Quantcast
Channel: Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 2652

conversion from COO format to CSR

$
0
0

Dear all,

I am using Intel MKL subroutine mkl_zcoocsr to convert a sparse matrix in COO form to CSR, but the results do not seem right. Here is my subroutine:

!ooooooooooooooooooooooooooooooooooooooooooooooooooooo

      subroutine testcoocsr

      integer, dimension(:), allocatable :: irn, jcn, aval
      integer, dimension(:), allocatable :: colindex, rowindex, amtrx 
      integer job(8), nnz, n, info
      
      nnz=6
      n=4
  
     allocate(irn(nnz))
     allocate(jcn(nnz))
     allocate(aval(nnz))
     allocate(colindex(nnz))
     allocate(amtrx(nnz))
     allocate(rowindex(n+1))
    
     job(1)=2  !from COO to CSR, column indices in CSRare sorted in increasing order within each row.
     job(2)=1  !one-based indexing for the matrix in CSR format is used.
     job(3)=1  !one-based indexing for the matrix in coordinate format is used.
     job(5)=nnz !sets number of the non-zero elements of the matrix A if job(1)=1.
     job(6)=0 !all arrays acsr, ja, ia are filled in for the output storage.
    
     irn(1)=1
     irn(2)=2
     irn(3)=3
     irn(4)=3
     irn(5)=4
     irn(6)=2
      
     jcn(1)=1
     jcn(2)=2
     jcn(3)=1
     jcn(4)=3
     jcn(5)=4
     jcn(6)=4
    
     aval(1)=1
     aval(2)=2
     aval(3)=3
     aval(4)=4
     aval(5)=5
     aval(6)=6
        
     call mkl_zcsrcoo(job, n, amtrx, colindex, rowindex, nnz, aval, irn, jcn, info)
   
     deallocate(irn)
     deallocate(jcn)
     deallocate(aval)   
     deallocate(colindex)
     deallocate(amtrx)
     deallocate(rowindex)

     end subroutine testcoocsr
!ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

After calling the above subroutine, I got

amtrx=(0, 0, 0, 0,  0, 1)

colindex=(1, 1, 2, 0, 0, 0)

rowindex=(3, 3, 4, 4, 4)

I would very much appreciate your help. Thanks.

Likun

 


Viewing all articles
Browse latest Browse all 2652

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>