Boost logo

Boost :

From: Kresimir Fresl (fresl_at_[hidden])
Date: 2002-03-10 05:50:50

rwgk wrote:


> Unfortunately I am having trouble compiling this minimal
> example:
> #include <vector>
> #include <boost/numeric/ublas/config.h>
> #include <boost/numeric/ublas/vector.h>
> int main()
> {
> numerics::vector<float, std::vector<float> > ua(1000);
> ua = ua * ua;
> return 0;
> }
> Attached are the minimal patches that I applied to config.h
> and iterator.h, and the output from two compilers.
> Advice on how to fix the problems is very much appreciated.


> gcc 3.0.4 (RedHat 7.1):
> g++ -fPIC -ftemplate-depth-50 -DUSE_GCC -g -
> I"/net/cci/rwgk/boost" -c ublas_shared.cpp
> ublas_shared.cpp: In function `int main()':
> ublas_shared.cpp:8: ambiguous overload for `numerics::vector<float,
> std::vector<float, std::allocator<float> > >& *
> numerics::vector<float,
> std::vector<float, std::allocator<float> > >&' operator


It seems that error messages are misleading. There is
no ambiguity in your example. Rather, in ublas there is no

     operator* (vector<> const&, vector<> const&)

or, more precisely,

     operator* (vector_expression<> const&,
                       vector_expression<> const&)

My guess is that authors decided not to provide this operator
because it is not clear whether it denotes inner product
or elementwise multiplication.

`operator*()' can only be used to multiply vectors (and matrices)
with scalars. (So, you can change the test operation to
`ua = 2. * ua;'. Or, you can use `+' or `-'.)

To compute inner product you must use function `inner_prod()'.

As far as I know, there is currently no way to do elementwise
multiplication. Strictly speaking, this is not linear algebra operation,
but I hope that authors will in some future version add some means
to do this and similar array operations (eg. apply some function to
all elements in a vector).



Boost list run by bdawes at, gregod at, cpdaniel at, john at