diff --git a/gtsam/linear/HessianFactor.cpp b/gtsam/linear/HessianFactor.cpp index aa1e4e6eb..caa8e7b5b 100644 --- a/gtsam/linear/HessianFactor.cpp +++ b/gtsam/linear/HessianFactor.cpp @@ -539,6 +539,11 @@ void HessianFactor::multiplyHessianAdd(double alpha, const VectorValues& x, void HessianFactor::multiplyHessianAdd(double alpha, const double* x, double* yvalues, vector keys) const { + // Use eigen magic to access raw memory + typedef Eigen::Matrix DVector; + typedef Eigen::Map DMap; + typedef Eigen::Map ConstDMap; + // Create a vector of temporary y values, corresponding to rows i vector y; y.reserve(size()); diff --git a/gtsam/linear/HessianFactor.h b/gtsam/linear/HessianFactor.h index 91e4c8a08..f9f8c0d26 100644 --- a/gtsam/linear/HessianFactor.h +++ b/gtsam/linear/HessianFactor.h @@ -142,11 +142,6 @@ namespace gtsam { typedef SymmetricBlockMatrix::constBlock constBlock; ///< A block from the Hessian matrix (const version) - // Use eigen magic to access raw memory - typedef Eigen::Matrix DVector; - typedef Eigen::Map DMap; - typedef Eigen::Map ConstDMap; - /** default constructor for I/O */ HessianFactor(); diff --git a/gtsam/linear/JacobianFactor.cpp b/gtsam/linear/JacobianFactor.cpp index e62f8e9ef..129e832e4 100644 --- a/gtsam/linear/JacobianFactor.cpp +++ b/gtsam/linear/JacobianFactor.cpp @@ -507,6 +507,12 @@ namespace gtsam { } void JacobianFactor::multiplyHessianAdd(double alpha, const double* x, double* y, std::vector keys) const { + + // Use eigen magic to access raw memory + typedef Eigen::Matrix DVector; + typedef Eigen::Map DMap; + typedef Eigen::Map ConstDMap; + if (empty()) return; Vector Ax = zero(Ab_.rows()); diff --git a/gtsam/linear/JacobianFactor.h b/gtsam/linear/JacobianFactor.h index 31d6f4d90..6c92b1a28 100644 --- a/gtsam/linear/JacobianFactor.h +++ b/gtsam/linear/JacobianFactor.h @@ -96,11 +96,6 @@ namespace gtsam { typedef ABlock::ColXpr BVector; typedef constABlock::ConstColXpr constBVector; - // Use eigen magic to access raw memory - typedef Eigen::Matrix DVector; - typedef Eigen::Map DMap; - typedef Eigen::Map ConstDMap; - /** Convert from other GaussianFactor */ explicit JacobianFactor(const GaussianFactor& gf);