packages/Matprop/xs/Mix_Table.cc
//---------------------------------------------------------------------------//
// METHODS
//---------------------------------------------------------------------------//
/*!
 * \brief Build from sparse coordinates
 */
METHODS
\brief Build from sparse coordinates
METHODS \ brief Build from sparse coordinates
Mix_Table Mix_Table::from_coo(const_View_Mat  row_ids,
                              const_View_Mat  col_ids,
                              const_View_Frac values)
{
    VALIDATE(row_ids.size() == values.size(),
             "Row size " << row_ids.size() << " does not match value "
             "size " << values.size());
    VALIDATE(row_ids.size() == col_ids.size(),
             "Row size " << row_ids.size() << " does not match cols "
             "size " << col_ids.size());
    Mix_Table table;
    if (!values.empty())
        table.start_row();
    matid_type row_index = 0;
    auto r = row_ids.begin();
    auto c = col_ids.begin();
    auto v = values.begin();
    for (auto end_r = row_ids.end(); r != end_r; ++r, ++c, ++v)
    {
        while (*r > row_index)
        {
            table.start_row();
            ++row_index;
        }
        table.extend_row(*c, *v);
    }
    table.complete();
    return std::move(table);
}
Mix_Table Mix_Table :: from_coo ( const_View_Mat row_ids , const_View_Mat col_ids , const_View_Frac values ) { VALIDATE ( row_ids . size ( ) == values . size ( ) , " " << row_ids . size ( ) << " " " " << values . size ( ) ) ; VALIDATE ( row_ids . size ( ) == col_ids . size ( ) , " " << row_ids . size ( ) << " " " " << col_ids . size ( ) ) ; Mix_Table table ; if ( ! values . empty ( ) ) table . start_row ( ) ; matid_type row_index = 0 ; auto r = row_ids . begin ( ) ; auto c = col_ids . begin ( ) ; auto v = values . begin ( ) ; for ( auto end_r = row_ids . end ( ) ; r != end_r ; ++ r , ++ c , ++ v ) { while ( * r > row_index ) { table . start_row ( ) ; ++ row_index ; } table . extend_row ( * c , * v ) ; } table . complete ( ) ; return std :: move ( table ) ; }
METHODS
 \brief Build from sparse coordinates
METHODS \ brief Build from sparse coordinates
// Start the first row if not empty