I have many expressions that look like
auto result = vec3f.cwiseProduct( vec3ui );
where vec3f
is from type Eigen::Matrix< float, 3, 1 >
and vec3ui
is from Eigen::Matrix< unsigned int, 3, 1 >
. These doesn't seem to be allowed, at least the compiler complains about it.
Hence I need to write the above like
Eigen::Matrix< float, 3, 1 > result( vec3f.x() * vec3ui.x(), /*...*/ );
which leads to very long, less-readable code.
Is it possible to vectorize the above expression using Eigen 3?
You need to cast the second matrix to the form of the first, like this:
Eigen::Matrix< float, 3, 1 > mf;
Eigen::Matrix< unsigned int, 3, 1 > mi;
mf.dot(mi.cast<float>());
Also, Eigen gives ready to use types for vectors, like Eigen::Vector3f
for floats and Eigen::Vector3i
for ints. (but none for unsigned int
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.