Registered Member
|
Hello
If I do this simple Matrix Computation . I should exipit aliasing, but why do I not? Because G.block(0,0,10,12)*P is a temporary?, Because of vectorization? I turned it of with EIGEN_DONT_VECTORIZE before header include....
Output
The other thing is this statement: (P_back, P_front, m_c are Vectors, G, R are Matrices). How do I know where in this statement are temporaries involved? Nowhere because I write .noalias(), and everything gets evaluated into P_front, so no temporaries for G*P_back...?
Thanks!! |
Moderator
|
this is because in your example:
P.segment<10>(0).noalias() = (P.segment<10>(0) + G.block(0,0,10,12)*P); the nested product G.block(0,0,10,12)*P has to be evaluated into a temporary. To avoid it you should use operator+=: P.segment<10>(0).noalias() += G.block(0,0,10,12)*P; Then you get a wrong result. In your second example you have two temporaries, one for each products. Again, you can avoid one by writing: P_front = P_back; P_front.noalias() -= R*(G *P_back + m_c); In the near future, Eigen will be able to this kind of high level optimizations for you. |
Moderator
|
there are some hints there: http://eigen.tuxfamily.org/dox-devel/To ... ssion.html
|
Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar