|
Ublas : |
Subject: Re: [ublas] [feature request] new free functions for matrix/vector sizes
From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2010-06-20 16:31:19
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 ;) )
In the attachment you can find my current implementation.
However it does not work!! :(
--- [error] ---
g++ -Wall -Wextra -pedantic -ansi -I. -I/home/marco/Sys/usr/include
-c -o libs/numeric/ublas/test/size.o libs/numeric/ublas/test/size.cpp
In file included from
/home/marco/Sys/usr/include/boost/numeric/ublas/storage.hpp:26,
from
/home/marco/Sys/usr/include/boost/numeric/ublas/vector.hpp:16,
from
/home/marco/Sys/usr/include/boost/numeric/ublas/matrix.hpp:16,
from libs/numeric/ublas/test/size.cpp:4:
/home/marcoSys/usr/include/boost/numeric/ublas/traits.hpp: In
instantiation of
boost::numeric::ublas::container_view_traits<boost::numeric::ublas::tag::major>:
/home/marco/Sys/usr/include/boost/numeric/ublas/traits.hpp:692:
instantiated from
boost::numeric::ublas::vector_view_traits<boost::numeric::ublas::tag::major>
/home/marco/Sys/usr/include/boost/numeric/ublas/traits.hpp:736:
instantiated from
boost::numeric::ublas::vector_traits<boost::numeric::ublas::tag::major>
libs/numeric/ublas/test/size.cpp:130: instantiated from here
...
--- [/error] ---
You can test by yourself by just compiling the file
"libs/numeric/ublas/test/size.cpp" you find in the boost tree.
In particular, what is currently offending the compiler is the version
of "size" parameterized by the tag dimension TagT:
template <typename TagT, typename MatrixExprT>
typename matrix_traits<MatrixExprT>::size_type size(...) { ... }
since when I call it, for instance as "size<tag::major>(m)", the
compiler "maps" the "tag::major" argument to the "MatrixExprT" type
instead of the "TagT" type.
I've tried several ways, but with no success.
I'm going to give up, but before I try to ask for help to the list.
So, do you any idea for solving it?
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.
Thank you very for any help!!
Best,
-- Marco