Boost logo

Ublas :

From: Jon Pearce (j.pearce_at_[hidden])
Date: 2005-03-29 04:48:58

Dear All,

I would be most grateful if someone might be able to shed some light on
why the first line of matrix::operator= is commented in the UBlas
distributed with Boost 1.32

195 template<class AE>
 197 matrix &operator = (const matrix_expression<AE> &ae) {
 198 // return assign (self_type (ae));
 199 self_type temporary (ae);
 200 return assign_temporary (temporary);
 201 }

The current implementation appears to result in incorrect behaviour when
used with shallow_array_adaptor<T> since the storage member is not
available for a shallow copy in matrix::matrix(matrix_expression):

 109 template<class AE>
 111 matrix (const matrix_expression<AE> &ae):
 112 matrix_expression<self_type> (),
 113 size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_
(functor_type::storage_size (size1_, size2_)) {
 114 matrix_assign (scalar_assign<reference,
BOOST_UBLAS_TYPENAME AE::value_type> (), *this, ae);
 115 }

For example, an expression like

    shallow_array_adaptor<double> my_storage(m, n, ptr_to_legacy_array);
        column_major, shallow_array_adaptor<double> > a(...), b(...),
c(m, n, my_storage);
     c = prod(a, b);

does not modify the contents at ptr_to_legacy_array.

Is it OK to go ahead and uncomment that first line of operator= (which
appears to do the trick), or is there another work-around that should be

Many thanks in advance for any insights you may have.

Yours sincerely

Jon Pearce