[eigen] No vectorization in presence of .cast<T>() calls

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi,

I have the following piece of code

MatrixXf od_full = - std::log( img_mat.cast<float>() / 255.0f + std::numeric_limits<float>::epsilon() );

where img_mat is of type

Map< Array<unsigned char,Dynamic,Dynamic,ColMajor> >.

The issue is now that I recognized that the code is not vectorized at all.. As soon as I introduce a temporary

ArrayXXf tmp = img_mat.cast<float>();
MatrixXf od_full = - std::log( tmp / 255.0f + std::numeric_limits<float>::epsilon() );

the vectorization works again as expected. Right now, I don't see, why the cast should prevent vectorization, though I admit that this might be a little bit tricky.

My use case is that I am "abusing" Eigen for some image processing algorithms and most often, images come as "unsigned char" arrays. For numerical procedures I want to convert these values to float while trying to prevent the introduction of unnecessary temporaries since sometimes my images are rather large.

Do you have any information or ideas about this issue?

- Hauke



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/