From: jhrwalter (walter_at_[hidden])
Date: 2002-03-14 05:19:20


--- In boost_at_y..., "rwgk" <rwgk_at_y...> wrote:
> --- In boost_at_y..., "jhrwalter" <walter_at_g...> wrote:
> > You seem to need element-wise multiplication. We currently do not
> > support this in ublas.
>
> Oh, sorry for being so stubborn about operator*. I should
> have figured that one out ...
>
> The latest cvs snapshot works great with gcc 3.0.4.
> For the EDG240 based Compaq cxx compiler I added
> a new #ifdef __EDG__ block in config.h which is
 
That's the correct strategy.

> identical to the USE_GCC block, but with "__restrict__"

Ok, even if NUMERICS_RESTRICT shouldn't be referenced anywhere,
currently.
 
> removed. The new code + error message is attached.
> Could you please advise?
> Thanks,
> Ralf
>
> #include <vector>
> #include <boost/numeric/ublas/config.h>
> #include <boost/numeric/ublas/vector.h>
>
> int main()
> {
> numerics::vector<float, std::vector<float> > ua(1000);
> numerics::vector<float, std::vector<float> > ub(1000);
> numerics::vector<float, std::vector<float> > uc(1000);
> uc = ua + ub;
> return 0;
> }
>
> cxx -I"/net/cci/rwgk/boost"/boost/compatibility/cpp_c_headers -std
> strict_ansi -msg_display_number -msg_disable 186,450,1115 -O2 -
> I"/net/cci/rwgk/boost" -c ublas_shared.cpp
> cxx: Error: /net/cci/rwgk/boost/boost/numeric/ublas/vector.h, line
> 430: #461
> initial value of reference to non-const must be an lvalue
> detected during instantiation of "numerics::vector<T, A>
> &numerics::vector<T, A>::operator=(const
> numerics::vector_expression<E> &) [with T=float,
> A=std::vector<float, std::allocator<float>>,
> AE=numerics::vector<numerics::scalar_plus<float,
> float>::result_type,
>
> numerics::unbounded_array<numerics::scalar_plus<float,
> float>::result_type>>]" at line 10
> of "ublas_shared.cpp"
> return assign_temporary (self_type (ae));
> -------------------------------------^
> cxx: Info: 1 error detected in the compilation
of "ublas_shared.cpp".
 
The referenced code is
template<class AE>
NUMERICS_INLINE
vector &operator = (const vector_expression<AE> &ae) {
#ifndef USE_GCC
    return assign_temporary (self_type (ae));
#else
    return assign (self_type (ae));
#endif
}

It looks, as if cxx wouldn't accept the original code in the same way
as gcc did, so the workaround could be to extend the preprocessor
conditional (BTW, similar constructions occur often).

If I interprete the compiler diagnostic correctly, cxx (and gcc) are
standard conforming w.r.t. this issue, but: three other compilers
(icc, bcc and msvc) accept the original code and the original code
should usually be faster.
 
Regards
 
Joerg