void create_random_indices( IndexContainer &idx , size_t N , size_t n )
{
    idx.resize( N );
    for( size_t i = 0 ; i < N ; ++i ) idx[i];
    std::random_shuffle( idx.begin() , idx.end() );
    idx.resize( n );
}
 /// @warning all elements are destroyed
 void resize(size_type nrows, size_type ncols, T const& val)
 {
   m_data.resize(nrows*ncols, val);
   m_offsets.resize(nrows+1);
   for (size_type i = 0; i < nrows+1; ++i)
   {
     m_offsets[i] = i*ncols;
   }
 }
Beispiel #3
0
typename IndexContainer::iterator sort_indices( const Container &v , IndexContainer &idx )
{
    idx.resize( v.size() );
    for( size_t i = 0 ; i != idx.size() ; ++i ) idx[i] = i;

    auto iter = std::partition( idx.begin() , idx.end() ,
                                [&v]( size_t i ) { return std::isfinite( v[i] ); } );
    std::sort( idx.begin() , iter , [&v]( size_t i1 , size_t i2 ) { return ( v[i1] < v[i2] ); } );
    return iter;
}
 /// @warning all elements are destroyed
 void resize(size_type nrows)
 {
   m_data.clear();
   //m_data.reserve(1); // this is ti define m_data.begin()
   m_offsets.resize(nrows+1, Int(0));
 }