title: c++/eigen:compute the orthonormal basis for the null space
body: <p>Matlab has a function:</p>
  
  <pre><code>Z = null(A);
  </code></pre>
  
  <p>This MATLAB function is an orthonormal basis for the null space of A obtained
   from the singular value decomposition.</p>
  
  <p>I have to convert the MATLAB code to C++ on eigen library,but I don't know how to do this.
  I have tried:</p>
  
  <pre><code>MatrixXf m = MatrixXf::Random(3,5);
  cout &lt;&lt; "Here is the matrix m:" &lt;&lt; endl &lt;&lt; m &lt;&lt; endl;
  MatrixXf ker = m.fullPivLu().kernel();
  cout &lt;&lt; "Here is a matrix whose columns form a basis of the kernel of m:"
  &lt;&lt; endl &lt;&lt; ker &lt;&lt; endl;
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Here is the matrix m:
  0.68   0.597   -0.33   0.108   -0.27
  -0.211   0.823   0.536 -0.0452  0.0268
   0.566  -0.605  -0.444   0.258   0.904
  Here is a matrix whose columns form a basis of the kernel of m:
  -0.219   0.763
  0.00335  -0.447
    0       1
    1       0
   -0.145  -0.285
  </code></pre>
  
  <p>It's not the "orthonormal" basis for the null space.</p>