|Re: [eigen] Convert 1x1 matrix to internal type?|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Convert 1x1 matrix to internal type?
- From: Jim Bosch <talljimbo@xxxxxxxxx>
- Date: Tue, 21 Sep 2010 10:31:27 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=3S+eOE76eXFY9gcFN7wBMDexTlsioIBIRHLasy+MwVw=; b=KEsIizFUl4zP9AJN1qm4lInT9Ksvgomz/UGVCUnqC/9KGAEcOcR7Bur2he47ZTiGJx +WDlLP6UHhAISYpLEfIWvc3cmf+ecn8Afd+WG8VfEozwHgx0yuSzNE0kYO9f25cnnr4/ gAZH9m5k5nsp5GsdUJGxD6mkbBIDjvoZ0ZEtw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=a3dqPiNqURsBADD6YrpAzztrq438yR33EKFGsHxxq/tVYgrRIK2Hahw+hyuhUOFvez vxXe9QE2UyUL6apgsGB4evQMMEUtdQDXYjbbeJ+n7DosD7qsycbY0m33Q6ewDa3gteTv QpwojMeumMCDvWSfTLLgceRljLKry2pweqoRQ=
You can also use dot:
double d = data.dot(covInverse * data);
On 09/21/2010 07:40 AM, lfrfly@xxxxxxxxxxx wrote:
Indeed, a Cholesky decomposition is a better option. However, the below
does not appear to be correct. I'm going to keep working the problem,
but in the meantime does anyone know how the Eigen expression to compute
Mahalanobis distance from the origin using a Cholesky decomposition?
From: Márton Danóczy <marton78@xxxxxxxxx>
To: eigen@xxxxxxxxxxxxxxxxxxx <eigen@xxxxxxxxxxxxxxxxxxx>
Sent: Fri, Sep 17, 2010 5:36 am
Subject: Re: [eigen] Convert 1x1 matrix to internal type?
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 :)
On 17.09.2010, at 03:48, Li Wei <lwthucs@xxxxxxxxx> wrote:
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> wrote:
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.