Re: Preserving values when resizing c_matrices.
Joaquim Duran <[email protected]>
| Newsgroups | gmane.comp.lib.boost.ublas |
|---|---|
| Message-ID | <CANdawSFrmyeviyhL9dGaHme17GSxzRF-uzGg__orZnVBRtJrzQ@mail.gmail.com> |
At which branch can I pull a change? It is needed to open a boost ticket? Joaquim Duran 2013/10/1 Joaquim Duran <[email protected]> > Dear all, > > Maybe, I don't see the full image of c_matrix, but IMO, when resizing the > c_matrix, it is not needed copy values to preserve them. > > The code of the resize member function of c_matrix: > > >> BOOST_UBLAS_INLINE > > void resize (size_type size1, size_type size2, bool preserve = true) { > > if (size1 > N || size2 > M) > > bad_size ().raise (); > > if (preserve) { > > self_type temporary (size1, size2); > > // Common elements to preserve > > const size_type size1_min = (std::min) (size1, size1_); > > const size_type size2_min = (std::min) (size2, size2_); > > for (size_type i = 0; i != size1_min; ++i) { // indexing copy over major > > for (size_type j = 0; j != size2_min; ++j) { > > temporary.data_[i][j] = data_[i][j]; > > } > > } > > assign_temporary (temporary); > > } > > else { > > size1_ = size1; > > size2_ = size2; > > } > > >> [...] > > >> private: >> > size_type size1_; >> > size_type size2_; >> > value_type data_ [N] [M]; > > >> > Thanks and Best Regards, > Joaquim Duran > >