Re: [eigen] block of dense-block should again be block |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] block of dense-block should again be block
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Sun, 27 Jun 2010 10:36:15 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=Q6ffjhLa2/ULh8xdre64GHsldlqkWFp6v+Yf1xrm67I=; b=J9sVb6OHujHxNBc2VeD5+v6EEkwVaLNa8MObgXbEUcXMY4epNUrviEcJXtdwy7w0Ot ieaqZbwvu7rxO3haHIQ/j/WUjbZIa4/OUr6L/9Z3dvVOGe2Qypz6uuEFxi//26gXP87X RaO59cvZNoOV5fzB9GIJrT4auyuvPM2eFq64A=
- 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=FySZ65AasQqKVkUBNyO+HVh5Dl4o7GEwSJhKV/sA7tuDI5tsYpPFfP8JHXlEUHrK13 37IpIJfFYfgEbtO3IS8zt2RNkzJAxKbi2tN0fNzbqieL6cdcIBnHHlTL7exTvZLjFnhq YpX1PWqgWgWlBquCTXXkdafwuIkAaU93QBM9M=
Here is a radical proposal:
let all direct-access block() methods return a Map, not a Block.
Thus, Block would be only for the non-direct-access case anymore.
Should be renamed to something making that explicit.
People would thus no longer explicitly create a Block<MatrixXd, 4, 4>
object, instead they would create a typename BlockReturnType<MatrixXd,
4, 4>::Type object, which (they don't need to know) is a typedef for
Map<Matrix4f, outerstride...>
The MapBase class could thus be removed (merged into Map).
Benoit
2010/6/27 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
> Gael, thinking more about this, our current solution with MapBase is
> almost "good", the only remaining issue is that MapBase doesn't reduce
> the number of types instantiated. We need to make sure that if two
> Block/Map types amount to the same, then they _are_ the same type.
>
> Benoit
>
> 2010/6/27 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
>> 2010/6/27 Manoj Rajagopalan <rmanoj@xxxxxxxxx>:
>>> Hi,
>>>
>>> I have a dense matrix(expression). When I create a block out of it and
>>> another block out of this block, I should get an object of type
>>> Block<some-DenseBase-derivative>. Currently, I get
>>> Block<Block<some-DenseBase-derivative> >. Studying the code, this is the
>>> natural way to cover all cases but can the block-of-block-of-X be collapsed
>>> to just block-of-X when X is dense? AFAIK this should also apply to all X
>>> besides dense (please correct me).
>>
>> Overloading block() and friends in the Block class to return simple
>> Block<...> instead of Block<Block<...>> would be a quite good idea, as
>> it would reduce the number of Block types instantiated. Internally
>> we're inheriting MapBase anyway, so this idea is already implemented
>> internally, but reducing the number of Block types would be valuable
>> as it could result in shorter compilation and smaller executables.
>>
>> As for user expectations, I guess that in both ways some users will be
>> surprised, can't please everybody. Such contraction of expression
>> types(Block<Block<T>> into Block<T>) would be rather unique, so of
>> course it would surprise people, which is not very good.
>>
>> Users who construct named Block objects are advanced users anyway.
>>
>>> If the associativity (endomorphism on the space of data-types, actually)
>>
>> This flew 10 km above my head... a tiny white dot in the clear blue
>> sky. What is an endomorphism, with respect to what structure?
>>
>>> holds for all types X, then can a member function be introduced into class
>>> Block that solves this problem? I thought I would try this and send a patch
>>> but I am not sure the endomorphism will hold for all expression types X that
>>> Block<> could apply to.
>>
>> A patch would consist in finding a way to reimplement all
>> block-returning methods on Block, with minimal number of LOC. Need to
>> find a way to do that as automatically as possible. A patch doing all
>> that manually would be very scary. This also needs a greatly expanded
>> unit test on taking all sorts of blocks on blocks.
>>
>>> As a user I suggest that the documentation should warn users about this
>>> case if this feature is not implemented.
>>
>> Sorry, but I still don't agree that fact that .block().block() returns
>> a Block<Block<... needs a warning. Having it return a Block<...
>> instead, would be preferable for the sake of reducing template
>> istantiations, but would not AFAICS be any more intuitive.
>>
>> Benoit
>>
>>>
>>> Thanks,
>>> Manoj
>>>
>>>
>>>
>>
>