Boost logo

Ublas :

From: Chris Bevan (chris_at_[hidden])
Date: 2008-02-26 11:46:21


Hi all,

We recently encountered an error compiling uBLAS on Windows with a
combination of the Intel compiler v9.1 and the libraries and headers
from Visual Studio 2005 SP1. I've seen this error reported by others
but didn't find a response, so thought I'd post my findings here.

Firstly, I'm not sure whether this is more of an issue with uBLAS,
the Intel compiler, or VS2005 SP1, as any other combination seems
completely fine. As uBLAS is the only thing I could practically
change, I've modified the appropriate files - vector.hpp and
matrix.hpp - to get around the error.

Have a look at this example programme:
#include <boost/numeric/ublas/vector.hpp>

typedef boost::numeric::ublas::c_vector<int, 2> Vec;

void VecFn(const Vec& a)
{
   Vec b(a);
}
It produces the following error when compiled with the configuration
mentioned above:
boost/numeric/ublas/vector.hpp(1302): error: more than one instance
of overloaded function "std::copy" matches the argument list:
             function template "_OutElem *__cdecl std::copy(_InIt,
_InIt, _OutElem (&)[_Size])"
             function template "std::_Enable_if<<expression>,
_OutIt>::_Result __cdecl std::copy(_InIt, _InIt, _OutIt)"
             argument types are: (const
boost::numeric::ublas::c_vector<int, 2U>::array_type, const
boost::numeric::ublas::c_vector<int, 2U>::value_type *,
boost::numeric::ublas::c_vector<int, 2U>::array_type)
               std::copy (v.data_, v.data_ + v.size_, data_);
               ^
           detected during:
             instantiation of "boost::numeric::ublas::c_vector<T, N>
&boost::numeric::ublas::c_vector<T, N>::operator=(const
boost::numeric::ublas::c_vector<T, N> &) [with T=int, N=2U]" at line
1216
             instantiation of "boost::numeric::ublas::c_vector<T,
N>::c_vector(const boost::numeric::ublas::c_vector<T, N> &) [with
T=int, N=2U]"
The ambiguity between an array reference or a pointer to the first
element of the array is causing problems here. I've attached a
unified diff that fixes the problem for me. It's a simple change,
but not a particularly elegant one, as I haven't really worked with
the library myself otherwise. The error comes up in a few other
places depending on which methods are used, and no doubt there are
more that I haven't looked into.

Maybe someone else more experienced with the code could suggest a
better solution, but anyway I thought it might help to post the issue
in case someone else experiences something similar.

Cheers,

- Chris Bevan