Skip to content
Snippets Groups Projects
Commit 8dadad00 authored by Steffen Müthing's avatar Steffen Müthing
Browse files

[Release][BCRSMatrix] Improve readability of new method setIndices()

- Use std::copy instead of homegrown copy loop
- Avoid custom counting logic for consistency check
parent 04a42801
No related branches found
No related tags found
No related merge requests found
......@@ -1194,17 +1194,15 @@ namespace Dune {
template<typename It>
void setIndices(size_type row, It begin, It end)
{
size_type cols = 0;
size_type* col_it = r[row].getindexptr();
for (; begin != end; ++begin, ++col_it, ++cols)
{
*col_it = *begin;
}
if (cols != r[row].size())
size_type row_size = r[row].size();
size_type* col_begin = r[row].getindexptr();
size_type* col_end;
// consistency check between allocated row size and number of passed column indices
if ((col_end = std::copy(begin,end,r[row].getindexptr())) != col_begin + row_size)
DUNE_THROW(BCRSMatrixError,"Given size of row " << row
<< " (" << r[row].size()
<< ") does not match number of passed entries (" << cols << ")");
std::sort(r[row].getindexptr(),r[row].getindexptr() + cols);
<< " (" << row_size
<< ") does not match number of passed entries (" << (col_end - col_begin) << ")");
std::sort(col_begin,col_end);
}
//! indicate that all indices are defined, check consistency
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment