Hello !


I'd like to extend ublas, i.e. I want to create a new Twist class, and overload some of the standard operation like addition, inner_prod, ...

I've define the new class as follow :

class twist : public vector<double, ublas::bounded_array<double,3> >
{
    typedef vector<double, bounded_array<double,3> > Base_vector;
    public:
    // Default construction
    twist () : Base_vector(3)
    {}
    // Construction and assignment from a uBLAS vector expression or copy assignment
    template <class R> twist (const vector_expression<R>& r) : Base_vector(r)
    {}
    template <class R> void operator=(const vector_expression<R>& r)
    {
        Base_vector::operator=(r);
    }
    template <class R> void operator=(const Base_vector& r)
    {
        Base_vector::operator=(r);
    }
};

And I've overloaded the sum specializing the following templated function :

template<>
BOOST_UBLAS_INLINE
vector_binary_traits<twist,
                    twist,
                    scalar_plus<double,double> >::result_type
operator + (const vector_expression<twist > &e1,
        const vector_expression<twist > &e2)
{
    typedef vector_binary_traits<twist, twist, scalar_plus<double,double> >::expression_type expression_type;
    std::cout << "twist sum !!!!" << std::endl;
    return expression_type (e1(), e2());
}



And I get the following error (using gcc-4.2):

../../../boost/numeric/ublas/
expression_types.hpp: In member function ‘const E& boost::numeric::ublas::vector_expression<E>::operator()() const [with E = boost::numeric::ublas::twist]’:
twist.cpp:37:   instantiated from here
../../../boost/numeric/ublas/expression_types.hpp:184: error: invalid static_cast from type ‘const boost::numeric::ublas::vector_expression<boost::numeric::ublas::twist>* const’ to type ‘const boost::numeric::ublas::twist*’

Do you have any idea of where is my mistake ?

Thanks,

kayhman

P.S. : a small example is enclosed.