Allocate temporary matrix on the stack rather tahn on heap, and give VerticalBlockMatrix a view on it.

release/4.3a0
dellaert 2014-10-15 00:56:06 +02:00
parent c88b2a5902
commit 9b1c9bbf37
1 changed files with 5 additions and 2 deletions

View File

@ -85,12 +85,15 @@ public:
// Get dimensions of Jacobian matrices
std::vector<size_t> dims = expression_.dimensions();
// Allocate memory on stack and create a view on it (saves a malloc)
size_t m1 = std::accumulate(dims.begin(),dims.end(),1);
Matrix matrix = Matrix::Identity(T::dimension,m1);
double memory[T::dimension*m1];
Eigen::Map<Eigen::Matrix<double,T::dimension,Eigen::Dynamic> > matrix(memory,T::dimension,m1);
matrix.setZero(); // zero out
// Construct block matrix, is of right size but un-initialized
VerticalBlockMatrix Ab(dims, matrix, true);
Ab.matrix().setZero(); // zero out
// Create blocks to be passed to expression_
JacobianMap blocks;