I'm sorry to raise a general question about Eigen3'scheme of optimized computation. Let's imagine we do possess two Eigen3 matrices, M and N. Imagine we need to compute the following:
Eigen::Matrix<double, 3,3> M;
Eigen::Matrix<double, 3,3> N;
// here is the computation:
Eigen::Matrix<double, 3,3> D = Eigen::Matrix<double, 5,5>::Identity() + M;
Eigen::Matrix<double, 3,3> R = D * N * D.transpose();
What I would like to know is: is there a ways to avoid copying the expression I + M into a full matrix (thus a copy), and instead use a lazy-evaluation scheme in such an expression. Hopefully, it would be feasible to write in C++11 something like this instead:
auto D = Eigen::Matrix<double, 3,3>::Identity() + M;
Eigen::Matrix<double, 3,3> R = D * N * D.transpose();
Normally, D is in this case a compound (potentially complex) template lazy-eval. type, so this normally should solve the problem. Could you correct me if not so ?
In the same order of idea, I would like to do the same with:
auto E = <undisclosed_type coma initializer>(
M,
Eigen::Matrix<double, 3,3>::Zero());
Eigen::Matrix<double, 6,6> R = E * N * E.transpose();
but I do not see how to perform such an optimization. So, if there is a way to optimize this out in term of instruction number in the evaluation process, this could help me.
Thanks in advance for your help.
Aucun commentaire:
Enregistrer un commentaire