<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic export dense matrix to CSR format, how to optimized? in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/export-dense-matrix-to-CSR-format-how-to-optimized/m-p/1415194#M33656</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;I want to cover A to the sparse matrix by CSR format. The array of pointerB, pointerE,&amp;nbsp; column index, and nonzero value is the target output.&lt;/P&gt;
&lt;P&gt;Here is my program:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;
    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

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code runs well but it takes so long time for the large size of A, for example A(100000,100000).&amp;nbsp; Is there any function in mkl library similar to my program or is there any way to speed up the calculation?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me!&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 08:35:52 GMT</pubDate>
    <dc:creator>nvh10</dc:creator>
    <dc:date>2022-09-16T08:35:52Z</dc:date>
    <item>
      <title>export dense matrix to CSR format, how to optimized?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/export-dense-matrix-to-CSR-format-how-to-optimized/m-p/1415194#M33656</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;I want to cover A to the sparse matrix by CSR format. The array of pointerB, pointerE,&amp;nbsp; column index, and nonzero value is the target output.&lt;/P&gt;
&lt;P&gt;Here is my program:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;
    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

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code runs well but it takes so long time for the large size of A, for example A(100000,100000).&amp;nbsp; Is there any function in mkl library similar to my program or is there any way to speed up the calculation?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 08:35:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/export-dense-matrix-to-CSR-format-how-to-optimized/m-p/1415194#M33656</guid>
      <dc:creator>nvh10</dc:creator>
      <dc:date>2022-09-16T08:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: export dense matrix to CSR format, how to optimized?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/export-dense-matrix-to-CSR-format-how-to-optimized/m-p/1416016#M33681</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/167184"&gt;@nvh10&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thanks for reaching out to us about this. Have you tried using&amp;nbsp;&lt;A href="https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-fortran/top/blas-and-sparse-blas-routines/sparse-blas-level-2-and-level-3-routines/sparse-blas-level-2-and-level-3-routines-1/mkl-dnscsr.html" target="_self"&gt;mkl_?dnscsr&lt;/A&gt;&amp;nbsp;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.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Gajanan&lt;/P&gt;
&lt;P&gt;(Developer in oneMKL team)&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 18:01:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/export-dense-matrix-to-CSR-format-how-to-optimized/m-p/1416016#M33681</guid>
      <dc:creator>Gajanan_Choudhary</dc:creator>
      <dc:date>2022-09-20T18:01:26Z</dc:date>
    </item>
  </channel>
</rss>

