|
Ublas : |
Subject: Re: [ublas] [feature request] new free functions for matrix/vector sizes
From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2010-09-20 17:29:51
On Sat, Jul 3, 2010 at 12:16 AM, Marco Guazzone
<marco.guazzone_at_[hidden]> wrote:
> On Sun, Jun 20, 2010 at 10:31 PM, Marco Guazzone
> <marco.guazzone_at_[hidden]> wrote:
>> On Fri, Oct 9, 2009 at 8:16 PM, Gunter Winkler <guwi17_at_[hidden]> wrote:
>>> Marco Guazzone schrieb:
>>>> OK Got it!
>>>> I'll try to follow this way in future implementations.
>>>> For what concern my committed code, I've seen some code need still to
>>>> be adequated. If you I can help you to change it. Let me know.
>>>>
>>> Feel free to send patches at any time.
>>>
>>
>> Hello,
>>
>> I'm considering to change the code of the "size" operation (that I
>> wrote months ago) for two reasons:
>>
>> 1. to use the new uBLAS traits system introduced by Gunter
>> E.g.:
>> typename ExprT::size_type size(...)
>> ==>
>> typename matrix_traits<ExprT>::size_type size(...)
>>
>> 2. to make it directly usable with *_expression<E> types rather than
>> passing the contained expression E
>> E.g.:
>> template <typename E>
>> void do_something(vector_expression<E> const& ve)
>> {
>> s = size(ve());
>> }
>> ==>
>> template <typename E>
>> void do_something(vector_expression<E> const& ve)
>> {
>> s = size(ve);
>> }
>> (surely less annoying ;) )
>>
>
> [big-cut]
>
>> PS: ok! One solution might be to create a different function
>> "size_by_tag" and to remove the polymorphic call "size<tag>()"; but
>> this would break compatibility with code developed after the release
>> of boost 1.41.
>>
>
> At the end, after several trials, I am unable to make the
> "size<tag>()" works with the new changes.
>
> I've created a new ticket
>
> https://svn.boost.org/trac/boost/ticket/4399
>
> where I propose a change (and a patch) which however *break back compatibility*.
> Specifically, instead of using "size<tag>" one should call "size_by_tag<tag>"
>
> What do you think?
>
Finally I've found a way to make the new version of size back compatible.
Real credits go to Daniel & Stefan, two guys that suggested to me the way to go.
For more info see:
http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/bd5080b28865f826
In the Trac ticket you can find the new patch (ignore the one
previously submitted).
Summary of changes:
* Use of ublas type-traits system (e.g. typename matrix_traits<M>::size_type).
* Explicit use of matrix_/vector_expression in function arguments
(e.g. size(matrix_expression<M> const& m).
* Call to size<1>(v), with v a vector expression, is legal and returns
the length of the vector-
Do you like it?'
Thank you very much!!
Best,
-- Marco