}
+namespace
+{
+ template <typename number>
+ void check_nonzero_diagonal (const SparseMatrix<number> &matrix)
+ {
+ for (typename SparseMatrix<number>::size_type row=0; row<matrix.m(); ++row)
+ Assert(matrix.diag_element(row) != 0.,
+ ExcMessage("There is a zero on the diagonal of this matrix "
+ "in row "
+ +
+ Utilities::int_to_string(row)
+ +
+ ". The preconditioner you selected cannot work if that "
+ "is the case because one of its steps requires "
+ "division by the diagonal elements of the matrix."
+ "\n\n"
+ "You should check whether you have correctly "
+ "assembled the matrix that you use for this "
+ "preconditioner. If it is correct that there are "
+ "zeros on the diagonal, then you will have to chose "
+ "a different preconditioner."));
+ }
+}
+
template <typename number>
template <typename somenumber>
AssertDimension (dst.size(), n());
AssertDimension (src.size(), n());
+ check_nonzero_diagonal(*this);
+
const size_type n = src.size();
somenumber *dst_ptr = dst.begin();
const somenumber *src_ptr = src.begin();
AssertDimension (dst.size(), n());
AssertDimension (src.size(), n());
+ check_nonzero_diagonal(*this);
+
const size_type n = src.size();
const std::size_t *rowstart_ptr = &cols->rowstart[0];
somenumber *dst_ptr = &dst(0);
// divide by diagonal element
*dst_ptr -= s * om;
- Assert(val[*rowstart_ptr]!= 0., ExcDivideByZero());
*dst_ptr /= val[*rowstart_ptr];
- };
+ }
rowstart_ptr = &cols->rowstart[0];
dst_ptr = &dst(0);
s += val[j] * dst(cols->colnums[j]);
*dst_ptr -= s * om;
- Assert(val[*rowstart_ptr]!= 0., ExcDivideByZero());
*dst_ptr /= val[*rowstart_ptr];
};
return;
AssertDimension (m(), n());
AssertDimension (dst.size(), n());
+ check_nonzero_diagonal(*this);
+
for (size_type row=0; row<m(); ++row)
{
somenumber s = dst(row);
s -= val[j] * dst(col);
}
- Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
dst(row) = s * om / val[cols->rowstart[row]];
}
}
AssertDimension (m(), n());
AssertDimension (dst.size(), n());
+ check_nonzero_diagonal(*this);
+
size_type row=m()-1;
while (true)
{
if (cols->colnums[j] > row)
s -= val[j] * dst(cols->colnums[j]);
- Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
dst(row) = s * om / val[cols->rowstart[row]];
if (row == 0)
Assert (m() == inverse_permutation.size(),
ExcDimensionMismatch(m(), inverse_permutation.size()));
+ check_nonzero_diagonal(*this);
+
for (size_type urow=0; urow<m(); ++urow)
{
const size_type row = permutation[urow];
}
}
- Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
dst(row) = s * om / val[cols->rowstart[row]];
}
}
Assert (m() == inverse_permutation.size(),
ExcDimensionMismatch(m(), inverse_permutation.size()));
+ check_nonzero_diagonal(*this);
+
for (size_type urow=m(); urow != 0;)
{
--urow;
s -= val[j] * dst(col);
}
- Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
dst(row) = s * om / val[cols->rowstart[row]];
}
}
Assert (m() == v.size(), ExcDimensionMismatch(m(),v.size()));
Assert (m() == b.size(), ExcDimensionMismatch(m(),b.size()));
+ check_nonzero_diagonal(*this);
+
for (size_type row=0; row<m(); ++row)
{
somenumber s = b(row);
{
s -= val[j] * v(cols->colnums[j]);
}
- Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
v(row) += s * om / val[cols->rowstart[row]];
}
}
Assert (m() == v.size(), ExcDimensionMismatch(m(),v.size()));
Assert (m() == b.size(), ExcDimensionMismatch(m(),b.size()));
+ check_nonzero_diagonal(*this);
+
for (int row=m()-1; row>=0; --row)
{
somenumber s = b(row);
{
s -= val[j] * v(cols->colnums[j]);
}
- Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
v(row) += s * om / val[cols->rowstart[row]];
}
}
AssertDimension (m(), n());
Assert (m() == dst.size(), ExcDimensionMismatch(m(),dst.size()));
+ check_nonzero_diagonal(*this);
+
const size_type n = dst.size();
size_type j;
somenumber s;
}
}
dst(i) -= s * om;
- Assert(val[cols->rowstart[i]]!= 0., ExcDivideByZero());
dst(i) /= val[cols->rowstart[i]];
}
if (static_cast<size_type>(i)<j) s += val[j] * dst(p);
}
}
- Assert(val[cols->rowstart[i]]!= 0., ExcDivideByZero());
dst(i) -= s * om / val[cols->rowstart[i]];
}
}