mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-30 00:50:37 +08:00
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
This commit is contained in:
committed by
ceres-solver code review
parent
9ad27e8e9f
commit
295ade1122
@@ -93,11 +93,13 @@ struct Differencer {
|
||||
using Eigen::Map;
|
||||
using Eigen::Matrix;
|
||||
using Eigen::RowMajor;
|
||||
using Eigen::ColMajor;
|
||||
|
||||
typedef Matrix<double, num_residuals, 1> ResidualVector;
|
||||
typedef Matrix<double, parameter_block_size, 1> ParameterVector;
|
||||
typedef Matrix<double, num_residuals, parameter_block_size, RowMajor>
|
||||
JacobianMatrix;
|
||||
typedef Matrix<double, num_residuals, parameter_block_size,
|
||||
(parameter_block_size == 1 &&
|
||||
num_residuals > 1) ? ColMajor : RowMajor> JacobianMatrix;
|
||||
|
||||
Map<JacobianMatrix> parameter_jacobian(jacobians[parameter_block],
|
||||
num_residuals,
|
||||
|
||||
Reference in New Issue
Block a user