<?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 Hello Dan, in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-sparse-z-export-csr-of-Inspector-executor-Sparse-BLAS-return/m-p/1137339#M26125</link>
    <description>&lt;P&gt;Hello Dan,&lt;BR /&gt;
	&lt;BR /&gt;
	Here is the example which should help to resolve incorrect behavior of mkl_sparse_z_export_csr by adding&amp;nbsp;&lt;SPAN style="font-size: 13.008px;"&gt;mkl_sparse_z_export_csr_cf interface which is using C_PTR.&lt;BR /&gt;
	Please let me know what you find out!&lt;BR /&gt;
	&lt;BR /&gt;
	Best regards,&lt;BR /&gt;
	Maria&lt;/SPAN&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;PROGRAM EXPORT_CSR

    USE MKL_SPBLAS
    USE ISO_C_BINDING
    IMPLICIT NONE
!   *****************************************************************************
!   Declare new interface using C_PTR:
!   *****************************************************************************
    INTERFACE
        FUNCTION MKL_SPARSE_Z_EXPORT_CSR_CF(source,indexing,rows,cols,rows_start,rows_end,col_indx,values) &amp;amp;
                 BIND(C, name='MKL_SPARSE_Z_EXPORT_CSR')
            USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX, C_PTR
            IMPORT SPARSE_MATRIX_T
            TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: source
            INTEGER(C_INT), INTENT(INOUT) :: indexing
            INTEGER       , INTENT(INOUT) :: rows
            INTEGER       , INTENT(INOUT) :: cols
            TYPE(C_PTR)   , INTENT(INOUT) :: rows_start
            TYPE(C_PTR)   , INTENT(INOUT) :: rows_end
            TYPE(C_PTR)   , INTENT(INOUT) :: col_indx
            TYPE(C_PTR)   , INTENT(INOUT) :: values
            INTEGER(C_INT) MKL_SPARSE_Z_EXPORT_CSR_CF
        END FUNCTION
    END INTERFACE

!   *****************************************************************************
!   Sparse representation of the matrices A:
!   *****************************************************************************
    INTEGER   , ALLOCATABLE :: csrColInd(:), csrRowPtr(:)
    COMPLEX*16, ALLOCATABLE :: csrVal(:)
!   CSR matrix structure
    TYPE(SPARSE_MATRIX_T) csrA
!   Variables used for exporting sparse matrix
    INTEGER        :: nrows, ncols
    INTEGER(C_INT) :: indexing
    TYPE(C_PTR)    :: rows_start_c, rows_end_c, col_indx_c, values_c
    INTEGER   , POINTER :: rows_start_f(:), rows_end_f(:), col_indx_f(:)
    COMPLEX*16, POINTER :: values_f(:)
!   *****************************************************************************
!   Declaration of local variables:
!   *****************************************************************************
    INTEGER M, N, NNZ, i, j, info
    M = 5
    NNZ = 13
    ALLOCATE(csrColInd(NNZ))
    ALLOCATE(csrRowPtr(M+1))
    ALLOCATE(csrVal(NNZ))
    csrVal = (/ (1.0, 0.0), (-1.0, 0.0), (-3.0, 0.0), (-2.0, 0.0), (5.0, 0.0), (4.0, 0.0), &amp;amp;
                (6.0, 0.0), (4.0, 0.0), (-4.0, 0.0), (2.0, 0.0), (7.0, 0.0), (8.0, 0.0), (-5.0, 0.0) /)
    csrColInd = (/ 0,1,3,0,1,2,3,4,0,2,3,1,4 /)
    csrRowPtr = (/ 0,    3,  5,    8,   11,  13 /)

    print*,'---------------------------------------------------'
    print*,'Input matrix A:'
    do i = 1, M
        print 100,'row #',i
        do j = csrRowPtr(i)+1, csrRowPtr(i+1)
            print*,csrColInd(j),csrVal(j)
        enddo
    enddo

