|
Boost Users : |
From: jhr.walter_at_[hidden]
Date: 2003-05-12 02:07:12
Hi Zhang,
you wrote:
> the following code generates a compile error raising from
> a macro in /ublas/traits.hpp:
> BOOST_STATIC_ASSERT ((boost::is_same<T1, T2>::value));
>
> Because I'm trying to prod on a vector of size_t and a matrix of
unsigned
> char.
>
> Because I want to save memory (the matrix is really huge) and I
> know the value in m will never exceed 255. The expression is ok to
> me (of course the result value is size_t).
> But the ASSERT prevent me from doing this.
>
> Is there a workaround that permits me doing this kind of case without
> sacrificing the memory efficiency?
I'd try to add specializations of the form
template<>
struct promote_traits<std::size_t, unsigned char> {
typedef std::size_t promote_type;
};
template<>
struct promote_traits<unsigned char, std::size_t> {
typedef std::size_t promote_type;
};
to the namespace boost::numeric::ublas. If there's enough interest we'll
probaby have to extend promote_traits systematically one day.
> Using size_t in the matrix will
> use three times more memory.
Looks like you're working on an interesting problem :-)
> ublas::vector<size_t> v1(5);
> matrix<unsigned char> m(5,5);
> prod(m,v1);
>
> the same problem arises when I do
> prod(m,v2); here v2 is a vector<double>
The same solution should apply here.
HTH,
Joerg
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net