Change in-class defined SolverSelector functions out-of-class to
conform to general style guide. (Ralf?)
-Eliminate #vec_len# from the SparseMatrixStruct class. This should
- be rather simple since as far as I can see it is only used once
- (at all other places, it is only written) and also its value
- should be equal to rowstart[row].
-
Why not replace Vector::scale by Vector::operator *= ?
Use the commented-out version in PreconditionBlock::invert_diagblocks
max_len = 0;
return;
};
-
- if (max_len<cols->vec_len)
+
+ const unsigned int N = cols->n_nonzero_elements();
+ if (N > max_len)
{
if (val) delete[] val;
- val = new number[cols->vec_len];
- max_len = cols->vec_len;
+ val = new number[N];
+ max_len = N;
};
if (val)
- fill_n (&val[0], cols->vec_len, 0);
+ fill_n (&val[0], N, 0);
}
Assert (val != 0, ExcMatrixNotInitialized());
Assert (cols == matrix.cols, ExcDifferentSparsityPatterns());
- copy (&matrix.val[0], &matrix.val[cols->vec_len],
+ copy (&matrix.val[0], &matrix.val[cols->n_nonzero_elements()],
&val[0]);
return *this;
number *val_ptr = &val[0];
const somenumber *matrix_ptr = &matrix.val[0];
- const number *const end_ptr = &val[cols->vec_len];
+ const number *const end_ptr = &val[cols->n_nonzero_elements()];
while (val_ptr != end_ptr)
*val_ptr++ += factor * *matrix_ptr++;
{
// simply map this function to the
// other #reinit# function
- vector<unsigned int> row_lengths (m, max_per_row);
+ const vector<unsigned int> row_lengths (m, max_per_row);
reinit (m, n, row_lengths);
};
rows = m;
cols = n;
- vec_len = accumulate (row_lengths.begin(), row_lengths.end(), 0);
- max_row_length = (row_lengths.size() == 0 ?
- 0 :
- *max_element(row_lengths.begin(), row_lengths.end()));
// delete empty matrices
if ((m==0) || (n==0))
if (colnums) delete[] colnums;
rowstart = 0;
colnums = 0;
- max_vec_len = vec_len = max_dim = rows = cols = 0;
+ max_vec_len = max_dim = rows = cols = 0;
// if dimension is zero: ignore
// max_per_row
max_row_length = 0;
return;
};
+ // find out how many entries we
+ // need in the #colnums# array. if
+ // this number is larger than
+ // #max_vec_len#, then we will need
+ // to reallocate memory
+ const unsigned int vec_len = accumulate (row_lengths.begin(),
+ row_lengths.end(), 0);
+ max_row_length = (row_lengths.size() == 0 ?
+ 0 :
+ *max_element(row_lengths.begin(), row_lengths.end()));
+
+
// allocate memory for the rowstart
// values, if necessary
if (rows > max_dim)
// set the rowstart array
rowstart[0] = 0;
- for (unsigned int i=1; i<=rows; i++)
+ for (unsigned int i=1; i<=rows; ++i)
rowstart[i] = rowstart[i-1]+row_lengths[i-1];
Assert (rowstart[rows]==vec_len, ExcInternalError());
ExcInternalError());
};
- vec_len = rowstart[rows] = next_row_start;
+ rowstart[rows] = next_row_start;
compressed = true;
};
Assert (rows==0, ExcInternalError());
Assert (cols==0, ExcInternalError());
Assert (colnums==0, ExcInternalError());
- Assert (vec_len==0, ExcInternalError());
Assert (max_vec_len==0, ExcInternalError());
- Assert (vec_len==0, ExcInternalError());
return true;
};