|Re: [eigen] Convert 1x1 matrix to internal type?|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: "eigen@xxxxxxxxxxxxxxxxxxx" <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] Convert 1x1 matrix to internal type?
- From: Márton Danóczy <marton78@xxxxxxxxx>
- Date: Fri, 17 Sep 2010 11:36:51 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:from:in-reply-to:mime-version :references:date:message-id:subject:to:content-type; bh=9iC1Yf+mi5tGwcWcUXJyF6ChyXUk9YJeYiF60XhB7/w=; b=lXjyCoa75BJ7/uxKTCvEgTbt/DH4mtOWQ1/7tl+vVwlBZO45K/b3ANKigD59XFGuym bE6rGUPecMzP7bSEtO3HWf29x3QDmL9VhPpceVaQy9yy8mwp4kaDQgZ0XmUNXV6Se9UP bXzW8KfwAGusT7rG//VxJpC8j048yNLGkCT6I=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:in-reply-to:mime-version:references:date:message-id:subject:to :content-type; b=Yy/W/NiJ23A7L+KHCQSKOyTkv1gDjFrVzQ2JsJN5s/msuepRyfVFez5w4tidbi/Kiw 5cgE1sucMfakkF11DY33NGQNBholjS/dep7ZssGNYf8yldVCRJoPP4PKqYqwDkznUNYd mijbt0XMW4HX3D+OJuAJXP0zIdyxYBn0r6hM0=
What about (untested):
double d = covariance.llt().matrixL().solve(data).squaredNorm();
Not that it answers your question, but this is the faster and numerically more stable way to compute it :)
How about converts to any matrix double type to its first element(top-left corner) in release mode by default, but with dimensionality check in debug mode.
On Thu, Sep 16, 2010 at 3:33 AM, <lfrfly@xxxxxxxxxxx>
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;
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);
but that's a bit awkward. What is the "correct" solution to this issue?
Best Wishes From
Dep. of Computer Science and Technology, Tshinghua Univ.