Boost logo

Ublas :

Subject: Re: [ublas] indirect_array cast
From: Philipp Kraus (philipp.kraus_at_[hidden])
Date: 2011-03-13 18:25:43

On 2011-03-13 10:03:40 +0100, Kraus Philipp said:

> I'm using an indirect_array< std::vector<std::size_t> > for creating a
> sorted index of a ublas::vector. How can I convert the indirect_array<
> std::vector<std::size> > to an indirect_array<> ? A have tried a
> static_cast or using the copy-constructor, but that doesn't work. Can
> I convert the array without std::copy?

My Code at this time (p_vec is an ublas::vector and lam is a shotcut
for the boost::lambda namespace with a sorting structure):

        std::sort( l_temp.begin(), l_temp.end(),
lam::var(p_vec)[lam::_1] < lam::var(p_vec)[lam::_2]);
        // here I would like to convert the l_temp vector to an
indirect:array<>, the code works, but it's not nice
        ublas::indirect_array<> l_idx(p_vec.size());
        for(std::size_t i=0; i < p_vec.size(); ++i)
            l_idx(i) = l_temp[i];

        I do it at the moment with
        ublas::indirect_array< std::vector<std::size_t> >(p_vec.size(),

        but I need the indirect_array<> and I have tried the
   std::copy( l_temp.begin(), l_temp.end(), l_idx.begin() );
       and get the error "assignment of read-only location"