!   Create CSR matrix
    info = MKL_SPARSE_Z_CREATE_CSR(csrA,SPARSE_INDEX_BASE_ZERO,M,M,csrRowPtr(1),csrRowPtr(2),csrColInd,csrVal)

!   Export CSR matrix
    info = MKL_SPARSE_Z_EXPORT_CSR_CF(csrA, indexing, nrows, ncols, rows_start_c, rows_end_c, col_indx_c, values_c)

!   Converting C into Fortran pointers
    call C_F_POINTER(rows_start_c, rows_start_f, [nrows])
    call C_F_POINTER(rows_end_c  , rows_end_f  , [nrows])
    call C_F_POINTER(col_indx_c  , col_indx_f  , [rows_end_f(nrows)])
    call C_F_POINTER(values_c    , values_f    , [rows_end_f(nrows)])

    print*,'---------------------------------------------------'
    print *,'Output matrix A:'
    do i = 1, nrows
        print 100,'row #',i
        do j = rows_start_f(i)+1, rows_end_f(i)
            print*,col_indx_f(j),values_f(j)
        enddo
    enddo

!   Release internal representation of CSR matrix
    info = MKL_SPARSE_DESTROY(csrA)

    print*,'---------------------------------------------------'

100 format(A,I2)

END PROGRAM EXPORT_CSR&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jun 2018 19:57:01 GMT</pubDate>
    <dc:creator>MariaZh</dc:creator>
    <dc:date>2018-06-07T19:57:01Z</dc:date>
    <item>
      <title>mkl_sparse_z_export_csr of Inspector-executor Sparse BLAS return bizarre results.</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-sparse-z-export-csr-of-Inspector-executor-Sparse-BLAS-return/m-p/1137338#M26124</link>
      <description>&lt;P&gt;Dear MKL experts,&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I'm testing the function,mkl_sparse_z_export_csr, in Inspector-executor Sparse BLAS, to convert COO format into CSR format and output the CSR format. The function returns BIZARRE results as shown in the below. I guess I did something wrong. I attach the simple code at the end. Please tell what the correct way to do it.&lt;/P&gt;

&lt;P&gt;Dan&lt;/P&gt;

&lt;P&gt;!&amp;nbsp;&amp;nbsp; Sparse representation of the matrix A&lt;BR /&gt;
	!&lt;BR /&gt;
	!&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp; -3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp; |&lt;BR /&gt;
	!&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; -2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp; |&lt;BR /&gt;
	!&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp; &amp;nbsp; |,&lt;BR /&gt;
	!&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; -4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp; |&lt;BR /&gt;
	!&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; -5&amp;nbsp;&amp;nbsp; |&lt;BR /&gt;
	!&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; info = mkl_sparse_z_export_csr (csrA, i, nrow, ncol, rows_start,rows_end,col_indx,csrA_value)&lt;/P&gt;

