]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix a bug in Arpack class related to wrong eigenvectors
authorDenis Davydov <davydden@gmail.com>
Thu, 17 Sep 2015 20:16:31 +0000 (22:16 +0200)
committerDenis Davydov <davydden@gmail.com>
Thu, 17 Sep 2015 20:25:51 +0000 (22:25 +0200)
Extend the unit test to check that we indeed have eigenvectors.

include/deal.II/lac/arpack_solver.h
tests/arpack/step-36_ar.cc

index dfb6bfc9fcbe26ce2dc4d57615fbfb74f06390c7..42739b43d3b51d020df4f49d582e6f0d2a596d27 100644 (file)
@@ -528,7 +528,7 @@ void ArpackSolver::solve (
       const unsigned int n_eigenvecs = eigenvectors.size();
       for (size_type i=0; i<n_eigenvecs; ++i)
         for (unsigned int j=0; j<n; ++j)
-          eigenvectors[i](j) = z[i*n+j];
+          eigenvectors[i](j) = v[i*n+j];
 
       delete[] workd;
 
index 276895d792a3ae1901642f4f59c9bb2c07dafc9f..1811ba4f93ee2d5df09871a653d2c6237609d3f0 100644 (file)
@@ -226,6 +226,25 @@ namespace Step36
                        eigenfunctions,
                        eigenvalues.size());
 
+    // make sure that we have eigenvectors and they are mass-orthonormal:
+    // a) (A*x_i-\lambda*B*x_i).L2() == 0
+    // b) x_i*B*y_i=\delta_{ij}
+    {
+      Vector<double> Ax(eigenfunctions[0]), Bx(eigenfunctions[0]);
+      for (unsigned int i=0; i < eigenfunctions.size(); ++i)
+        {
+          mass_matrix.vmult(Bx,eigenfunctions[i]);
+
+          for (unsigned int j=0; j < eigenfunctions.size(); j++)
+            Assert( std::abs( eigenfunctions[j] * Bx - (i==j))< 1e-8,
+                    ExcMessage(std::to_string(eigenfunctions[j] * Bx)));
+
+          stiffness_matrix.vmult(Ax,eigenfunctions[i]);
+          Ax.add(-1.0*std::real(eigenvalues[i]),Bx);
+          Assert (Ax.l2_norm() < 1e-8,
+                  ExcMessage(std::to_string(Ax.l2_norm())));
+        }
+    }
     for (unsigned int i=0; i<eigenfunctions.size(); ++i)
       eigenfunctions[i] /= eigenfunctions[i].linfty_norm ();
 

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.