<?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 The Lapack routines ?geqrf() in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-with-dgeqrf-and-dorgqr/m-p/1109141#M24265</link>
    <description>&lt;P&gt;The Lapack routines ?geqrf() do not use Gram-Schmidt or Modified Gram-Schmidt. In fact, after calling ?geqrf() the input matrix has been overwritten by the Householder reflectors that were produced by the factorization.&lt;/P&gt;

&lt;P&gt;In other words, Q is not stored in the usual matrix convention, but as a sequence of reflectors from which, if desired, one can calculate the usual representation of Q by calling ?orgqr(). However, in many algorithms one does not want Q explicitly, but wishes to obtain the product of Q and another matrix, using ?ormqr().&lt;/P&gt;

&lt;P&gt;If you really wish to obtain Q explicitly and insist on a convention (e.g., all diagonal elements of R should be positive, as you specified), it is easy to flip the signs of the corresponding columns of Q and rows of R to suit.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2016 17:28:34 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2016-04-28T17:28:34Z</dc:date>
    <item>
      <title>Problems with dgeqrf and dorgqr</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-with-dgeqrf-and-dorgqr/m-p/1109138#M24262</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm having some unexpected results with the function LAPACKE_dgeqrf. Apparently I'm unable to get the appropriate QR decomposition at some cases, I'm rather obtaining a QR decomposition with some unexpected vector orientations for the orthogonal matrix Q.&lt;/P&gt;

&lt;P&gt;Here is a MWE of the problem:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include "mkl.h"

#define N 2

int main()
{
    double *x   = (double *) malloc( sizeof(double) * N * N );
    double *tau = (double *) malloc( sizeof(double) * N );
    int i, j;

    /* Pathological example */
    x[0] = 4.0, x[1] = 1.0, x[2] = 3.0, x[3] = 1.0;

    printf("\n INITIAL MATRIX\n\n");
    for (i = 0; i &amp;lt; N; i++) {
        for (j = 0; j &amp;lt; N; j++) {
            printf(" %3.2lf\t", x[i*N+j]);
        }
        printf("\n");
    }

    LAPACKE_dgeqrf ( LAPACK_ROW_MAJOR, N, N, x, N, tau);

    printf("\n R MATRIX\n\n");
    for (i = 0; i &amp;lt; N; i++) {
        for (j = 0; j &amp;lt; N; j++) {
            if ( j &amp;gt;= i ){
                printf(" %3.2lf\t", x[i*N+j]);
            }else{
                printf(" %3.2lf\t", 0.0);
            }
        }
        printf("\n");
    }

    LAPACKE_dorgqr ( LAPACK_ROW_MAJOR, N, N, N, x, N, tau);

    printf("\n Q MATRIX\n\n");
    for (i = 0; i &amp;lt; N; i++) {
        for (j = 0; j &amp;lt; N; j++) {
            printf(" %3.2lf\t", x[i*N+j]);
        }
        printf("\n");
    }

    printf("\n");

    return 0;
}
&lt;/PRE&gt;

&lt;P&gt;With this example, the output I get is:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;INITIAL MATRIX&lt;/P&gt;

&lt;P&gt;&amp;nbsp;4.00&amp;nbsp;&amp;nbsp; &amp;nbsp; 1.00&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;3.00&amp;nbsp;&amp;nbsp; &amp;nbsp; 1.00&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;R MATRIX&lt;/P&gt;

&lt;P&gt;&amp;nbsp;-5.00&amp;nbsp;&amp;nbsp; &amp;nbsp; -1.40&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;0.00&amp;nbsp;&amp;nbsp; &amp;nbsp; 0.20&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;Q MATRIX&lt;/P&gt;

&lt;P&gt;&amp;nbsp;-0.80&amp;nbsp;&amp;nbsp; &amp;nbsp; -0.60&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;-0.60&amp;nbsp;&amp;nbsp; &amp;nbsp; 0.80&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;However, the expected QR decomposition would be:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;R MATRIX&lt;/P&gt;

&lt;P&gt;&amp;nbsp;5.00&amp;nbsp;&amp;nbsp; &amp;nbsp; 1.40&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;0.00&amp;nbsp;&amp;nbsp; &amp;nbsp; 0.20&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;Q MATRIX&lt;/P&gt;