&lt;P&gt;&amp;nbsp;OUTPUT DATA FOR &lt;A&gt; in CSR Format =&lt;BR /&gt;
	&amp;nbsp;rows_start(1:M) = &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8546432&amp;nbsp; 1919251285&amp;nbsp; 1631870067&amp;nbsp; 1883331694&amp;nbsp; 1952531568&lt;BR /&gt;
	&amp;nbsp;rows_end(1:M)&amp;nbsp; =&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 8546436&amp;nbsp; 1952531568&amp;nbsp; 1867275361&amp;nbsp; 1550606691&amp;nbsp; 1886217556&lt;BR /&gt;
	&amp;nbsp;col_indx(1:NNZ) =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8546688&amp;nbsp; 1279350084&amp;nbsp; 1313817944&amp;nbsp; 1398079538&amp;nbsp; 1095651909&amp;nbsp; 1144866125&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 1426091617&amp;nbsp; 1347568979&amp;nbsp; 1229344594&amp;nbsp; 1128088908&amp;nbsp; 1934974010&amp;nbsp; 1551069797&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7233860&lt;BR /&gt;
	&amp;nbsp;csr_AB_value(1:NNZ) =&lt;BR /&gt;
	&amp;nbsp;(2.099310184342793E+021,1.887537090390452E+219)&lt;BR /&gt;
	&amp;nbsp;(8.857835453724769E+247,8.490117977552768E+175)&lt;BR /&gt;
	&amp;nbsp;(1.178852010317225E-307,2.225055204183881E+252)&lt;BR /&gt;
	&amp;nbsp;(5.817520101125294E+252,1.035480486908856E+243)&lt;BR /&gt;
	&amp;nbsp;(2.646398786088117E+199,6.103525143045638E+257)&lt;BR /&gt;
	&amp;nbsp;(1.298808940059573E+219,1.565465600591419E-076)&lt;BR /&gt;
	&amp;nbsp;(3.015794287991875E+161,2.305365297438563E+108)&lt;BR /&gt;
	&amp;nbsp;(1.665757500898629E-071,9.805903047556869E-072)&lt;BR /&gt;
	&amp;nbsp;(1.107082334375070E+074,4.363619063791335E+242)&lt;BR /&gt;
	&amp;nbsp;(1.323192987846278E+199,1.674261708694803E-047)&lt;BR /&gt;
	&amp;nbsp;(1.099368561560521E+248,5.829277640098750E+257)&lt;BR /&gt;
	&amp;nbsp;(4.893813689845159E+199,3.173709719932153E+016)&lt;BR /&gt;
	&amp;nbsp;(2.410805593608415E+098,2.868330566549112E+093)&lt;BR /&gt;
	&amp;nbsp;---------------------------------------------------&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 19:09:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-sparse-z-export-csr-of-Inspector-executor-Sparse-BLAS-return/m-p/1137338#M26124</guid>
      <dc:creator>Dan_Ghiocel</dc:creator>
      <dc:date>2018-06-07T19:09:13Z</dc:date>
    </item>
    <item>
      <title>Hello Dan,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-sparse-z-export-csr-of-Inspector-executor-Sparse-BLAS-return/m-p/1137339#M26125</link>
      <description>&lt;P&gt;Hello Dan,&lt;BR /&gt;
	&lt;BR /&gt;
	Here is the example which should help to resolve incorrect behavior of mkl_sparse_z_export_csr by adding&amp;nbsp;&lt;SPAN style="font-size: 13.008px;"&gt;mkl_sparse_z_export_csr_cf interface which is using C_PTR.&lt;BR /&gt;
	Please let me know what you find out!&lt;BR /&gt;
	&lt;BR /&gt;
	Best regards,&lt;BR /&gt;
	Maria&lt;/SPAN&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;PROGRAM EXPORT_CSR

    USE MKL_SPBLAS
    USE ISO_C_BINDING
    IMPLICIT NONE
!   *****************************************************************************
!   Declare new interface using C_PTR:
!   *****************************************************************************
    INTERFACE
        FUNCTION MKL_SPARSE_Z_EXPORT_CSR_CF(source,indexing,rows,cols,rows_start,rows_end,col_indx,values) &amp;amp;
                 BIND(C, name='MKL_SPARSE_Z_EXPORT_CSR')
            USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX, C_PTR
            IMPORT SPARSE_MATRIX_T
            TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: source
            INTEGER(C_INT), INTENT(INOUT) :: indexing
            INTEGER       , INTENT(INOUT) :: rows
            INTEGER       , INTENT(INOUT) :: cols
            TYPE(C_PTR)   , INTENT(INOUT) :: rows_start
            TYPE(C_PTR)   , INTENT(INOUT) :: rows_end
            TYPE(C_PTR)   , INTENT(INOUT) :: col_indx
            TYPE(C_PTR)   , INTENT(INOUT) :: values
            INTEGER(C_INT) MKL_SPARSE_Z_EXPORT_CSR_CF
        END FUNCTION
    END INTERFACE

!   *****************************************************************************
!   Sparse representation of the matrices A:
!   *****************************************************************************
    INTEGER   , ALLOCATABLE :: csrColInd(:), csrRowPtr(:)
    COMPLEX*16, ALLOCATABLE :: csrVal(:)
