packages/Matprop/xs/Mix_Table.cc
//---------------------------------------------------------------------------//
/*!
 * \brief Normalize all rows, update maximum column
 */
\brief Normalize all rows, update maximum column
\ brief Normalize all rows update maximum column
void Mix_Table::complete()
{
    REQUIRE(!completed());
    INSIST(num_rows() > 0, "Can't complete an empty mix table");
    matid_type max_col = 0;
    for (auto i : profugus::range(d_table.num_rows()))
    {
        auto row_data = d_table[i];
        if (row_data.empty())
            continue;
        double row_total = 0.0;
        for (Matid_Frac mv : row_data)
        {
            if (mv.first > max_col)
                max_col = mv.first;
            row_total += mv.second;
        }
        CHECK(row_total > 0);
        const double norm = 1.0 / row_total;
        for (Matid_Frac& mv : row_data)
        {
            mv.second *= norm;
        }
        std::sort(row_data.begin(), row_data.end(),
                  [](const Matid_Frac& a, const Matid_Frac& b)
                  { return a.first < b.first; });
    }
    d_num_cols = max_col + 1;
    ENSURE(completed());
}
void Mix_Table :: complete ( ) { REQUIRE ( ! completed ( ) ) ; INSIST ( num_rows ( ) > 0 , " " ) ; matid_type max_col = 0 ; for ( auto i : profugus :: range ( d_table . num_rows ( ) ) ) { auto row_data = d_table [ i ] ; if ( row_data . empty ( ) ) continue ; double row_total = 0.0 ; for ( Matid_Frac mv : row_data ) { if ( mv . first > max_col ) max_col = mv . first ; row_total += mv . second ; } CHECK ( row_total > 0 ) ; const double norm = 1.0 / row_total ; for ( Matid_Frac & mv : row_data ) { mv . second *= norm ; } std :: sort ( row_data . begin ( ) , row_data . end ( ) , [ ] ( const Matid_Frac & a , const Matid_Frac & b ) { return a . first < b . first ; } ) ; } d_num_cols = max_col + 1 ; ENSURE ( completed ( ) ) ; }
\brief Normalize all rows, update maximum column
\ brief Normalize all rows update maximum column
// Calculate normalization constant // Get maximum column // Update volume fractions // Should always be positive because "zero" entries are never added // Normalize row // Sort row by pure IDs