Fix Eigen3 Row/Column Major storage issue.

Eigen3 does not allow column vectors to be stored in row-major
format. NumericDiffCostFunction by default stores its Jacobian
matrices in row-major format. This works fine if the residual
contains more than one variable. But if the residual block
depends on one variable and has more than one residuals, the
resulting Jacobian matrix is a column matrix in row-major format
resulting in a compile time error.

The fix is to check the template parameters and switch to column-major
storage as needed.

Thanks to Lena Gieseke for reporting this.

Change-Id: Icc51c5b38e1f3609e0e1ecb3c4e4a02aecd72c3b
2 files changed