&lt;P&gt;&amp;nbsp;0.80&amp;nbsp;&amp;nbsp; &amp;nbsp; -0.60&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;0.60&amp;nbsp;&amp;nbsp; &amp;nbsp; 0.80&amp;nbsp;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I have found this problem with other Initial matrices as well.&lt;/P&gt;

&lt;P&gt;Thanks in advance,&lt;/P&gt;

&lt;P&gt;Paulo&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2016 13:45:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-with-dgeqrf-and-dorgqr/m-p/1109138#M24262</guid>
      <dc:creator>Paulo_G_1</dc:creator>
      <dc:date>2016-04-28T13:45:33Z</dc:date>
    </item>
    <item>
      <title>There is no problem. Just as</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-with-dgeqrf-and-dorgqr/m-p/1109139#M24263</link>
      <description>&lt;P&gt;There is no problem. Just as (-2) X&amp;nbsp;3 and 2 X (-3) are both acceptable factorizations of -6, some columns of Q and the corresponding rows of R may have their signs flipped.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2016 14:11:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-with-dgeqrf-and-dorgqr/m-p/1109139#M24263</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2016-04-28T14:11:20Z</dc:date>
    </item>
    <item>
      <title>yeap, I know that the given</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-with-dgeqrf-and-dorgqr/m-p/1109140#M24264</link>
      <description>&lt;P&gt;Hello mecej4, thanks for the reply,&lt;/P&gt;

&lt;P&gt;yeap, I know that the given factorization is acceptable. My point (and I probably should have mentioned that explicitly in the description of the problem) is that it is not the expected factorization obtained typically by the gram-schimidt process. It may seem irrelevant, but in the particular application I'm interested it is very important that the directions of the orthonormalized column vectors of Q are preserved, so as the diagonal elements of R are positive.&lt;/P&gt;

&lt;P&gt;So, in other terms, is it possible to force the library to obtain the expected QR decomposition by GS?&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2016 15:21:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-with-dgeqrf-and-dorgqr/m-p/1109140#M24264</guid>
      <dc:creator>Paulo_G_1</dc:creator>
      <dc:date>2016-04-28T15:21:00Z</dc:date>
    </item>
    <item>
      <title>The Lapack routines ?geqrf()</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-with-dgeqrf-and-dorgqr/m-p/1109141#M24265</link>
      <description>&lt;P&gt;The Lapack routines ?geqrf() do not use Gram-Schmidt or Modified Gram-Schmidt. In fact, after calling ?geqrf() the input matrix has been overwritten by the Householder reflectors that were produced by the factorization.&lt;/P&gt;

&lt;P&gt;In other words, Q is not stored in the usual matrix convention, but as a sequence of reflectors from which, if desired, one can calculate the usual representation of Q by calling ?orgqr(). However, in many algorithms one does not want Q explicitly, but wishes to obtain the product of Q and another matrix, using ?ormqr().&lt;/P&gt;

&lt;P&gt;If you really wish to obtain Q explicitly and insist on a convention (e.g., all diagonal elements of R should be positive, as you specified), it is easy to flip the signs of the corresponding columns of Q and rows of R to suit.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2016 17:28:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-with-dgeqrf-and-dorgqr/m-p/1109141#M24265</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2016-04-28T17:28:34Z</dc:date>
    </item>
    <item>
      <title>I see, I did that already,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-with-dgeqrf-and-dorgqr/m-p/1109142#M24266</link>
      <description>&lt;P&gt;I see, I did that already, but I was hoping it could be done by the library, so I wouldn't need the extra loop for flipping the signs&lt;/P&gt;

&lt;P&gt;Unfortunately, I do need the Q matrix explicitly and also need its columns to be aligned so all diagonal elements of R are positive.&lt;/P&gt;

&lt;P&gt;Anyway, thank you very much for your help.&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2016 17:37:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-with-dgeqrf-and-dorgqr/m-p/1109142#M24266</guid>
      <dc:creator>Paulo_G_1</dc:creator>
      <dc:date>2016-04-28T17:37:51Z</dc:date>
    </item>
  </channel>
</rss>

