Re: [eigen] odd behaviour of operator[] |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] odd behaviour of operator[]
- From: Tim Hutt <tdhutt@xxxxxxxxx>
- Date: Thu, 18 Jun 2009 18:54:25 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=iOAKspCIWF03uTiBtn+HRjRXhvV7jW+dIf2QCOJQ0Ks=; b=frGgpW7BB/ocjqWxdiy1Os+UF6QSh5e1uxmmcKqi4HDsqu5iR1Sno5fYXAXs1UYoDj VorNKd/zRcRsa5ExrkcOxgRFZA+c/D9Lps/a97HmxR7sqgDOISPx0wWUu6DtH4uGsyKQ n0GAnZ0Qb/AB6dQooZKRuFj5X8Qx+1+G2YlNM=
- 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:content-transfer-encoding; b=kLx/hVEQxmrSDanyJgbTx9jhjOT3e3iZtjdDkGqUQf/YRvDktvIBmbRdkANOx63Ju8 6UdMlXL/cyT2mGU9hd7vaACM1/4NSwR0wpQSmutp2r1hmzUUe0rxGwdHjpLszE16LrkN ubwyJXcWBTRcHZUJEPn5l0jwvQ/kg7e+cNTU4=
2009/6/18 Andre Krause <post@xxxxxxxxxxxxxxxx>:
> states[a, 0] = sin(0.1*a);
> states[a, 1] = sin(0.2*a);
> states[a, 2] = sin(0.3*a);
> oddly enough, this code compiles fine and executes without asserts, but assigns
> strange values to the array.
GCC gives a warning about the ',' operator having no effect. Due to
operator precedence and stuff, the comma is evaluated and then the
result of that comma is passed to the [] operator.
It is the equivalent of writing: states[(a, 0)] = sin(0.1*a);
Which is the same as: a; states[0] = sin(0.1*a);
See http://msdn.microsoft.com/en-us/library/zs06xbxh(VS.80).aspx