Re: [eigen] Signed-ness of size types, and better constructors for Matrix |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Signed-ness of size types, and better constructors for Matrix
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Mon, 23 Mar 2009 16:07:51 +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 :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=LKaJ4PmyuzGCClBxnd7OdJQeLHJznmy8cbcwLsRaNJ8=; b=S+7tKX2hqc3P6goDZZvPR3KB+surR0BH0HPIJSU/IuOK7tHeNKDhKTjocqo5lXlw0O 3b8KzqE2TMqIMqszodFDU0Kx9EK7v862J6JwF2RyY/EPca9a7Z2E2UAj0OAGPFjvuEQ+ jg1J8+eENEBU8aTkp6r9Dk2/ZHLp00xzOssFY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=m3T2l8cS0Gel3Q131b+XYeDOzj4t1Zz8cT/ADHOA7GMaC7Dt9IrWxpmO/nro8RaCUr yoXMFMSAngAv7L/DBoZFcmI0sWKiXAHMK7DuxU7cAyZBcmJq0W6iZ7/KjWyA4FpNXC5z DUuzFH2HzL7e9uVZy21bVSjDc5llz6INVRbQs=
Hi,
For int vs. unsigned int, one reason for our choice is that we can do
backwards for loops like
for( int i = size()-1; i >= 0; --i)
without risk (and compilers didn't always issue warnings as soon as
the situation was a bit more subtle). After having spent hours on a
bug like that, that was a very compelling argument :)
The situation for the STL is different, they try to be completely
general and lowlevel so they want their arrays to be able to have any
size up to the maximum memory size, so they must use size_t; by
contrast Eigen is just a specialized library and in our context,
"unsigned" only brings some trouble and no intrinsic advantage.
The problem with passing unsigned ints to the constructors could then
be reversed: if our constructors took unsigned arguments, then people
trying to pass plain ints would have the same problem....
> The Matrix constructors should use some equivalent of boost::enable_if so
> they are only available when they should be
Ah, that sounds like a good idea. I will try it. But at some point
(maybe at a different place) Gael tried something like that and there
was an issue, but I don't remember. Yes the macro trick with
EIGEN_PARSED_BY_DOXYGEN seems useful to prevent documentation from
being affected by that.
Cheers,
Benoit