<?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 Hi Jan,  in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-ddiamm-bug/m-p/1048990#M21069</link>
    <description>&lt;P&gt;Hi Jan,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Right, it brings some confusion here. The "&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;one-based indexing" is not&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: rgb(67, 67, 67); font-family: Tahoma, Arial; font-size: 12px; font-weight: bold; line-height: 19.1875px; widows: auto; background-color: rgb(242, 242, 242);"&gt;apply to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;&amp;nbsp;the routine, but for all SP BLAS functions. &amp;nbsp;We should add some notes there to clarify.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;&amp;nbsp;Thanks for asking.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Please notes,&lt;/P&gt;

&lt;P&gt;this routine supports only one-based indexing of the input arrays, thus the &lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;B and C ( if suitable) were column-oriented.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;if considering the matrix structure, the mkl_ddiamm should be almost same effect as cblas_?trmm, &amp;nbsp;But you may caculate &amp;nbsp;the result either from right or left. &amp;nbsp; For example. &amp;nbsp;(u * s) * vt &amp;nbsp; , &amp;nbsp;where (u*s)t=s*ut. &amp;nbsp;here &amp;nbsp;t&lt;/SPAN&gt;&lt;SPAN style="color: rgb(67, 67, 67); font-family: Tahoma, Arial; font-size: 12px; line-height: 24px; widows: auto; background-color: rgb(242, 242, 242);"&gt;wo column-oriented make a row major, so the result should be ok.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Ying&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2015 01:29:58 GMT</pubDate>
    <dc:creator>Ying_H_Intel</dc:creator>
    <dc:date>2015-09-29T01:29:58Z</dc:date>
    <item>
      <title>mkl_ddiamm bug ?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-ddiamm-bug/m-p/1048986#M21065</link>
      <description>&lt;P&gt;I am trying to multiply two matrices using mkl_ddiamm method:&lt;/P&gt;

&lt;P&gt;C = A * B&lt;/P&gt;

&lt;P&gt;where A is diagonal matrix 3x3 and B is general matrix 3x3. No matter what I try, i get as a result no A*B, but B*A. This is my sample code. It essentially does SVD decomposition of matrix A and checks, if the computed matrices U, S and VT satisfy all requirements according to theory i.e.&lt;/P&gt;

&lt;P&gt;1. U * UT = I, where I us identity matrix&lt;/P&gt;

&lt;P&gt;2. V * VT = I&lt;/P&gt;

&lt;P&gt;3. U * S * VT = A&lt;/P&gt;

&lt;P&gt;Result of temporary operation S * VT is not correct. In fact, the function mkl_ddiamm computes VT * S.&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;   // requirement: m &amp;gt;= n
   int m = 3;
   int n = 3;
   double *a = (double *)mkl_malloc(m * n * sizeof(double), 16);
   double *s = (double *)mkl_malloc(n * sizeof(double), 16);
   double *u = (double *)mkl_malloc(m * n * sizeof(double), 16);
   double *vt = (double *)mkl_malloc(n * n * sizeof(double), 16);
   double *superb = (double *)mkl_malloc((n-1) * sizeof(double), 16);
   // identity matrix m x m
   double *unit_m = (double *)mkl_malloc(m * m * sizeof(double), 16);

   for (int i = 0; i &amp;lt; m; i++)
      for (int j = 0; j &amp;lt; m; j++)
         unit_m[i*m+j] = i == j ? 1.0 : 0;

   // identity matrix n x n
   double *unit_n = (double *)mkl_malloc(n * n * sizeof(double), 16);

   for (int i = 0; i &amp;lt; n; i++)
      for (int j = 0; j &amp;lt; n; j++)
         unit_n[i*n+j] = i == j ? 1.0 : 0;

   a[0] = 1;   a[1] = 1; a[2] = 1;
   a[3] = 2.5; a[4] = 3; a[5] = 4;
   a[6] = 3;   a[7] = 2; a[8] = 1;

   lapack_int res = LAPACKE_dgesvd(LAPACK_ROW_MAJOR, 'S', 'S', m, n, a, n, s, u, n, vt, n, superb);

   // Checking correctness of SVD calculation ...

   // u * ut = I
   double *temp = (double *)mkl_malloc(m * m * sizeof(double), 16);
   memset(temp, 0, m * m * sizeof(double));
   cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasTrans, m, m, n, 1.0, u, n, u, n, 0, temp, m);

   // v * vt = I
   memset(temp, 0, n * n * sizeof(double));
   cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans, n, n, n, 1.0, vt, n, vt, n, 0, temp, n);

   // u * s * vt = a
   memset(temp, 0, n * n * sizeof(double));
   int lval = 3;
   int idiag = 0;
   int ndiag = 1;
   double alpha = 1.0;
   double beta = 0;
   mkl_ddiamm("N", &amp;amp;n, &amp;amp;n, &amp;amp;n, &amp;amp;alpha, "DLNF", s, &amp;amp;lval, &amp;amp;idiag, &amp;amp;ndiag, vt, &amp;amp;n, &amp;amp;beta, temp, &amp;amp;n);
   double *temp2 = (double *)mkl_malloc(m * n * sizeof(double), 16);
   memset(temp2, 0, m * n * sizeof(double));
   cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, n, 1.0, u, n, temp, n, 0, temp2, n);&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Sep 2015 14:39:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-ddiamm-bug/m-p/1048986#M21065</guid>
      <dc:creator>Ján_K_</dc:creator>
      <dc:date>2015-09-26T14:39:07Z</dc:date>
    </item>
    <item>
      <title>Hi Jan, </title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-ddiamm-bug/m-p/1048987#M21066</link>
      <description>&lt;P&gt;Hi Jan,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;It is by designed purpose as MKL support both foran interface and C interface. &amp;nbsp;So &amp;nbsp;for these SPARSE BLAS functions, &amp;nbsp;&lt;/P&gt;

