|
Ublas : |
Subject: [ublas] vector matrix binaries
From: Matwey V. Kornilov (matwey.kornilov_at_[hidden])
Date: 2012-03-28 05:32:19
Hi,
I am trying to implement outer plus ((v(+)u)_ij = v_i + u_j) operation
looking at outer_prod:
template<class E1, class E2> BOOST_UBLAS_INLINE
typename vector_matrix_binary_traits<E1, E2, scalar_plus<typename
E1::value_type, typename E2::value_type> >::result_type
outer_plus (const vector_expression<E1> &e1, const vector_expression<E2>
&e2) {
BOOST_STATIC_ASSERT (E1::complexity == 0 && E2::complexity == 0);
typedef typename vector_matrix_binary_traits<E1, E2,
scalar_plus<typename E1::value_type, typename E2::value_type>
>::expression_type expression_type;
return expression_type (e1 (), e2 ());
}
But this code doesn't work:
vector<double> r(4);
//...
symmetric_matrix<double> s = outer_plus(r,r);
I get:
Check failed in file
/usr/include/boost/numeric/ublas/detail/matrix_assign.hpp at line 763:
detail::expression_type_check (m, cm)
terminate called after throwing an instance of
'boost::numeric::ublas::external_logic'
what(): external logic
Same assignment with outer_prod(r,r) operator works pretty good, but I can't
figure out what I do wrong. It seems I need a little help here :)