packages/Matprop/xs/Mix_Table.cc
//---------------------------------------------------------------------------//
/*!
 * \brief Access a particular row/column value.
 *
 * If called before "completed", either row or column can be outside the mix
 * table, and we return zero rather than raising an
 * error. Additionally the fractions will be unnormalized.
 *
 * If called after completed, we require both mixed and pure to be within the
 * bounds of the mix table.
 */
\brief Access a particular row/column value.
If called before "completed", either row or column can be outside the mix
table, and we return zero rather than raising an
error. Additionally the fractions will be unnormalized.

If called after completed, we require both mixed and pure to be within the
bounds of the mix table.
\ brief Access a particular row / column value . If called before " completed " either row or column can be outside the mix table and we return zero rather than raising an error . Additionally the fractions will be unnormalized . If called after completed we require both mixed and pure to be within the bounds of the mix table .
Mix_Table::value_type Mix_Table::find_fraction(
        matid_type mixed_id,
        matid_type pure_id) const
{
    REQUIRE(mixed_id >= 0);
    REQUIRE(pure_id >= 0);
    if (completed())
    {
        REQUIRE(mixed_id < num_rows());
        REQUIRE(pure_id  < num_cols());
        auto row_view = row(mixed_id);
        auto iter = std::lower_bound(row_view.begin(), row_view.end(), pure_id,
                                     [](const Matid_Frac &mf, matid_type m)
                                     { return mf.first < m; });
        if (iter != row_view.end() && iter->first == pure_id)
        {
            ENSURE(iter->second >= 0);
            return iter->second;
        }
    }
    else if (mixed_id < num_rows())
    {
        auto row_view = row(mixed_id);
        auto iter = std::find_if(row_view.begin(), row_view.end(),
                                 [pure_id](const Matid_Frac &mf)
                                 { return mf.first == pure_id; });
        if (iter != row_view.end())
        {
            ENSURE(iter->second >= 0);
            return iter->second;
        }
    }
    return 0;
}
Mix_Table :: value_type Mix_Table :: find_fraction ( matid_type mixed_id , matid_type pure_id ) const { REQUIRE ( mixed_id >= 0 ) ; REQUIRE ( pure_id >= 0 ) ; if ( completed ( ) ) { REQUIRE ( mixed_id < num_rows ( ) ) ; REQUIRE ( pure_id < num_cols ( ) ) ; auto row_view = row ( mixed_id ) ; auto iter = std :: lower_bound ( row_view . begin ( ) , row_view . end ( ) , pure_id , [ ] ( const Matid_Frac & mf , matid_type m ) { return mf . first < m ; } ) ; if ( iter != row_view . end ( ) && iter -> first == pure_id ) { ENSURE ( iter -> second >= 0 ) ; return iter -> second ; } } else if ( mixed_id < num_rows ( ) ) { auto row_view = row ( mixed_id ) ; auto iter = std :: find_if ( row_view . begin ( ) , row_view . end ( ) , [ pure_id ] ( const Matid_Frac & mf ) { return mf . first == pure_id ; } ) ; if ( iter != row_view . end ( ) ) { ENSURE ( iter -> second >= 0 ) ; return iter -> second ; } } return 0 ; }
\brief Access a particular row/column value.
\ brief Access a particular row / column value .
// Find sorted pure ID in the row // Find unsorted pure ID in the unnormalized row // Not found