use safer eigen indexing syntax
parent
bfb21c2faa
commit
9165041299
|
|
@ -36,7 +36,6 @@ namespace gtsam {
|
||||||
*/
|
*/
|
||||||
JacobianFactor linearizeNumerically(const NoiseModelFactor& factor,
|
JacobianFactor linearizeNumerically(const NoiseModelFactor& factor,
|
||||||
const Values& values, double delta = 1e-5) {
|
const Values& values, double delta = 1e-5) {
|
||||||
|
|
||||||
// We will fill a vector of key/Jacobians pairs (a map would sort)
|
// We will fill a vector of key/Jacobians pairs (a map would sort)
|
||||||
std::vector<std::pair<Key, Matrix> > jacobians;
|
std::vector<std::pair<Key, Matrix> > jacobians;
|
||||||
|
|
||||||
|
|
@ -53,11 +52,11 @@ JacobianFactor linearizeNumerically(const NoiseModelFactor& factor,
|
||||||
Matrix J = Matrix::Zero(rows, cols);
|
Matrix J = Matrix::Zero(rows, cols);
|
||||||
for (size_t col = 0; col < cols; ++col) {
|
for (size_t col = 0; col < cols; ++col) {
|
||||||
Eigen::VectorXd dx = Eigen::VectorXd::Zero(cols);
|
Eigen::VectorXd dx = Eigen::VectorXd::Zero(cols);
|
||||||
dx[col] = delta;
|
dx(col) = delta;
|
||||||
dX[key] = dx;
|
dX[key] = dx;
|
||||||
Values eval_values = values.retract(dX);
|
Values eval_values = values.retract(dX);
|
||||||
const Eigen::VectorXd left = factor.whitenedError(eval_values);
|
const Eigen::VectorXd left = factor.whitenedError(eval_values);
|
||||||
dx[col] = -delta;
|
dx(col) = -delta;
|
||||||
dX[key] = dx;
|
dX[key] = dx;
|
||||||
eval_values = values.retract(dX);
|
eval_values = values.retract(dX);
|
||||||
const Eigen::VectorXd right = factor.whitenedError(eval_values);
|
const Eigen::VectorXd right = factor.whitenedError(eval_values);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue