|
Ublas : |
Subject: Re: [ublas] Initial submission plan?
From: Patrick Lacasse (patrick.m.lacasse_at_[hidden])
Date: 2009-02-12 16:03:57
2009/2/12 Patrick Lacasse <patrick.m.lacasse_at_[hidden]>
> Hi all,
> I'm new with ublas and I also consider that lack of operator* for
> matrix-matrix is a real turn-off for newbies, specialy when reading the
> compilator errors.
> This can be issued by appropriate use of boost::disable_if .
> The problem comes from the two operator *
> scalar * matrix
> matrix * scalar
> that are both defined for
> matrix_expression * matrix_expression
> Also they are badly defined for this case.
> But if you disabled them by changing the returned type to
>
> typename
> boost::disable_if<boost::is_base_of<matrix_expression<T1>,T1>,
> typename matrix_binary_scalar1_traits<const T1, E2, scalar_multiplies<T1,
> typename E2::value_type> >::result_type
> >::type
>
> and
>
> typename
> boost::disable_if<boost::is_base_of<matrix_expression<T2>,T2>,
> typename matrix_binary_scalar2_traits<E1, const T2,
> scalar_multiplies<typename E1::value_type, T2> >::result_type >::type
>
> one can now add a matrix-matrix operator*
>
> template<class E1, class
> E2>
> BOOST_UBLAS_INLINE
> typename matrix_matrix_binary_traits<typename E1::value_type, E1, typename
> E2::value_type,
> E2>::result_type
>
> operator* (const matrix_expression<E1>
> &e1, const
> matrix_expression<E2> &e2) {
> return prod(e1,e2);
> }
>
> Of course there is many other operator* to define for matrix-vector, etc
> cases and scalar operator * must also be disabled for vector_expression.
>
> I join a minimalist test program and my modified version of operator* (only
> matrix-matrix case) to this post.
>
> I really think matrix-matrix operator * should be implemented.
>
> Patrick Lacasse
>
>
>
> 2009/2/12 Jesse Perla <jesseperla_at_[hidden]>
>
>>
>> And one more question on ublas itself: I have seen a lot of people ask
>> this, but I got a lot of flack for the lack of the * overloading for
>> matrix-matrix and matrix-vector from the matlab programmers. Could these be
>> added without too much difficulty?
>>
>> _______________________________________________
>> ublas mailing list
>> ublas_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/ublas
>>
>>
>