Re: [Boost-users] matrix<double> initialization
18 Aug
2006
18 Aug
'06
4:05 p.m.
From: Minkoo Seo
for (unsigned i = 0; i < 3; i++) m(i, i) = -i;
In this code, I'm trying to initialize the diagonal with -1, -2, -3. But, the result is obviously different from what I expected:
[3,3]((0,0,0),(0,4.29497e+09,0),(0,0,4.29497e+09))
If you must use unsigned, then change to: m(i, i) = -1.0 * static_cast<double>(i); What it's doing now is this: i = 1; -i = 4294967295; // it's unsigned, after all double(-i) = 4.295e+9 Probably clearer to use int instead of unsigned, though. - James Jones Administrative Data Mgmt. Webmaster 375 Raritan Center Pkwy, Suite A Data Architect Edison, NJ 08837
6664
Age (days ago)
6664
Last active (days ago)
0 comments
1 participants
participants (1)
-
james.jonesīŧ firstinvestors.com