|
Ublas : |
Subject: [ublas] vector * vector ambiguity causes compilation error
From: Mark Johnson (mj1_at_[hidden])
Date: 2009-08-05 10:52:04
I'm trying to use the * operator on a pair of vectors, but it seems the
vector * scalar and scalar * vector version of the operators also
match. Can anyone recommend a fix or a work-around? I'm using the
version of Boost that comes pre-installed on Fedora 11, which I think is
1.37.
Thanks in advance for your help,
Mark
Example:
#include <iostream>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_expression.hpp>
int main(int argc, char** argv) {
boost::numeric::ublas::scalar_vector<double> v(2, 2);
std::cout << "v = " << v*v << std::endl;
}
when compiled produces
g++ utmp.cc
utmp.cc: In function 'int main(int, char**)':
utmp.cc:8: error: ambiguous overload for 'operator*' in 'v * v'
/usr/include/boost/numeric/ublas/vector_expression.hpp:1399: note:
candidates are: typename
boost::numeric::ublas::vector_binary_scalar2_traits<E1, const T2,
boost::numeric::ublas::scalar_multiplies<typename E1::value_type,
T2> >::result_type boost::numeric::ublas::operator*(const
boost::numeric::ublas::vector_expression<E>&, const T2&) [with E1 =
boost::numeric::ublas::vector<double,
boost::numeric::ublas::unbounded_array<double,
std::allocator<double> > >, T2 =
boost::numeric::ublas::vector<double,
boost::numeric::ublas::unbounded_array<double,
std::allocator<double> > >]
/usr/include/boost/numeric/ublas/vector_expression.hpp:1174:
note: typename
boost::numeric::ublas::vector_binary_scalar1_traits<const T1, E2,
boost::numeric::ublas::scalar_multiplies<T1, typename
E2::value_type> >::result_type
boost::numeric::ublas::operator*(const T1&, const
boost::numeric::ublas::vector_expression<E2>&) [with T1 =
boost::numeric::ublas::vector<double,
boost::numeric::ublas::unbounded_array<double,
std::allocator<double> > >, E2 =
boost::numeric::ublas::vector<double,
boost::numeric::ublas::unbounded_array<double,
std::allocator<double> > >]