From e57df66a4bda4e2de27737d60a685bd150d9197a Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Fri, 25 May 2018 23:09:29 -0500 Subject: [PATCH] Bugfix: Make sparse_matrix_ez and chunk_sparse_matrix fit for std::complex --- include/deal.II/lac/chunk_sparse_matrix.h | 4 ++-- include/deal.II/lac/sparse_matrix_ez.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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]); } -- 2.39.5