std::set<unsigned int>::const_iterator dof = boundary_dofs.begin(),
endd = boundary_dofs.end();
const SparsityPattern &sparsity = matrix.get_sparsity_pattern();
- const unsigned int *sparsity_rowstart = sparsity.get_rowstart_indices();
+ const std::size_t *sparsity_rowstart = sparsity.get_rowstart_indices();
const unsigned int *sparsity_colnums = sparsity.get_column_numbers();
for (; dof != endd; ++dof)
{
std::map<unsigned int,double>::const_iterator dof = boundary_values.begin(),
endd = boundary_values.end();
const SparsityPattern &sparsity = matrix.get_sparsity_pattern();
- const unsigned int *sparsity_rowstart = sparsity.get_rowstart_indices();
+ const std::size_t *sparsity_rowstart = sparsity.get_rowstart_indices();
const unsigned int *sparsity_colnums = sparsity.get_column_numbers();
for (; dof != endd; ++dof)
{
<ol>
- <li> <p>Improved: The class <code
- class="class">LAPACKFullMatrix</code> now also uses LU factorization
- of LAPACK. The new wrapper <code class="class">PreconditionLU</code>
- allows us to use this as a preconditioner.
- <br>
- (GK 2006/10/02)
+ <li> <p>Improved: The <code
+ class="class">SparsityPattern</code> class would produce
+ segmentation faults if one tried to allocate a matrix with more
+ than about 4.2 billion elements (i.e. the number that one can
+ store in a 32-bit unsigned integer). This is now fixed: if you
+ have enough memory, this is now possible on 64-bit
+ systems. (The number of rows is still limited by the 32-bit
+ limit, but this is probably going to be enough for some time to
+ come.) This fix also required changing the return type of the
+ <code>SparsityPattern::get_rowstart_indices</code> function
+ from <code>const unsigned int *</code> to <code>const
+ std::size_t *</code>; since this function should not be used
+ outside of the library anyway, this is probably not a change
+ that affects user code.
+ <br>
+ (WB 2006/12/14)
</p>
<li> <p>New: The class <code
{
const unsigned int * const
column_numbers = this->get_sparsity_pattern().get_column_numbers();
- const unsigned int * const
+ const std::size_t * const
rowstart_indices = this->get_sparsity_pattern().get_rowstart_indices();
const unsigned int N = this->m();
// note: pointers to the sparsity
// pattern of the old matrix!
- const unsigned int * const rowstart_indices
+ const std::size_t * const rowstart_indices
= matrix.get_sparsity_pattern().get_rowstart_indices();
const unsigned int * const column_numbers
this->strengthen_diagonal_impl();
const SparsityPattern &sparsity = this->get_sparsity_pattern();
- const unsigned int * const rowstart_indices = sparsity.get_rowstart_indices();
+ const std::size_t * const rowstart_indices = sparsity.get_rowstart_indices();
const unsigned int * const column_numbers = sparsity.get_column_numbers();
/*
Assert (dst.size() == this->m(), ExcDimensionMismatch(dst.size(), this->m()));
const unsigned int N=dst.size();
- const unsigned int * const rowstart_indices
+ const std::size_t * const rowstart_indices
= this->get_sparsity_pattern().get_rowstart_indices();
const unsigned int * const column_numbers
= this->get_sparsity_pattern().get_column_numbers();
Assert (dst.size() == this->m(), ExcDimensionMismatch(dst.size(), this->m()));
const unsigned int N=dst.size();
- const unsigned int * const rowstart_indices
+ const std::size_t * const rowstart_indices
= this->get_sparsity_pattern().get_rowstart_indices();
const unsigned int * const column_numbers
= this->get_sparsity_pattern().get_column_numbers();
const unsigned int n = src.size();
somenumber *dst_ptr = dst.begin();
const somenumber *src_ptr = src.begin();
- const unsigned int *rowstart_ptr = &cols->rowstart[0];
+ const std::size_t *rowstart_ptr = &cols->rowstart[0];
// optimize the following loop for
// the case that the relaxation
Assert (src.size() == n(), ExcDimensionMismatch (src.size(), n()));
const unsigned int n = src.size();
- const unsigned int *rowstart_ptr = &cols->rowstart[0];
+ const std::size_t *rowstart_ptr = &cols->rowstart[0];
somenumber *dst_ptr = &dst(0);
// forward sweep
}
const unsigned int* const col_nums = this->get_sparsity_pattern().get_column_numbers();
- const unsigned int* const rowstarts = this->get_sparsity_pattern().get_rowstart_indices();
+ const std::size_t* const rowstarts = this->get_sparsity_pattern().get_rowstart_indices();
for(unsigned int row=0; row<this->m(); row++)
{
// get start of this row. skip the
// diagonal element
const unsigned int * const column_numbers = this->get_sparsity_pattern().get_column_numbers();
- const unsigned int * const rowstart_indices = this->get_sparsity_pattern().get_rowstart_indices();
+ const std::size_t * const rowstart_indices = this->get_sparsity_pattern().get_rowstart_indices();
const unsigned int * const rowend = &column_numbers[rowstart_indices[row+1]];
// find the position where the part
Assert (dst.size() == this->m(), ExcDimensionMismatch(dst.size(), this->m()));
const unsigned int N=dst.size();
- const unsigned int * const rowstart_indices = this->get_sparsity_pattern().get_rowstart_indices();
+ const std::size_t * const rowstart_indices = this->get_sparsity_pattern().get_rowstart_indices();
const unsigned int * const column_numbers = this->get_sparsity_pattern().get_column_numbers();
// We assume the underlying matrix A is:
// A = X - L - U, where -L and -U are
* avoid programs relying on outdated
* information!
*/
- inline const unsigned int * get_rowstart_indices () const;
+ inline const std::size_t * get_rowstart_indices () const;
/**
* @deprecated. Use @p row_length and
* may be larger than the actually used
* part of the array.
*/
- unsigned int max_vec_len;
+ std::size_t max_vec_len;
/**
* Maximum number of elements per
* number of elements that was allocated
* is stored in #max_dim.
*/
- unsigned int *rowstart;
+ std::size_t *rowstart;
/**
* Array of column numbers. In
inline
-const unsigned int *
+const std::size_t *
SparsityPattern::get_rowstart_indices () const
{
return rowstart;
const unsigned int
n_rows = sparsity_pattern->n_rows();
- const unsigned int * const
+ const std::size_t * const
rowstart_indices = sparsity_pattern->get_rowstart_indices();
const unsigned int * const
col_nums = sparsity_pattern->get_column_numbers();
const SparsityPattern &sparsity_pattern = matrix.get_sparsity_pattern ();
const unsigned int n_rows = sparsity_pattern.n_rows();
- const unsigned int *rowstart_indices = sparsity_pattern.get_rowstart_indices();
+ const std::size_t *rowstart_indices = sparsity_pattern.get_rowstart_indices();
const unsigned int *col_nums = sparsity_pattern.get_column_numbers();
unsigned int global_index = 0;
const unsigned int
n_rows = sparsity_pattern.n_rows();
- const unsigned int * const
+ const std::size_t * const
rowstart_indices = sparsity_pattern.get_rowstart_indices();
const unsigned int * const
col_nums = sparsity_pattern.get_column_numbers();
const SparsityPattern &sparsity_pattern = matrix.get_sparsity_pattern ();
const unsigned int n_rows = sparsity_pattern.n_rows();
- const unsigned int *rowstart_indices = sparsity_pattern.get_rowstart_indices();
+ const std::size_t *rowstart_indices = sparsity_pattern.get_rowstart_indices();
const unsigned int *col_nums = sparsity_pattern.get_column_numbers();
unsigned int global_index = 0;
max_row_length = 0;
compressed = false;
return;
- };
+ }
// first, if the matrix is
// quadratic and special treatment
// note that the number of elements
// per row is bounded by the number
// of columns
- unsigned int vec_len = 0;
+ std::size_t vec_len = 0;
for (unsigned int i=0; i<m; ++i)
vec_len += std::min((diagonal_optimized ?
std::max(row_lengths[i], 1U) :
if (vec_len == 0)
{
vec_len = 1;
- if (colnums) delete[] colnums;
+ if (colnums)
+ {
+ delete[] colnums;
+ colnums = 0;
+ }
+
max_vec_len = vec_len;
colnums = new unsigned int[max_vec_len];
}
max_row_length = (row_lengths.size() == 0 ?
0 :
- std::min (*std::max_element(row_lengths.begin(), row_lengths.end()),
+ std::min (*std::max_element(row_lengths.begin(),
+ row_lengths.end()),
n));
if (diagonal_optimized && (max_row_length==0) && (m!=0))
max_row_length = 1;
// allocate memory for the rowstart
- // values, if necessary
+ // values, if necessary. even
+ // though we re-set the pointers
+ // again immediately after deleting
+ // their old content, set them to
+ // zero in between because the
+ // allocation might fail, in which
+ // case we get an exception and the
+ // destructor of this object will
+ // be called -- where we look at
+ // the non-nullness of the (now
+ // invalid) pointer again and try
+ // to delete the memory a second
+ // time.
if (rows > max_dim)
{
- if (rowstart) delete[] rowstart;
+ if (rowstart)
+ {
+ delete[] rowstart;
+ rowstart = 0;
+ }
+
max_dim = rows;
- rowstart = new unsigned int[max_dim+1];
- };
+ rowstart = new std::size_t[max_dim+1];
+ }
// allocate memory for the column
// numbers if necessary
if (vec_len > max_vec_len)
{
- if (colnums) delete[] colnums;
+ if (colnums)
+ {
+ delete[] colnums;
+ colnums = 0;
+ }
+
max_vec_len = vec_len;
colnums = new unsigned int[max_vec_len];
- };
+ }
// set the rowstart array
rowstart[0] = 0;
// elements there are, in order to
// allocate the right amount of
// memory
- const unsigned int nonzero_elements
+ const std::size_t nonzero_elements
= std::count_if (&colnums[rowstart[0]],
&colnums[rowstart[rows]],
std::bind2nd(std::not_equal_to<unsigned int>(), invalid_entry));
// gives us a sharp bound
unsigned int m = 0;
for (unsigned int i=1; i<rows; ++i)
- m = std::max (m, rowstart[i]-rowstart[i-1]);
+ m = std::max (m, static_cast<unsigned int>(rowstart[i]-rowstart[i-1]));
return m;
}
if (colnums)
delete[] colnums;
- rowstart = new unsigned int[max_dim+1];
+ rowstart = new std::size_t[max_dim+1];
colnums = new unsigned int[max_vec_len];
// then read data