<?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 Why does LAPACKE_dormqr require double length of input array b? in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-does-LAPACKE-dormqr-require-double-length-of-input-array-b/m-p/770221#M555</link>
    <description>Hi David, &lt;BR /&gt;&lt;BR /&gt;I haven't tried the code with exact icc 12.1.3 in Ubuntu 10.04 platform. But one of parameter of LAPACKE_dormqr(matrix_order, 'L', 'T', m, &lt;STRONG&gt;n&lt;/STRONG&gt;, k, a, lda, tau, b, ldb)) seems be given wrong value. So you have to setting b=m*n=6. &lt;BR /&gt;&lt;BR /&gt;Here m, n is not related to A, but the B in QT B ( or C in MKL manual:&lt;BR /&gt;&lt;BR /&gt;&lt;DL&gt;&lt;DT class="dlterm"&gt;&lt;SPAN class="parmname"&gt;m&lt;/SPAN&gt;&lt;/DT&gt;&lt;DD&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;INTEGER&lt;/SPAN&gt;. The number of rows in the matrix &lt;VAR&gt;C&lt;/VAR&gt; (&lt;SAMP class="codeph"&gt;&lt;SPAN style="font-family: Courier New;"&gt;&lt;VAR&gt;m&lt;/VAR&gt; &lt;SPAN&gt;&lt;/SPAN&gt; 0&lt;/SPAN&gt;&lt;/SAMP&gt;). &lt;/P&gt;&lt;/DD&gt;&lt;DT class="dlterm"&gt;&lt;SPAN class="parmname"&gt;n&lt;/SPAN&gt;&lt;/DT&gt;&lt;DD&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;INTEGER&lt;/SPAN&gt;. The number of columns in &lt;VAR&gt;C&lt;/VAR&gt; (&lt;SAMP class="codeph"&gt;&lt;SPAN style="font-family: Courier New;"&gt;&lt;VAR&gt;n&lt;/VAR&gt; &lt;SPAN&gt;&lt;/SPAN&gt; 0&lt;/SPAN&gt;&lt;/SAMP&gt;). &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In your test case, the B is &lt;STRONG&gt;1&lt;/STRONG&gt; column. So if you change &lt;BR /&gt;&lt;BR /&gt;const int dim_b =3; //Note that it must double length of b!&lt;BR /&gt;double b[dim_b] = {0,1.1,2};&lt;BR /&gt;n=1;&lt;BR /&gt;&lt;BR /&gt;You will get correct value: 2.28079 0.0365148 -0.0816497. &lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Ying &lt;/P&gt;&lt;/DD&gt;&lt;/DL&gt;</description>
    <pubDate>Tue, 05 Jun 2012 06:52:10 GMT</pubDate>
    <dc:creator>Ying_H_Intel</dc:creator>
    <dc:date>2012-06-05T06:52:10Z</dc:date>
    <item>
      <title>Why does LAPACKE_dormqr require double length of input array b?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-does-LAPACKE-dormqr-require-double-length-of-input-array-b/m-p/770219#M553</link>
      <description>Using QR factorization to solve a linear least square problem requires three functions:&lt;BR /&gt;LAPACKE_dgeqrf for QR factorization matrix A = Q*R,&lt;BR /&gt;LAPACKE_dormqr for calculation of c = Q&lt;SUP&gt;T&lt;/SUP&gt;*b, and&lt;BR /&gt;dtrsm for solution of R*X = c.&lt;BR /&gt;&lt;BR /&gt;The declaration of the second function, LAPACKE_dormqu, is&lt;BR /&gt;&lt;DL class="dlsyntax"&gt;&lt;P class="dlsyntaxpara"&gt;lapack_int LAPACKE_dormqr( int matrix_order, char side, char trans, lapack_int m, lapack_int n, lapack_int k, const double* a, lapack_int lda, const double* tau, double* b, lapack_int ldb); .&lt;/P&gt;&lt;P class="dlsyntaxpara"&gt;The question is array b must hold double elements than b should. Here is an example:&lt;/P&gt;&lt;P class="dlsyntaxpara"&gt;&lt;/P&gt;&lt;P class="dlsyntaxpara"&gt;//Least_square_test.cpp&lt;/P&gt;&lt;P&gt;#include &lt;IOSTREAM&gt;&lt;/IOSTREAM&gt;&lt;/P&gt;&lt;P&gt;#include &lt;IOMANIP&gt;&lt;/IOMANIP&gt;&lt;/P&gt;&lt;P&gt;#include &lt;MKL_LAPACKE.H&gt;&lt;/MKL_LAPACKE.H&gt;&lt;/P&gt;&lt;P&gt;#include &lt;MKL_BLAS.H&gt;&lt;/MKL_BLAS.H&gt;&lt;/P&gt;&lt;P&gt;using namespace std;&lt;/P&gt;&lt;P&gt;void print(double*, int, int = 12);&lt;/P&gt;&lt;P&gt;int main(){&lt;/P&gt;&lt;P&gt;	int matrix_order = LAPACK_COL_MAJOR;&lt;/P&gt;&lt;P&gt;	lapack_int info, m(3), n(2), lda(3);&lt;/P&gt;&lt;P&gt;	double a[6] = {0,1,2,1,1,1};&lt;/P&gt;&lt;P&gt;	double tau[2] = {0.0,0.0};&lt;/P&gt;&lt;P&gt;	info = LAPACKE_dgeqrf(matrix_order, m, n, a, lda, tau)); // It works well here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	lapack_int k(2), ldb(3);&lt;/P&gt;&lt;P&gt;	const int dim_b = 6; //Note that it must double length of b!&lt;/P&gt;&lt;P&gt;	double b[dim_b] = {0,1.1,2};&lt;/P&gt;&lt;P&gt;	if(LAPACKE_dormqr(matrix_order, 'L', 'T', m, n, k, a, lda, tau, b, ldb)) // This will result right answer here!&lt;/P&gt;&lt;P&gt;		cerr&amp;lt;&amp;lt;"Something wrong in Q'*B multiplication!"&amp;lt;&lt;ENDL&gt;&lt;/ENDL&gt;&lt;/P&gt;&lt;P&gt;	else&lt;/P&gt;&lt;P&gt;		cout&amp;lt;&amp;lt;"Succeed in Q'*B multiplication!"&amp;lt;&lt;ENDL&gt;&lt;/ENDL&gt;&lt;/P&gt;&lt;P&gt;	cout&amp;lt;&amp;lt;"a = "&amp;lt;&lt;ENDL&gt;&lt;/ENDL&gt;&lt;/P&gt;&lt;P&gt;	print(a,6);&lt;/P&gt;&lt;P&gt;	cout&amp;lt;&amp;lt;"tau = "&amp;lt;&lt;ENDL&gt;&lt;/ENDL&gt;&lt;/P&gt;&lt;P&gt;	print(tau,2);&lt;/P&gt;&lt;P&gt;	cout&amp;lt;&amp;lt;"b = "&amp;lt;&lt;ENDL&gt;&lt;/ENDL&gt;&lt;/P&gt;&lt;P&gt;	print(b,dimb);&lt;/P&gt;&lt;P&gt;	cout&amp;lt;&lt;ENDL&gt;&lt;/ENDL&gt;&lt;/P&gt;&lt;P&gt;	return 0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;void print(double *a, int N, int width){&lt;/P&gt;&lt;P&gt;	for(int i = 0; i != N; ++i)&lt;/P&gt;&lt;P&gt;		cout&amp;lt;&lt;SETW&gt;&amp;lt;&lt;I&gt;&lt;/I&gt;&lt;/SETW&gt;&lt;/P&gt;&lt;P&gt;	cout&amp;lt;&lt;ENDL&gt;&lt;/ENDL&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;I compile it with Intel icpc (ICC) 12.1.3 20120212 with least MKL in Ubuntu 10.04 platform, and it display the right answer b = -2.28079 0.0365148 -0.0816497.&lt;/P&gt;&lt;P&gt;But if I set dim_b = 3, the answer is incorrect: -2.28079 0.0879783 -0.0323584, and const array tau is also changed. &lt;/P&gt;&lt;P&gt;Any comments are welcome and thank you for your answers!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;David Wu&lt;/P&gt;&lt;/DL&gt;</description>
      <pubDate>Thu, 19 Apr 2012 08:52:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-does-LAPACKE-dormqr-require-double-length-of-input-array-b/m-p/770219#M553</guid>
      <dc:creator>Wu__Wentao</dc:creator>
      <dc:date>2012-04-19T08:52:07Z</dc:date>
    </item>
    <item>
      <title>Why does LAPACKE_dormqr require double length of input array b?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-does-LAPACKE-dormqr-require-double-length-of-input-array-b/m-p/770220#M554</link>
      <description>You could study the open source and see how the arrays are used.</description>
      <pubDate>Thu, 19 Apr 2012 10:22:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-does-LAPACKE-dormqr-require-double-length-of-input-array-b/m-p/770220#M554</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2012-04-19T10:22:49Z</dc:date>
    </item>
    <item>
      <title>Why does LAPACKE_dormqr require double length of input array b?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-does-LAPACKE-dormqr-require-double-length-of-input-array-b/m-p/770221#M555</link>
      <description>Hi David, &lt;BR /&gt;&lt;BR /&gt;I haven't tried the code with exact icc 12.1.3 in Ubuntu 10.04 platform. But one of parameter of LAPACKE_dormqr(matrix_order, 'L', 'T', m, &lt;STRONG&gt;n&lt;/STRONG&gt;, k, a, lda, tau, b, ldb)) seems be given wrong value. So you have to setting b=m*n=6. &lt;BR /&gt;&lt;BR /&gt;Here m, n is not related to A, but the B in QT B ( or C in MKL manual:&lt;BR /&gt;&lt;BR /&gt;&lt;DL&gt;&lt;DT class="dlterm"&gt;&lt;SPAN class="parmname"&gt;m&lt;/SPAN&gt;&lt;/DT&gt;&lt;DD&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;INTEGER&lt;/SPAN&gt;. The number of rows in the matrix &lt;VAR&gt;C&lt;/VAR&gt; (&lt;SAMP class="codeph"&gt;&lt;SPAN style="font-family: Courier New;"&gt;&lt;VAR&gt;m&lt;/VAR&gt; &lt;SPAN&gt;&lt;/SPAN&gt; 0&lt;/SPAN&gt;&lt;/SAMP&gt;). &lt;/P&gt;&lt;/DD&gt;&lt;DT class="dlterm"&gt;&lt;SPAN class="parmname"&gt;n&lt;/SPAN&gt;&lt;/DT&gt;&lt;DD&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;INTEGER&lt;/SPAN&gt;. The number of columns in &lt;VAR&gt;C&lt;/VAR&gt; (&lt;SAMP class="codeph"&gt;&lt;SPAN style="font-family: Courier New;"&gt;&lt;VAR&gt;n&lt;/VAR&gt; &lt;SPAN&gt;&lt;/SPAN&gt; 0&lt;/SPAN&gt;&lt;/SAMP&gt;). &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In your test case, the B is &lt;STRONG&gt;1&lt;/STRONG&gt; column. So if you change &lt;BR /&gt;&lt;BR /&gt;const int dim_b =3; //Note that it must double length of b!&lt;BR /&gt;double b[dim_b] = {0,1.1,2};&lt;BR /&gt;n=1;&lt;BR /&gt;&lt;BR /&gt;You will get correct value: 2.28079 0.0365148 -0.0816497. &lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Ying &lt;/P&gt;&lt;/DD&gt;&lt;/DL&gt;</description>
      <pubDate>Tue, 05 Jun 2012 06:52:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-does-LAPACKE-dormqr-require-double-length-of-input-array-b/m-p/770221#M555</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2012-06-05T06:52:10Z</dc:date>
    </item>
  </channel>
</rss>

