Boost logo

Ublas :

Subject: Re: [ublas] I have a problem with expression templates
From: Oswin Krause (Oswin.Krause_at_[hidden])
Date: 2012-09-26 13:59:53


Hi,

it is a bad idea to nest calls to prod(), so ublas prevents it. Your
workaround with the intermediate result is fine.

Also, try ublas::prod(trans(A), ublas::prod<ublas::matrix<double> >(B,
A))

On 2012-09-26 19:17, George Slavov wrote:
> I am using MSVC 2010 and trying to compile the following code
>
> ublas::prod(trans(A), ublas::prod(B, A));
>
> where A and B are matrices of the basic type ublas::matrix<double>.
> So
> the product should equal A^T B A. However, I get a compile error on
> the static assert line of the following
>
> // Dispatcher
> 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
> prod (const matrix_expression<E1> &e1,
>         const matrix_expression<E2> &e2) {
>     BOOST_STATIC_ASSERT (E1::complexity == 0 && E2::complexity ==
> 0);
>     typedef typename matrix_matrix_binary_traits<typename
> E1::value_type, E1,
>        typename E2::value_type, E2>::storage_category
> storage_category;
>     typedef typename matrix_matrix_binary_traits<typename
> E1::value_type, E1,
>        typename E2::value_type, E2>::orientation_category
> orientation_category;
>     return prod (e1, e2, storage_category (), orientation_category
> ());
> }
>
> If I compute a temporary result, then I get no problems. Like so:
>
> ublas::matrix<double> temp = ublas::prod(B,A);
> ublas::prod(trans(A), temp);
>
> I also tried a case where the expression template won't involve
> transposes and I got the same problem. What am I doing wrong?
>
> Regards,
> George