&lt;P&gt;mkl_sdiamm&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;NOTE&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;This routine supports only one-based indexing of the input arrays.&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;when A*B, &amp;nbsp;if &amp;nbsp;A is claimed &amp;nbsp;in 1 based, &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;then&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&amp;nbsp;MKL supports only &amp;nbsp;take column-oriented dense matrix B in 1-base case also.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;So the routine take B as&amp;nbsp;column-oriented, as a result, it looks &lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;VT * S.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;So maybe you can use the cblas &amp;nbsp;function (c interface) to replace the functionality.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;cblas_?trmm&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Computes a matrix-matrix product where one input&lt;BR /&gt;
	matrix is triangular.&lt;BR /&gt;
	Syntax&lt;BR /&gt;
	void cblas_strmm (const CBLAS_LAYOUT Layout, const CBLAS_SIDE side, const CBLAS_UPLO&lt;BR /&gt;
	uplo, const CBLAS_TRANSPOSE transa, const CBLAS_DIAG diag, const MKL_INT m, const&lt;BR /&gt;
	MKL_INT n, const float alpha, const float *a, const MKL_INT lda, float *b, const&lt;BR /&gt;
	MKL_INT ldb);&lt;/P&gt;

&lt;P&gt;Best Regards,&lt;/P&gt;

&lt;P&gt;Ying&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 03:39:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-ddiamm-bug/m-p/1048987#M21066</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2015-09-28T03:39:00Z</dc:date>
    </item>
    <item>
      <title>Hello Ying,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-ddiamm-bug/m-p/1048988#M21067</link>
      <description>&lt;P&gt;Hello Ying,&lt;/P&gt;

&lt;P&gt;now I understand but only partially. So if routine mkl_ddiamm takes matrix B as column oriented, it explains why it seems as if order of multiplication was changed. If my matrix B was saved in column major order, all would be as in documentation. But what has column major order in common with one-based indexing ? Arent these different things ? I am lost in this. I noticed that note about "one-based indexing" in documentation, but didnt understand. There is not any parameter of mkl_ddiamm method like "index of array item" where this note would be appropriate. Perhaps its clear for you, but I am only beginning working with MKL, so forgive my&amp;nbsp;silly questions.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 16:16:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-ddiamm-bug/m-p/1048988#M21067</guid>
      <dc:creator>Ján_K_</dc:creator>
      <dc:date>2015-09-28T16:16:48Z</dc:date>
    </item>
    <item>
      <title>I will use mkl_ddiamm method</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-ddiamm-bug/m-p/1048989#M21068</link>
      <description>&lt;P&gt;I will use mkl_ddiamm method it seems to me more effective than cblas_?trmm for my case. Instead of multiplicating formula u * s * vt from right u * (s * vt), I will do it from left (u * s) * vt. There should be a little bit more multiplications involved, but the difference isnt significant.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 16:21:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-ddiamm-bug/m-p/1048989#M21068</guid>
      <dc:creator>Ján_K_</dc:creator>
      <dc:date>2015-09-28T16:21:17Z</dc:date>
    </item>
    <item>
      <title>Hi Jan, </title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-ddiamm-bug/m-p/1048990#M21069</link>
      <description>&lt;P&gt;Hi Jan,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Right, it brings some confusion here. The "&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;one-based indexing" is not&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: rgb(67, 67, 67); font-family: Tahoma, Arial; font-size: 12px; font-weight: bold; line-height: 19.1875px; widows: auto; background-color: rgb(242, 242, 242);"&gt;apply to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;&amp;nbsp;the routine, but for all SP BLAS functions. &amp;nbsp;We should add some notes there to clarify.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;&amp;nbsp;Thanks for asking.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Please notes,&lt;/P&gt;

&lt;P&gt;this routine supports only one-based indexing of the input arrays, thus the &lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;B and C ( if suitable) were column-oriented.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;if considering the matrix structure, the mkl_ddiamm should be almost same effect as cblas_?trmm, &amp;nbsp;But you may caculate &amp;nbsp;the result either from right or left. &amp;nbsp; For example. &amp;nbsp;(u * s) * vt &amp;nbsp; , &amp;nbsp;where (u*s)t=s*ut. &amp;nbsp;here &amp;nbsp;t&lt;/SPAN&gt;&lt;SPAN style="color: rgb(67, 67, 67); font-family: Tahoma, Arial; font-size: 12px; line-height: 24px; widows: auto; background-color: rgb(242, 242, 242);"&gt;wo column-oriented make a row major, so the result should be ok.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Ying&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 01:29:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-ddiamm-bug/m-p/1048990#M21069</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2015-09-29T01:29:58Z</dc:date>
    </item>
  </channel>
</rss>

