]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use LinearOperator instead of ShiftedMatrix in eigen.h
authorMatthias Maier <tamiko@43-1.org>
Thu, 6 Apr 2017 21:26:56 +0000 (16:26 -0500)
committerMatthias Maier <tamiko@43-1.org>
Fri, 7 Apr 2017 13:32:57 +0000 (08:32 -0500)
include/deal.II/lac/eigen.h

index 9d874d234e3e433cf056f157b10426a75476fdcf..f459270ca37d8f62215d2c6b5e9a652c72632019 100644 (file)
 
 
 #include <deal.II/base/config.h>
-#include <deal.II/lac/shifted_matrix.h>
-#include <deal.II/lac/solver.h>
-#include <deal.II/lac/solver_control.h>
+#include <deal.II/lac/linear_operator.h>
+#include <deal.II/lac/precondition.h>
 #include <deal.II/lac/solver_cg.h>
+#include <deal.II/lac/solver_control.h>
 #include <deal.II/lac/solver_gmres.h>
+#include <deal.II/lac/solver.h>
 #include <deal.II/lac/solver_minres.h>
 #include <deal.II/lac/vector_memory.h>
-#include <deal.II/lac/precondition.h>
 
 #include <cmath>
 
@@ -334,7 +334,9 @@ EigenInverse<VectorType>::solve (double           &value,
   SolverControl::State conv=SolverControl::iterate;
 
   // Prepare matrix for solver
-  ShiftedMatrix <MatrixType> A_s(A, -value);
+  auto A_op = linear_operator(A);
+  double current_shift = -value;
+  auto A_s = A_op + current_shift * identity_operator(A_op);
 
   // Define solver
   ReductionControl inner_control (5000, 1.e-16, 1.e-5, false, false);
@@ -385,13 +387,17 @@ EigenInverse<VectorType>::solve (double           &value,
       // Compute unshifted eigenvalue
       value = (entry * x (i) < 0.) ? -length : length;
       value = 1./value;
-      value -= A_s.shift ();
+      value -= current_shift;
 
       if (iter==goal)
         {
-          const double new_shift = - additional_data.relaxation * value
-                                   + (1.-additional_data.relaxation) * A_s.shift();
-          A_s.shift(new_shift);
+          const auto &relaxation = additional_data.relaxation;
+          const double new_shift =
+              relaxation * (-value) + (1. - relaxation) * current_shift;
+
+          A_s = A_op + new_shift * identity_operator(A_op);
+          current_shift = new_shift;
+
           ++goal;
         }
 

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.