]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Make sparse_matrix_ez and chunk_sparse_matrix fit for std::complex
authorMatthias Maier <tamiko@43-1.org>
Sat, 26 May 2018 04:09:29 +0000 (23:09 -0500)
committerMatthias Maier <tamiko@43-1.org>
Wed, 6 Jun 2018 15:19:38 +0000 (10:19 -0500)
include/deal.II/lac/chunk_sparse_matrix.h
include/deal.II/lac/sparse_matrix_ez.h

index be0b6677d603aa22c1ce141090b42ab14403bade..91f565d1c5783d82d3e11e1cd24efb2328f3813e 100644 (file)
@@ -1504,7 +1504,7 @@ ChunkSparseMatrix<number>::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<number>::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;
 
index 0cb5dfe586eaf863abcc4d51d9e55dd872f69a94..2d8c6ccb028dd69d93be0a4b8e17733675d1e632 100644 (file)
@@ -1273,7 +1273,7 @@ SparseMatrixEZ<number>::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<number>::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]);
 }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.