Boost logo

Ublas :

From: wangxiaoyi (wangxiaoyi00_at_[hidden])
Date: 2006-10-16 19:08:07

function same_impl_ex() is just one issue. Actually I have given a specialization as
yours and it compile successfully. However, ublas use size_t(-1) as a special value for
checking the index value, which will cause a assertion fail at run time. There seems no graceful way to solve this problem.

Gunter Winkler wrote:
> On Saturday 14 October 2006 10:07, wangxiaoyi wrote:
>> The uBLAS uses *size_t* to for index values. However, I have use int as
>> the index values in some cases. For example, I have to use int indexed
>> sparse matrix when binding ublas matrix to superLU package. Using int as
>> index value may fail to compile in debug configuration, i.e. no NDEBUG
>> defined. The compiler reports that:
>> NO function could match same_impl_ex(int, size_t). Actually in
>> exception.hpp:276, same_impl_ex is just defined for the argument type,
>> expected to be (size_t, size_t).
>> Is there really a way to use int as index value in current released ublas?
> The use of int instead of size_t is not fully working, but it should work with
> most expression. Only mixing of index types makes lots of trouble. It looks
> like you operated on two different types of vectors/matrices. If you need
> (int) as index type you always have to use the full type declaration
> vector<double, A> where A is an allocator type, that defines the size_type as
> (int).
> This is quite nasty and may still be fail on some expressions.
> A workaround is to give a specialization of same_impl_ex (untested)
> template<class T>
> size_t same_impl_ex (const size_t &size1, const int &size2,
> const char *file, int line) {
> BOOST_UBLAS_CHECK_EX (size1 == size2, file, line, bad_argument ());
> // WARNING: this fails if size2 is negative!
> return (size1<size2?(size_t)size1:(size_t)size2);
> }
> mfg
> Gunter
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]