<?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 mkl_dcsrcoo documentation: nnz is required input parameter? in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-dcsrcoo-documentation-nnz-is-required-input-parameter/m-p/791284#M2242</link>
    <description>Hello,&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I've noticed a few problems with the documentation of mkl_dcsrcoo, one of which took me a few hours to figure out. The parameter nnz is listed as an output parameter, but I have found that it's value must be set to the number of non-zero elements (the same value assigned to job(5)), or the result is a crash or undefined behavior.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Here is a quick test example in C++:&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;[cpp]#include "mkl_spblas.h"
#include "mkl_types.h"
#include &lt;IOSTREAM&gt;
using namespace std;

// test matrix A = [1 0]
//                 [0 1]
int main() {
    MKL_INT rowind[2] = {1,2},ia[2],ja[3],job[8] = {1,1,1,0,2,0,0,0};
    MKL_INT info, nnz,n=2;
    double Acoo[2] = {1.0,1.0}, Acsr[2];

    nnz = 0;    // set nnz to a nonsense value before the conversion
    mkl_dcsrcoo (job,&amp;amp;n, Acsr, ja, ia,&amp;amp;nnz,Acoo,rowind,rowind,&amp;amp;info);
    cout &amp;lt;&amp;lt; "\n\nAfter passing nnz=0 to mkl_dcsrcoo" &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "nnz: "  &amp;lt;&amp;lt; nnz     &amp;lt;&amp;lt; " info: " &amp;lt;&amp;lt; info    &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "ia: "   &amp;lt;&amp;lt; ia[0]   &amp;lt;&amp;lt; " "       &amp;lt;&amp;lt; ia[1]   &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "Acsr: " &amp;lt;&amp;lt; Acsr[0] &amp;lt;&amp;lt; " "       &amp;lt;&amp;lt; Acsr[1] &amp;lt;&amp;lt; endl;

    nnz = 2;   // set nnz to 2
    mkl_dcsrcoo (job,&amp;amp;n, Acsr, ja, ia,&amp;amp;nnz,Acoo,rowind,rowind,&amp;amp;info);

    cout &amp;lt;&amp;lt; "\n\nAfter passing nnz=2 to mkl_dcsrcoo" &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "nnz: "  &amp;lt;&amp;lt; nnz     &amp;lt;&amp;lt; " info: " &amp;lt;&amp;lt; info    &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "ia: "   &amp;lt;&amp;lt; ia[0]   &amp;lt;&amp;lt; " "       &amp;lt;&amp;lt; ia[1]   &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "Acsr: " &amp;lt;&amp;lt; Acsr[0] &amp;lt;&amp;lt; " "       &amp;lt;&amp;lt; Acsr[1] &amp;lt;&amp;lt; endl;
}
[/cpp]&lt;/IOSTREAM&gt;&lt;/PRE&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Without the following output:&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;I&gt;After passing nnz=0 to mkl_dcsrcoo&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;nnz: 0 info: 0&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;ia: 1 1&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;Acsr: 2.65259e-314 2.65259e-314&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;&lt;BR /&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;After passing nnz=2 to mkl_dcsrcoo&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;nnz: 2 info: 0&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;ia: 1 2&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;Acsr: 1 1&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;What I find alarming is that in both instances info = 0 indicating a successful conversion from COO to CSR.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;DIV style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;There are other minor missing things in the documentation: mkl_dcsrcoo(job, &amp;amp;n, should be changed too mkl_dcsrcoo(job,&lt;B style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;&amp;amp;m&lt;/B&gt;to match the description, and then the description could be modified to&lt;/DIV&gt;&lt;DIV style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;&lt;BR style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;" /&gt;&lt;/DIV&gt;&lt;DIV style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;&lt;S style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;m&lt;/S&gt;&lt;SPAN style="line-height: 16px;"&gt;&lt;S style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;INTEGER. Dimension of the matrix&lt;/S&gt;&lt;VAR style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;" class="bi"&gt;&lt;/VAR&gt;&lt;S style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;&lt;VAR style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;" class="bi"&gt;A&lt;/VAR&gt;&lt;/S&gt;&lt;S style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;.&lt;/S&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;m INTEGER. Number of columns of the matrix A&lt;BR style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;" /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/SPAN&gt;Cheers,&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;Bob&lt;/DIV&gt;</description>
    <pubDate>Thu, 24 Jun 2010 00:53:54 GMT</pubDate>
    <dc:creator>bob_edwards</dc:creator>
    <dc:date>2010-06-24T00:53:54Z</dc:date>
    <item>
      <title>mkl_dcsrcoo documentation: nnz is required input parameter?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-dcsrcoo-documentation-nnz-is-required-input-parameter/m-p/791284#M2242</link>
      <description>Hello,&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I've noticed a few problems with the documentation of mkl_dcsrcoo, one of which took me a few hours to figure out. The parameter nnz is listed as an output parameter, but I have found that it's value must be set to the number of non-zero elements (the same value assigned to job(5)), or the result is a crash or undefined behavior.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Here is a quick test example in C++:&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;[cpp]#include "mkl_spblas.h"
#include "mkl_types.h"
#include &lt;IOSTREAM&gt;
using namespace std;

// test matrix A = [1 0]
//                 [0 1]
int main() {
    MKL_INT rowind[2] = {1,2},ia[2],ja[3],job[8] = {1,1,1,0,2,0,0,0};
    MKL_INT info, nnz,n=2;
    double Acoo[2] = {1.0,1.0}, Acsr[2];

    nnz = 0;    // set nnz to a nonsense value before the conversion
    mkl_dcsrcoo (job,&amp;amp;n, Acsr, ja, ia,&amp;amp;nnz,Acoo,rowind,rowind,&amp;amp;info);
    cout &amp;lt;&amp;lt; "\n\nAfter passing nnz=0 to mkl_dcsrcoo" &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "nnz: "  &amp;lt;&amp;lt; nnz     &amp;lt;&amp;lt; " info: " &amp;lt;&amp;lt; info    &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "ia: "   &amp;lt;&amp;lt; ia[0]   &amp;lt;&amp;lt; " "       &amp;lt;&amp;lt; ia[1]   &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "Acsr: " &amp;lt;&amp;lt; Acsr[0] &amp;lt;&amp;lt; " "       &amp;lt;&amp;lt; Acsr[1] &amp;lt;&amp;lt; endl;

    nnz = 2;   // set nnz to 2
    mkl_dcsrcoo (job,&amp;amp;n, Acsr, ja, ia,&amp;amp;nnz,Acoo,rowind,rowind,&amp;amp;info);

    cout &amp;lt;&amp;lt; "\n\nAfter passing nnz=2 to mkl_dcsrcoo" &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "nnz: "  &amp;lt;&amp;lt; nnz     &amp;lt;&amp;lt; " info: " &amp;lt;&amp;lt; info    &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "ia: "   &amp;lt;&amp;lt; ia[0]   &amp;lt;&amp;lt; " "       &amp;lt;&amp;lt; ia[1]   &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "Acsr: " &amp;lt;&amp;lt; Acsr[0] &amp;lt;&amp;lt; " "       &amp;lt;&amp;lt; Acsr[1] &amp;lt;&amp;lt; endl;
}
[/cpp]&lt;/IOSTREAM&gt;&lt;/PRE&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Without the following output:&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;I&gt;After passing nnz=0 to mkl_dcsrcoo&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;nnz: 0 info: 0&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;ia: 1 1&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;Acsr: 2.65259e-314 2.65259e-314&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;&lt;BR /&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;After passing nnz=2 to mkl_dcsrcoo&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;nnz: 2 info: 0&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;ia: 1 2&lt;/I&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;I&gt;Acsr: 1 1&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;What I find alarming is that in both instances info = 0 indicating a successful conversion from COO to CSR.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;DIV style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;There are other minor missing things in the documentation: mkl_dcsrcoo(job, &amp;amp;n, should be changed too mkl_dcsrcoo(job,&lt;B style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;&amp;amp;m&lt;/B&gt;to match the description, and then the description could be modified to&lt;/DIV&gt;&lt;DIV style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;&lt;BR style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;" /&gt;&lt;/DIV&gt;&lt;DIV style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;&lt;S style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;m&lt;/S&gt;&lt;SPAN style="line-height: 16px;"&gt;&lt;S style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;INTEGER. Dimension of the matrix&lt;/S&gt;&lt;VAR style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;" class="bi"&gt;&lt;/VAR&gt;&lt;S style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;&lt;VAR style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;" class="bi"&gt;A&lt;/VAR&gt;&lt;/S&gt;&lt;S style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;.&lt;/S&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;"&gt;m INTEGER. Number of columns of the matrix A&lt;BR style="font-family: verdana, sans-serif; padding: 0px; margin: 0px;" /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/SPAN&gt;Cheers,&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;Bob&lt;/DIV&gt;</description>
      <pubDate>Thu, 24 Jun 2010 00:53:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-dcsrcoo-documentation-nnz-is-required-input-parameter/m-p/791284#M2242</guid>
      <dc:creator>bob_edwards</dc:creator>
      <dc:date>2010-06-24T00:53:54Z</dc:date>
    </item>
    <item>
      <title>mkl_dcsrcoo documentation: nnz is required input parameter?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-dcsrcoo-documentation-nnz-is-required-input-parameter/m-p/791285#M2243</link>
      <description>Bob,&lt;DIV&gt;we will take into account these comments&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, we
should to explicitly point that nnz is the input parameter also.&lt;/P&gt;&lt;P&gt;Nevertheless, Looking at the input parameter description we
can see..&lt;/P&gt;

&lt;P&gt;rowind (input/output)INTEGER.
Array of length &lt;VAR&gt;nnz&lt;/VAR&gt;, contains
the row indices for each non-zero element of the matrix &lt;VAR&gt;A&lt;/VAR&gt;.&lt;/P&gt;&lt;P&gt;--Gennady&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 24 Jun 2010 03:40:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-dcsrcoo-documentation-nnz-is-required-input-parameter/m-p/791285#M2243</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2010-06-24T03:40:07Z</dc:date>
    </item>
    <item>
      <title>mkl_dcsrcoo documentation: nnz is required input parameter?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-dcsrcoo-documentation-nnz-is-required-input-parameter/m-p/791286#M2244</link>
      <description>Here is a general woking example for a rectangualr matrix&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;[bash]// This is a routine to check the mkl_csrcoo routine 
// for a rectangular matrix, there is a bug in the 
// mkl doc, which was pointed out. Here is the working example.
// Matrix is 
//  
//      1 0 2 0
// A =  0 0 3 0
//      5 0 7 8
//
// nnz = 6, m = 3, n = 4

#include &lt;STDIO.H&gt;
#include "mkl_spblas.h"

int main(int argc, char *argv[] )
{
  double acoo[6] ={1., 2., 3., 5., 7., 8.};
  int rowind[6] = {1, 1, 2, 3, 3, 3};
  int colind[6] = {1, 3, 3, 1, 3, 4};
  int m=3, n=4, nnz=6;
  int job[8]={1,1,1,0,6,0,0,0};
  double acsr[6] = {1., 2., 3., 5., 7., 8.}; 
  int ia[4]; // m+1 
  int ja[6]; 
  int i, info;
  mkl_dcsrcoo(job, &amp;amp;m, acsr, ja, ia, &amp;amp;nnz, acoo, rowind, colind, &amp;amp;info);

  printf("n info = %d n ", info);
  printf("n--- csr matrix ---n");
  printf("n ia = ");
  for(i=0;i&lt;M&gt;);
  printf("n ja = ");
  for(i=0;i&lt;NNZ&gt;);
  printf("n acsr = ");
  for(i=0;i&lt;NNZ&gt;);
  printf("n n");

  return 0;

}
[/bash]&lt;/NNZ&gt;&lt;/NNZ&gt;&lt;/M&gt;&lt;/STDIO.H&gt;&lt;/PRE&gt; Hopefully, this helps !&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Cheers,&lt;/DIV&gt;&lt;DIV&gt;Pawan&lt;/DIV&gt;</description>
      <pubDate>Sun, 09 Jan 2011 14:22:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-dcsrcoo-documentation-nnz-is-required-input-parameter/m-p/791286#M2244</guid>
      <dc:creator>pawanlri</dc:creator>
      <dc:date>2011-01-09T14:22:22Z</dc:date>
    </item>
  </channel>
</rss>

