Re: [eigen] Enhanced AlignedBox |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Enhanced AlignedBox
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Sat, 16 Jan 2010 10:15:40 +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; bh=nJNwzDc3P/PYnQGHWhPi6N5JMuv5423nCSNYdx3fhWE=; b=c/lPaJpv/dWoeKFOF/MmYH3GRE0bO/IbAAf70F2GHFsb0vC/8+Nu+NkE9ATOAIw/kc DDl6UcFXTQNUsc50WYU2bpacCYLBxbmz5GGTqfBvxuTfKbcRM3clZBu/5PpxYNhuKsim r9ma8nzMhXRKy+2hs7VL1tXEkWcophCshUTp4=
- 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=X7wqxj/wwJWjbwKFebpinzeGkG44OJSrh/JB3VhGh0frKuXxHYDA6F6Gsu/tFiXAWc wKPxS8fc02nbaewN4ybY8Y4zwHF3mx8y0tG2gyRlEH7wA4OuL1N8smJu3v4a8cl2T7jj gRTUFv+DdnjoSxPIQwDCb4jhFpTziMk1sLiB0=
On Sat, Jan 16, 2010 at 5:31 AM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> 2010/1/15 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:
>> On Wed, Dec 23, 2009 at 7:47 PM, Manuel Yguel <manuel.yguel@xxxxxxxxx> wrote:
>>> On Tue, Dec 22, 2009 at 2:48 PM, Gael Guennebaud
>>>> * Why did you template the functions taking another aligned box.
>>>> (e.g., contains(), extend(), clamp(), etc.). I mean, both the
>>>> dimension and the scalar type have to be exactly the same, so no need
>>>> to template them.
>>> Why? I agree for the dimension, but not necessary for the scalar type.
>>> One can want float for hardware reason and double for precision in an
>>> other part of the application.
>>
>> Actually, this is mainly because we cannot rely on automatic type
>> conversion when enabling vectorization. Therefore, throughout Eigen we
>> enforce that both operand of a binary operations have the same scalar
>> type. Consequently, even if you allow contains() to accept different
>> scalar types, the code wont compile. To mix different scalar type you
>> have to explicitly do a cast. So two options:
>>
>> 1 - contains() only accepts the same scalar type, and the user have to
>> cast one of the operand
>> 2 - contains() accepts different scalar types and the implementation
>> of contains() have to be updated to ensure consistent types that is
>> quite complicated because you have to determine whether casting
>> *this's members or the argument.
>>
>> For the latter reason, and to be consistent with the rest of Eigen,
>> and to not hide any implicit conversions, I really vote for option 1.
>
> I vote for 1. too.
>
> Manuel: note that the user can do cast<double>() wherever he wants to,
> and that has no cost other than the casting itself, so we're not
> limiting the power of eigen here, we're just forcing casts to be
> explicit rather than implicit.
>
>>> Do you think it is the eigen way to add some fields and/or static
>>> methods to NumTraits in order to provide the equivalent following
>>> informations?
>>
>> so far we used global functions.
>>
>>> In the std::numeric_limits they give also minimum positive number,
>>> precision, codes for NAN, +INF etc...
>>> I saw that you define dummy_precision as a template function, should
>>> it not be a static method part of the NumTraits such that someone can
>>> easily change the default behaviour by defining its own NumTraits ?
>>
>> why not. At least why you propose allow to centralize everything in a
>> single place.
>>
>> Benoit, what do you think ?
>
> Initially I too considered putting everything in NumTraits. The reason
> why I didn't stick with that, was just the heaviness of the notation.
> But thinking about it, for dummy_precision(), it's not too bad, and we
> don't use it frequently anyway. So yes why not! Same for epsilon(). As
> long as ei_exp() and such remain global functions, I'm happy.
yes the math functions must remain global functions. So let's do it.
>
>>
>>>
>>> If you agree with that I would make the changes adding the static functions:
>>> highest()
>>> lowest()
>>> dummy_precision()
>>> adding the value for -INF also etc...
>>>
>>> and after we can mimic std::numeric_limits
>>> epsilon()
>>> has_infinity()
>>> has_quiet_NaN()
>>> has_signaling_NaN()
>>> etc ...
>>
>> Then why not simply make NumTraits<Foo> inherits std::numeric_limits<Foo>?
>
> Good idea! (AFAICS)
ok, good.
gael
>
> Benoit
>
>
>