From: Matthias Maier Date: Sat, 26 May 2018 04:09:29 +0000 (-0500) Subject: Bugfix: Make sparse_matrix_ez and chunk_sparse_matrix fit for std::complex X-Git-Tag: v9.1.0-rc1~1067^2~42 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e57df66a4bda4e2de27737d60a685bd150d9197a;p=dealii.git Bugfix: Make sparse_matrix_ez and chunk_sparse_matrix fit for std::complex --- diff --git a/include/deal.II/lac/chunk_sparse_matrix.h b/include/deal.II/lac/chunk_sparse_matrix.h index be0b6677d6..91f565d1c5 100644 --- a/include/deal.II/lac/chunk_sparse_matrix.h +++ b/include/deal.II/lac/chunk_sparse_matrix.h @@ -1504,7 +1504,7 @@ ChunkSparseMatrix::add(const size_type i, Assert(cols != nullptr, ExcNotInitialized()); - if (value != 0.) + if (std::abs(value) != 0.) { const size_type index = compute_location(i, j); Assert((index != ChunkSparsityPattern::invalid_entry), @@ -1564,7 +1564,7 @@ ChunkSparseMatrix::operator/=(const number factor) { Assert(cols != nullptr, ExcNotInitialized()); Assert(val != nullptr, ExcNotInitialized()); - Assert(factor != 0, ExcDivideByZero()); + Assert(std::abs(factor) != 0, ExcDivideByZero()); const number factor_inv = 1. / factor; diff --git a/include/deal.II/lac/sparse_matrix_ez.h b/include/deal.II/lac/sparse_matrix_ez.h index 0cb5dfe586..2d8c6ccb02 100644 --- a/include/deal.II/lac/sparse_matrix_ez.h +++ b/include/deal.II/lac/sparse_matrix_ez.h @@ -1273,7 +1273,7 @@ SparseMatrixEZ::add(const size_type i, Assert(j < n(), ExcIndexRange(j, 0, n())); // ignore zero additions - if (value == 0) + if (std::abs(value) == 0.) return; Entry *entry = allocate(i, j); @@ -1342,7 +1342,7 @@ SparseMatrixEZ::add(const size_type row, { // TODO: This function can surely be made more efficient for (size_type j = 0; j < n_cols; ++j) - if ((values[j] != 0) || (elide_zero_values == false)) + if ((std::abs(values[j]) != 0) || (elide_zero_values == false)) add(row, col_indices[j], values[j]); }