* <dt class="glossary">@anchor GlobalDoFIndexSparseMatrix
* <b>SparseMatrix</b></dt>
* <dd>
- * The size SparseMatrix can be arbitrary large therefore,
- * types::global_do_index is used.
+ * The size of SparseMatrix can be arbitrary large therefore,
+ * types::global_do_index is used. However, even for a large complex problem we
+ * can solve now, there is no reason for the number of non-zero entries in a
+ * sparse matrix to go over four billions. Thus, we still use unsigned int
+ * for, e.g., row_lengths in the object.
+ *
+ *
*/
void
BlockList::create_sparsity_pattern(SparsityPattern &sparsity, size_type n) const
{
- std::vector<size_type> sizes(size());
+ std::vector<unsigned int> sizes(size());
for (size_type b=0; b<size(); ++b)
sizes[b] = block_size(b);
*/
void reinit (const BlockIndices &row_indices,
const BlockIndices &col_indices,
- const std::vector<std::vector<size_type> > &row_lengths);
+ const std::vector<std::vector<unsigned int> > &row_lengths);
/**
* the @p index th entry in row @p row.
*/
size_type column_number (const size_type row,
- const size_type index) const;
+ const unsigned int index) const;
/**
* Allow the use of the reinit
inline
BlockCompressedSimpleSparsityPattern::size_type
BlockCompressedSimpleSparsityPattern::column_number (const size_type row,
- const size_type index) const
+ const unsigned int index) const
{
// .first= ith block, .second = jth row in that block
const std::pair<size_type ,size_type >
Assert(index<row_length(row), ExcIndexRange(index, 0, row_length(row)));
size_type c = 0;
- for (size_type b=0; b<columns; ++b)
+ for (unsigned int b=0; b<columns; ++b)
{
- size_type rowlen = sub_objects[row_index.first][b]->row_length (row_index.second);
+ unsigned int rowlen = sub_objects[row_index.first][b]->row_length (row_index.second);
if (index<c+rowlen)
return c+sub_objects[row_index.first][b]->column_number(row_index.second, index-c);
c += rowlen;
// create an array that caches some
// elements that are going to be written
// into the new matrix.
- size_type max_n_cols_B = 0;
+ unsigned int max_n_cols_B = 0;
for (size_type i=0; i<B.m(); ++i)
max_n_cols_B = std::max (max_n_cols_B, sp_B.row_length(i));
std::vector<numberC> new_entries(max_n_cols_B);
// create an array that caches some
// elements that are going to be written
// into the new matrix.
- size_type max_n_cols_B = 0;
+ unsigned int max_n_cols_B = 0;
for (size_type i=0; i<B.m(); ++i)
max_n_cols_B = std::max (max_n_cols_B, sp_B.row_length(i));
std::vector<numberC> new_entries(max_n_cols_B);
*/
SparsityPattern (const size_type m,
const size_type n,
- const size_type max_per_row,
+ const unsigned int max_per_row,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
*/
SparsityPattern (const size_type m,
const size_type n,
- const size_type max_per_row);
+ const unsigned int max_per_row);
/**
* Initialize a rectangular matrix.
*/
SparsityPattern (const size_type m,
const size_type n,
- const std::vector<size_type> &row_lengths,
+ const std::vector<unsigned int> &row_lengths,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
*/
SparsityPattern (const size_type m,
const size_type n,
- const std::vector<size_type> &row_lengths);
+ const std::vector<unsigned int> &row_lengths);
/**
* Initialize a quadratic matrix of dimension <tt>n</tt> with at most
* numbers separately.
*/
SparsityPattern (const size_type n,
- const size_type max_per_row);
+ const unsigned int max_per_row);
/**
* Initialize a quadratic matrix.
* it is ignored.
*/
SparsityPattern (const size_type m,
- const std::vector<size_type> &row_lengths,
+ const std::vector<unsigned int> &row_lengths,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
* vector must have one entry for each row.
*/
SparsityPattern (const size_type m,
- const std::vector<size_type> &row_lengths);
+ const std::vector<unsigned int> &row_lengths);
/**
* Make a copy with extra off-diagonals.
* compressed after this function finishes.
*/
SparsityPattern (const SparsityPattern &original,
- const size_type max_per_row,
+ const unsigned int max_per_row,
const size_type extra_off_diagonals);
/**
*/
void reinit (const size_type m,
const size_type n,
- const size_type max_per_row,
+ const unsigned int max_per_row,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
*/
void reinit (const size_type m,
const size_type n,
- const size_type max_per_row);
+ const unsigned int max_per_row);
/**
* Reallocate memory for a matrix of size <tt>m x n</tt>. The number of
*/
void reinit (const size_type m,
const size_type n,
- const std::vector<size_type> &row_lengths,
+ const std::vector<unsigned int> &row_lengths,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
*/
void reinit (const size_type m,
const size_type n,
- const std::vector<size_type> &row_lengths);
+ const std::vector<unsigned int> &row_lengths);
/**
* Same as above, but with a VectorSlice argument instead.
*/
void reinit (const size_type m,
const size_type n,
- const VectorSlice<const std::vector<size_type> > &row_lengths,
+ const VectorSlice<const std::vector<unsigned int> > &row_lengths,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
*/
void reinit (const size_type m,
const size_type n,
- const VectorSlice<const std::vector<size_type> > &row_lengths);
+ const VectorSlice<const std::vector<unsigned int> > &row_lengths);
/**
* This function compresses the sparsity structure that this object
/**
* Number of entries in a specific row.
*/
- size_type row_length (const size_type row) const;
+ unsigned int row_length (const size_type row) const;
/**
* Determine whether the matrix uses the special convention for quadratic
* <tt>column_number(row,i+1)</tt>.
*/
size_type column_number (const size_type row,
- const size_type index) const;
+ const unsigned int index) const;
// @}
* reinit versions are called. Its value is more or less meaningless after
* compress() has been called.
*/
- size_type max_row_length;
+ unsigned int max_row_length;
/**
* Array which hold for each row which is the first element in #colnums
inline
-SparsityPattern::size_type
+unsigned int
SparsityPattern::row_length (const size_type row) const
{
Assert(row<rows, ExcIndexRangeType<size_type>(row,0,rows));
inline
SparsityPattern::size_type
SparsityPattern::column_number (const size_type row,
- const size_type index) const
+ const unsigned int index) const
{
Assert(row<rows, ExcIndexRangeType<size_type>(row,0,rows));
- Assert(index<row_length(row), ExcIndexRangeType<size_type>(index,0,row_length(row)));
+ Assert(index<row_length(row), ExcIndexRange(index,0,row_length(row)));
return colnums[rowstart[row]+index];
}
// is not yet present. as we have to call compress anyway later on, don't
// bother to check whether that diagonal entry is in a certain row or not
const bool is_square = (n_rows == n_cols);
- std::vector<size_type> row_lengths;
+ std::vector<unsigned int> row_lengths;
row_lengths.reserve(n_rows);
for (ForwardIterator i=begin; i!=end; ++i)
row_lengths.push_back (std::distance (i->begin(), i->end())
task_info.n_blocks : size_info.n_active_cells;
// first determine row lengths
- std::vector<types::global_dof_index> row_lengths(n_rows);
+ std::vector<unsigned int> row_lengths(n_rows);
unsigned int cell_start = 0, mcell_start = 0;
std::vector<types::global_dof_index> scratch;
- for (types::global_dof_index block = 0; block < n_blocks; ++block)
+ for (unsigned int block = 0; block < n_blocks; ++block)
{
// if we have the blocking variant (used in the coloring scheme), we
// want to build a graph with the blocks with interaction with
numbers::invalid_unsigned_int);
// Estimate for the number of dofs at this point
- std::vector<types::global_dof_index> vertex_dof_count(dof_handler.get_tria().n_vertices(), 0);
+ std::vector<unsigned int> vertex_dof_count(dof_handler.get_tria().n_vertices(), 0);
// Identify all vertices active on this level and remember some data
// about them
BlockSparsityPattern::reinit(
const BlockIndices &rows,
const BlockIndices &cols,
- const std::vector<std::vector<size_type> > &row_lengths)
+ const std::vector<std::vector<unsigned int> > &row_lengths)
{
AssertDimension (row_lengths.size(), cols.size());
cols.block_size(j), row_lengths[j][0]);
else
{
- VectorSlice<const std::vector<size_type > >
+ VectorSlice<const std::vector<unsigned int> >
block_rows(row_lengths[j], start, length);
block(i,j).reinit(rows.block_size(i),
cols.block_size(j),
// row zero at columns {0,2} and for row
// one at {4,6} --> we'll need 4 chunks for
// the first chunk row!) :
- std::vector<size_type> chunk_row_lengths (m_chunks, 0);
+ std::vector<unsigned int> chunk_row_lengths (m_chunks, 0);
for (size_type i=0; i<m; ++i)
chunk_row_lengths[i/chunk_size] += row_lengths[i];
SparsityPattern::SparsityPattern (const size_type m,
const size_type n,
- const size_type max_per_row,
+ const unsigned int max_per_row,
const bool)
:
max_dim(0),
SparsityPattern::SparsityPattern (const size_type m,
const size_type n,
- const size_type max_per_row)
+ const unsigned int max_per_row)
:
max_dim(0),
max_vec_len(0),
SparsityPattern::SparsityPattern (const size_type m,
const size_type n,
- const std::vector<size_type> &row_lengths,
+ const std::vector<unsigned int> &row_lengths,
const bool)
:
max_dim(0),
SparsityPattern::SparsityPattern (const size_type m,
const size_type n,
- const std::vector<size_type> &row_lengths)
+ const std::vector<unsigned int> &row_lengths)
:
max_dim(0),
max_vec_len(0),
SparsityPattern::SparsityPattern (const size_type n,
- const size_type max_per_row)
+ const unsigned int max_per_row)
:
max_dim(0),
max_vec_len(0),
SparsityPattern::SparsityPattern (const size_type m,
- const std::vector<size_type> &row_lengths,
+ const std::vector<unsigned int> &row_lengths,
const bool)
:
max_dim(0),
SparsityPattern::SparsityPattern (const size_type m,
- const std::vector<size_type> &row_lengths)
+ const std::vector<unsigned int> &row_lengths)
:
max_dim(0),
max_vec_len(0),
SparsityPattern::SparsityPattern (const SparsityPattern &original,
- const size_type max_per_row,
+ const unsigned int max_per_row,
const size_type extra_off_diagonals)
:
max_dim(0),
void
SparsityPattern::reinit (const size_type m,
const size_type n,
- const size_type max_per_row,
+ const unsigned int max_per_row,
const bool)
{
// simply map this function to the
// other @p{reinit} function
- const std::vector<size_type> row_lengths (m, max_per_row);
+ const std::vector<unsigned int> row_lengths (m, max_per_row);
reinit (m, n, row_lengths);
}
void
SparsityPattern::reinit (const size_type m,
const size_type n,
- const size_type max_per_row)
+ const unsigned int max_per_row)
{
// simply map this function to the
// other @p{reinit} function
- const std::vector<size_type> row_lengths (m, max_per_row);
+ const std::vector<unsigned int> row_lengths (m, max_per_row);
reinit (m, n, row_lengths);
}
void
SparsityPattern::reinit (const size_type m,
const size_type n,
- const VectorSlice<const std::vector<size_type> > &row_lengths,
+ const VectorSlice<const std::vector<unsigned int> > &row_lengths,
const bool)
{
reinit (m, n, row_lengths);
void
SparsityPattern::reinit (const size_type m,
const size_type n,
- const VectorSlice<const std::vector<size_type> > &row_lengths)
+ const VectorSlice<const std::vector<unsigned int> > &row_lengths)
{
AssertDimension (row_lengths.size(), m);
// note that the number of elements
// per row is bounded by the number
// of columns
+ //
std::size_t vec_len = 0;
for (size_type i=0; i<m; ++i)
- vec_len += std::min((store_diagonal_first_in_row ?
- std::max(row_lengths[i], static_cast<size_type> (1U)) :
- row_lengths[i]),
+ vec_len += std::min(static_cast<size_type>(store_diagonal_first_in_row ?
+ std::max(row_lengths[i], 1U) :
+ row_lengths[i]),
n);
// sometimes, no entries are
max_row_length = (row_lengths.size() == 0 ?
0 :
- std::min (*std::max_element(row_lengths.begin(),
- row_lengths.end()),
+ std::min (static_cast<size_type>(*std::max_element(row_lengths.begin(),
+ row_lengths.end())),
n));
if (store_diagonal_first_in_row && (max_row_length==0) && (m!=0))
for (size_type i=1; i<=rows; ++i)
rowstart[i] = rowstart[i-1] +
(store_diagonal_first_in_row ?
- std::max(std::min(row_lengths[i-1],n),static_cast<size_type> (1U)) :
- std::min(row_lengths[i-1],n));
+ std::max(std::min(static_cast<size_type>(row_lengths[i-1]),n),
+ static_cast<size_type> (1U)) :
+ std::min(static_cast<size_type>(row_lengths[i-1]),n));
Assert ((rowstart[rows]==vec_len)
||
((vec_len == 1) && (rowstart[rows] == 0)),
// diagonal entry is in a certain
// row or not
const bool do_diag_optimize = (csp.n_rows() == csp.n_cols());
- std::vector<size_type> row_lengths (csp.n_rows());
+ std::vector<unsigned int> row_lengths (csp.n_rows());
for (size_type i=0; i<csp.n_rows(); ++i)
{
row_lengths[i] = csp.row_length(i);
// also have to allocate memory for the
// diagonal entry, unless we have already
// counted it
- std::vector<size_type> entries_per_row (matrix.m(), 0);
+ std::vector<unsigned int> entries_per_row (matrix.m(), 0);
for (size_type row=0; row<matrix.m(); ++row)
{
for (size_type col=0; col<matrix.n(); ++col)
void
SparsityPattern::reinit (const size_type m,
const size_type n,
- const std::vector<size_type> &row_lengths,
+ const std::vector<unsigned int> &row_lengths,
const bool)
{
reinit(m, n, make_slice(row_lengths));
void
SparsityPattern::reinit (const size_type m,
const size_type n,
- const std::vector<size_type> &row_lengths)
+ const std::vector<unsigned int> &row_lengths)
{
reinit(m, n, make_slice(row_lengths));
}