QR decomposition in C++ by LAPACK
<p>I have recently installed a new library for matrix calculation in C++, called <a href="http://www.netlib.org/lapack/" rel="nofollow noreferrer">LAPACK</a>. I am beginner in this field and wanted to test its application in QR decomposition by using the <code>dgeqrf</code> function. I prepared this simple code below:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;lapacke.h&gt;

using namespace std;

int main()
{
    double a[4] = {0, 2, 2, -1};

    int m=2;
    int n=2;
    int info = 0;
    int lda = m;
    int lwork = n;
    double *work;
    double *tau;

    dgeqrfp_(&amp;m, &amp;n, a, &amp;lda, tau, work, &amp;lwork, &amp;info);
}
</code></pre>

<p>I built it without error but when I tried to run it, it didn't work. I got these warning messages:</p>

<pre><code>D:\c++ code\lllll\main.cpp|15|warning: 'tau' is used uninitialized in this function [-Wuninitialized]|
D:\c++ code\lllll\main.cpp|15|warning: 'work' is used uninitialized in this function [-Wuninitialized]|
</code></pre>

<p>I don't know what's the problem but I think my definition of the <code>dgeqrf</code> function is wrong. </p>

<p>Also, the <code>dgeqrf</code> is a <code>void</code> function. I need to save its result (Q matrix) into an another matrix and use it in my calculation.</p>

<p>Does anyone have an idea about it?</p>