$include_dir="/home/hyper-archives/ublas/include"; include("$include_dir/msg-header.inc") ?>
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
[ublas/matrix.hpp]
195         template<class AE>
 196         BOOST_UBLAS_INLINE
 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):
[ublas/matrix.hpp]
 109         template<class AE>
 110         BOOST_UBLAS_INLINE
 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);
     matrix<double,
        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 
preferred?
Many thanks in advance for any insights you may have.
Yours sincerely
Jon Pearce