title: Null Space Calculation using Eigen is wrong?
body: <p>I'm using the Eigen library (<a href="http://eigen.tuxfamily.org" rel="nofollow">http://eigen.tuxfamily.org</a>) to do a Null Space calculation using the SVD function.  I compared the output to the "Null" function in matlab, and got different results.  Stepping through it with a debugger, and looking at the V matrix created by Eigen vs. the V matrix from matlab, there's an odd difference.</p>
  
  <p>The left-singular vectors (left 3 columns in the example below) in the V matrix are almost the same, but the signs are switched.  The right singular vectors (the null space; right 3 columns below) are not very similar at all.</p>
  
  <p>Any idea what would cause this?  Am I using the SVD Function incorrectly?  Code and example results below.</p>
  
  <p>Here's the code: "input" is a normal C++ array:</p>
  
  <pre><code>/* Create a matrix with the nessecary size */
  MatrixXf A(inRows, inCols);
  
  /* Populate the matrix from the input */
  for (int i=0; i &lt; inRows; i++)
  {
    for(int j=0; j &lt; inCols; j++)
    {
      A(i,j) = input[i*inCols + j];
    }
  }
  
  /* Do a singular value decomposition on the matrix */
  JacobiSVD&lt;MatrixXf&gt; svd(A, Eigen::ComputeFullV);
  
  /* Get the V matrix */
  MatrixXf V((int)svd.matrixV().rows(), (int)svd.matrixV().cols());
  V = svd.matrixV();
  </code></pre>
  
  <p>Here are some example results:</p>
  
  <p>A(input) =</p>
  
  <pre><code>-0.5059    -0.0075   -0.0121   -0.3526   -0.3528   -0.0128
  -0.0067     0.4915    0.0235   -0.3503    0.3559    0.0211
   0.0027     0.0010   -0.5015    0.0021   -0.0031   -0.4999
  </code></pre>
  
  <p>V(Matlab) =</p>
  
  <pre><code> 0.3120    0.6304    0.1115   -0.5031   -0.4895   -0.0027
   0.3628   -0.2761    0.5333    0.4955   -0.5121   -0.0018
   0.5180   -0.1804   -0.4480   -0.0002    0.0000   -0.7060
  -0.0353    0.6404   -0.2953    0.7081    0.0074   -0.0023
   0.4859    0.2283    0.4623    0.0032    0.7057    0.0048
   0.5151   -0.1775   -0.4489    0.0014   -0.0080    0.7082
  </code></pre>
  
  <p>V(Eigen) =</p>
  
  <pre><code>-0.3120   -0.6304   -0.1115   -0.5040   -0.4886   -0.0038
  -0.3628    0.2761   -0.5333    0.4638   -0.4832    0.2432
  -0.5180    0.1804    0.4480    0.1693   -0.1736   -0.6630
   0.0353   -0.6404    0.2953    0.6878    0.0257    0.1666
  -0.4859   -0.2283   -0.4623    0.0258    0.6851   -0.1677
  -0.5151    0.1775    0.4489   -0.1689    0.1665    0.6674
  </code></pre>
  
  <p>Thank you for your assistance!</p>