Boost logo

Ublas :

From: Simon Perreault (nomis80_at_[hidden])
Date: 2006-06-01 10:28:34


Hi,

Why is there no element-wise division operator? I tried to write one myself
but it fails deep into traits stuff, which is way over my head. So I suppose
there is a good reason why no division operator is present in uBLAS.

Thanks

P.S. Here's my first try:

    /**
     * Element-wise division operator.
     */
    template<class E1, class E2>
    BOOST_UBLAS_INLINE
    typename vector_binary_traits<E1, E2,
            scalar_divides<typename E1::value_type,
                           typename E2::value_type> >::result_type
    operator / (const vector_expression<E1> &e1,
                const vector_expression<E2> &e2) {
        typedef typename vector_binary_traits<E1, E2,
            scalar_divides<typename E1::value_type,
                           typename E2::value_type> >::expression_type
                               expression_type;
        return expression_type (e1 (), e2 ());
    }