]> https://gitweb.dealii.org/ - dealii.git/commitdiff
eigenvalues
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 30 Mar 2005 18:11:36 +0000 (18:11 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 30 Mar 2005 18:11:36 +0000 (18:11 +0000)
git-svn-id: https://svn.dealii.org/trunk@10322 0785d39b-7218-0410-832d-ea1e28bc413d

tests/lac/lapack.cc

index 31d5f1688bd5ab78f737cee24d794932fdd464ea..a6496443f0555a8baacaa23bf0f81f6ee63435d1 100644 (file)
 #include <fstream>
 #include <iostream>
 
+/*
+ * Eigenvalues and -vectors of this system are
+ * lambda = 1     v = (1, 1, 1, 1)
+ * lambda = 5     v = (1,-1, 0, 0)
+ * lambda = 5     v = (0, 1,-1, 0)
+ * lambda = 5     v = (0, 0, 1,-1)
+ */
 const double symm[] =
 {
-      4., 1., -1., 1.,
-      1., 4., 1., -1.,
-      -1., 1., 4., 1.,
-      1., -1., 4., 1.
+      4., -1., -1., -1.,
+      -1., 4., -1., -1.,
+      -1., -1., 4., -1.,
+      -1., -1., -1., 4.
 };
 
 const double rect[] =
@@ -41,7 +48,7 @@ const double rect[] =
 int main()
 {
   std::ofstream logfile("lapack.output");
-  logfile.precision(4);
+  logfile.precision(3);
   deallog.attach(logfile);
   deallog.depth_console(0);
 
@@ -96,11 +103,20 @@ int main()
   LA.reinit(4,4);
   A.fill(symm);
   LA = A;
+  LA.compute_eigenvalues();
+  for (unsigned int i=0;i<A.m();++i)
+    {
+      std::complex<double> lambda = LA.eigenvalue(i);
+      deallog << "Eigenvalues "
+             << (int) (lambda.real()+.0001) << '\t'
+             << (int) (lambda.imag()+.0001) << std::endl;
+    }
+  
   v1.reinit(4);
   v2.reinit(4);
   
 #else
-                                  // If lapack is not available, this
+                       // If lapack is not available, this
                                   // test will not complain.
   deallog.push("Rect");
   deallog << "operator= (const FullMatrix<number>&) ok" << std::endl;
@@ -108,6 +124,10 @@ int main()
   deallog << "vmult_add ok" << std::endl;
   deallog << "Tvmult ok" << std::endl;
   deallog << "Tvmult_add ok" << std::endl;
+  deallog << "Eigenvalues 5\t0" << std::endl;
+  deallog << "Eigenvalues 1\t0" << std::endl;
+  deallog << "Eigenvalues 5\t0" << std::endl;
+  deallog << "Eigenvalues 5\t0" << std::endl;
   deallog.pop();
 #endif
 }

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.