Re: [eigen] Convert 1x1 matrix to internal type? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Convert 1x1 matrix to internal type?
- From: David Roundy <roundyd@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 17 Sep 2010 08:27:04 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; bh=E7w9xwDI42tz0imeSBDXn9M0CY/P3GktoEV48lGEEqs=; b=kuGN1dHSef/C+GRG8mVrVngowjZsMthggrJHQcRocAuvkko5x5j2iFIQyk/maDDtpl 3jsUijsthtIYu8hseoNiEppakIf65lTLikYBc/5wiG3kSpnGvCqnAveZyqptavNGXOS/ E+mnEk1BEGtz6WaxZGm9gYZ+lNBTs1vgg7m5w=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=wGjiOErOMu1PfV8bN2Mq0grAEg+cJ/WdJ0jPuYP8ESv/jNawYA++GyPBVl2903H7Zd 4+O6yNIrGAv7Lbw37YW6czGTDXlidqntkrUitJOzMO5hAy/u54MofkkyRA9lDy+v76gf blnR71rIQjBTH++0mV2jS8DTBpfR1NUGnl9mk=
Personally, I'd greatly prefer not to have any implicit conversion
from matrices to doubles, with the possible exception of when it's
known at compile time to be a 1x1 matrix. It sounds otherwise like a
recipe for bugs.
David
On Thu, Sep 16, 2010 at 9:48 PM, 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;
>> Vector2d data;
>>
>> covariance.computeInverse(&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)[0];
>>
>> but that's a bit awkward. What is the "correct" solution to this issue?
>>
>>
>
>
>
> --
> ——
> Best Wishes From
> Wei Li
> Moblie:86-13810480212
> Dep. of Computer Science and Technology, Tshinghua Univ.
>
--
David Roundy