I have some Eigen vectors which are concatenated from parts which I want to access. For this I use the block method. However, I need to access the same part over and over in different parts of the function. Therefore, I defined a temporary Eigen vector but I am not sure if this adds too much overhead or is optimized out anyway?
auto vec_part = vec.block<NUM_ELEMS,1>(start,0);
Any suggestions for an efficient implementation?
Regards Max
autoin the documentation: eigen.tuxfamily.org/dox/TopicPitfalls.html Basically,autois only really safe to use with Eigen when you don't nest or chain expressions (or you are lucky with their implementation and interface). So your use is okay, butvec.block(...).normalized()may not be. Use separateautovariables for thatvecis a "safe" object (e.g., a plainMatrixorArray), thenauto vec_part = vec.block<...>()is safe as well. Ifvecis known at compile-time to be a vector, you can also writevec.segment<NUM_ELEMS>(start), btw. This should not make any difference after compilation, but could be easier to read.