[eigen] Convert 1x1 matrix to internal type?

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

It seems to me that a 1x1 matrix ought to be convertible to its internal type. Maybe it is, but if so, there's some kind of problem. Consider the computation for Mahalanobis distance:

Matrix2d covariance, covInverse;
Vector2d data;

double mdist = data.transpose()*covInverse*data;

You would think this would work fine, since the result ix 1x1. However, it gives an error that an Eigen::Multiply cannot be converted to a double.

I can get around this by doing

double mdist = (data.transpose()*covInverse*data)[0];

but that's a bit awkward. What is the "correct" solution to this issue?

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