|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: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Thu, 23 Sep 2010 18:48:08 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=c/dOKim2z9rJzxgvEXCHxZX/l7EH2OpfBRPM4QK3tXY=; b=XY72E6wtan61TfUC0U3Gq5RZXFFoWvFh7aSlMgNhfJOvrmMprKxBQOzu+goifWNKz3 K9pSaQCUtUJtVcv5HWNKS7aU79M2xR0QVmg4wG4o0nNU4nfHl5y61+JvkD/WyKDqwIQR gq3cvPVcGknyctYddTHIs5acTJ/Z4q4c55cJ8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=ohCaN7k8nEsnbTmUdplRPiO5itP3ES9iFUfxhZHegUed465fFEcCSxY24UFmqFowK4 yphweMIqNF4ZNMKSY0HL5fG745zMNeJDbmM2ciFe4AScBsbLN9h+UbnX5Gu2pPSjlCCl ZBWXKhqIuMoDwGHciyHCd9aBucE6uX9BS1ALc=
On Thu, Sep 23, 2010 at 6:40 PM, Gael Guennebaud
> unfortunately, allowing automatic conversion for any 1x1 matrix leads
> to many ambiguities (I don't remember exactly but there is a old
> thread where I listed them).
for the record:
ok I've a working version of that:
mat = 1;
float x = mat + 1
but there is a quite big downside:
mat * 2
does not compile anymore because there is an ambiguity which has to be
resolved by doing either:
mat * Scalar(2);
mat * 2.f;
Scalar(mat) * 2;
Maybe the worst thing is that such an ambiguity will show up for 1x1
objects only... so think about general template code which compile
fine for all objects except 1x1. Since the later ones are likely not
be well tested....
also not that :
double x = 2. * vec1.transpose() * vec2;
won't work, so enabling such a conversion only for inner product is
not 100% ideal....