!   CSR matrix structure
    TYPE(SPARSE_MATRIX_T) csrA
!   Variables used for exporting sparse matrix
    INTEGER        :: nrows, ncols
    INTEGER(C_INT) :: indexing
    TYPE(C_PTR)    :: rows_start_c, rows_end_c, col_indx_c, values_c
    INTEGER   , POINTER :: rows_start_f(:), rows_end_f(:), col_indx_f(:)
    COMPLEX*16, POINTER :: values_f(:)
!   *****************************************************************************
!   Declaration of local variables:
!   *****************************************************************************
    INTEGER M, N, NNZ, i, j, info
    M = 5
    NNZ = 13
    ALLOCATE(csrColInd(NNZ))
    ALLOCATE(csrRowPtr(M+1))
    ALLOCATE(csrVal(NNZ))
    csrVal = (/ (1.0, 0.0), (-1.0, 0.0), (-3.0, 0.0), (-2.0, 0.0), (5.0, 0.0), (4.0, 0.0), &amp;amp;
                (6.0, 0.0), (4.0, 0.0), (-4.0, 0.0), (2.0, 0.0), (7.0, 0.0), (8.0, 0.0), (-5.0, 0.0) /)
    csrColInd = (/ 0,1,3,0,1,2,3,4,0,2,3,1,4 /)
    csrRowPtr = (/ 0,    3,  5,    8,   11,  13 /)

    print*,'---------------------------------------------------'
    print*,'Input matrix A:'
    do i = 1, M
        print 100,'row #',i
        do j = csrRowPtr(i)+1, csrRowPtr(i+1)
            print*,csrColInd(j),csrVal(j)
        enddo
    enddo

!   Create CSR matrix
    info = MKL_SPARSE_Z_CREATE_CSR(csrA,SPARSE_INDEX_BASE_ZERO,M,M,csrRowPtr(1),csrRowPtr(2),csrColInd,csrVal)

!   Export CSR matrix
    info = MKL_SPARSE_Z_EXPORT_CSR_CF(csrA, indexing, nrows, ncols, rows_start_c, rows_end_c, col_indx_c, values_c)

!   Converting C into Fortran pointers
    call C_F_POINTER(rows_start_c, rows_start_f, [nrows])
    call C_F_POINTER(rows_end_c  , rows_end_f  , [nrows])
    call C_F_POINTER(col_indx_c  , col_indx_f  , [rows_end_f(nrows)])
    call C_F_POINTER(values_c    , values_f    , [rows_end_f(nrows)])

    print*,'---------------------------------------------------'
    print *,'Output matrix A:'
    do i = 1, nrows
        print 100,'row #',i
        do j = rows_start_f(i)+1, rows_end_f(i)
            print*,col_indx_f(j),values_f(j)
        enddo
    enddo

!   Release internal representation of CSR matrix
    info = MKL_SPARSE_DESTROY(csrA)

    print*,'---------------------------------------------------'

100 format(A,I2)

END PROGRAM EXPORT_CSR&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 19:57:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-sparse-z-export-csr-of-Inspector-executor-Sparse-BLAS-return/m-p/1137339#M26125</guid>
      <dc:creator>MariaZh</dc:creator>
      <dc:date>2018-06-07T19:57:01Z</dc:date>
    </item>
    <item>
      <title>Hi, Maria,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-sparse-z-export-csr-of-Inspector-executor-Sparse-BLAS-return/m-p/1137340#M26126</link>
      <description>&lt;P&gt;Hi, Maria,&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thanks a lot. It works.&lt;/P&gt;

&lt;P&gt;&amp;nbsp; Dan&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 14:04:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-sparse-z-export-csr-of-Inspector-executor-Sparse-BLAS-return/m-p/1137340#M26126</guid>
      <dc:creator>Dan_Ghiocel</dc:creator>
      <dc:date>2018-06-08T14:04:26Z</dc:date>
    </item>
  </channel>
</rss>

