Skip to content

Instantly share code, notes, and snippets.

@martani
Last active December 17, 2015 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martani/5684252 to your computer and use it in GitHub Desktop.
Save martani/5684252 to your computer and use it in GitHub Desktop.
//Append this function to class Indexer.
template <typename Matrix>
void spliceToAB(Matrix& M, Matrix& A, Matrix& B)
{
typename Matrix::Row::const_iterator it;
// Splice M into two submatrices A and B, A contains pivot columns, B contains non pivot colums.
uint32 curr_piv = 0;
typename Matrix::RowIterator i_B;
for(i_B = M.rowBegin (); i_B != M.rowEnd (); ++i_B)
{
for(it = i_B->begin (); it != i_B->end (); ++it) {
if(pivot_columns_map[it->first] != MINUS_ONE)
{
A[curr_piv].push_back (typename Matrix::Row::value_type(pivot_columns_map[it->first], it->second));
}
else
{
B[curr_piv].push_back (typename Matrix::Row::value_type(non_pivot_columns_map[it->first], it->second));
}
}
++curr_piv;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment