Registered Member
|
Hi,
using Eigen 3.2, when i do
the expression is always evaluated into a temporary variable, which is required since it cannot be assumed that a and b are not the same variable. (See SparseVector::operator= in SparseVector.h) This is not very nice for the performance. Inspired by Eigen::NoAlias i wrote the two following files to work around this issue: eigen_sparsevector_plugin.hpp
test.cpp
This seems to work, but it my real world application i use something similar to the following code:
Is there a feasible way how to use the approach shown above could be used here. I basically want to avoid any dynamic memory allocation in the last line. I read about the new expression evaluator, but I am not clear if this is related. Thanks, Alex |
Moderator
|
I guess that in your real-world example the dimension of the problem is much larger (1000 or more), and that the expression is also much more involved and so temporaries will be created along the way anyway because the expression template mechanism won't apply at the coefficient level.
|
Registered Member
|
Hi,
thanks for the quick answer. The real world example is a templated algorithm which does not create any temporaries when double is used instead of AutoDiffScalar. So i think that is not in the way. The expressions used in the algorithm are mainly C = A * B or C.noalias() += A*B. However oftern A and B are blocks. The motivation is that if no temporaries for SparseVector are involved, the algorithm will initialize the sizes of the required derivative vector on the first run. This would the hopefully lead to all further executions being free of malloc. Just some details of the real-world application: The size of the derivative vector is ~100 and the matrix/vector dimensions ~50. The resulting derivative vectors are quite sparse and reveal the structure of the expressions computed. Also the amount of cache needed when using AutoDiffScalar<VectorXd> is quite big in comparsion to what SparseVector<double> needs. The purpose of the algorithm is to compute robot dynamics. Thanks, Alex |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]