]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
test for computing generalized eigenvalue problem with LAPACK added. Unlike full_matr...
authorwillems <willems@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 15 Feb 2012 09:06:48 +0000 (09:06 +0000)
committerwillems <willems@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 15 Feb 2012 09:06:48 +0000 (09:06 +0000)
git-svn-id: https://svn.dealii.org/trunk@25076 0785d39b-7218-0410-832d-ea1e28bc413d

tests/lapack/full_matrix_06.cc [new file with mode: 0644]
tests/lapack/full_matrix_06/cmp/generic [new file with mode: 0644]
tests/lapack/full_matrix_06/exe [new file with mode: 0755]
tests/lapack/full_matrix_06/output [new file with mode: 0644]
tests/lapack/full_matrix_06/status [new file with mode: 0644]

diff --git a/tests/lapack/full_matrix_06.cc b/tests/lapack/full_matrix_06.cc
new file mode 100644 (file)
index 0000000..370579b
--- /dev/null
@@ -0,0 +1,87 @@
+//--------------------------------------------------------------------
+//    $Id: full_matrix_05.cc 23710 2011-05-17 04:50:10Z bangerth $
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005, 2006, 2010 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//--------------------------------------------------------------------
+
+// Tests generalized eigenvalues of FullMatrix
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/lapack_full_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <float.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+const double left[] =
+{
+      4., -1., -1., -1.,
+      -1., 4., -1., -1.,
+      -1., -1., 4., -1.,
+      -1., -1., -1., 4.
+};
+
+const double right[] =
+{
+      4., -1., -1., -1.,
+      -1., 5., -1., -1.,
+      -1., -1., 6., -1.,
+      -1., -1., -1., 7.
+};
+
+
+
+int main()
+{
+  const std::string logname = JobIdentifier::base_name(__FILE__) + std::string("/output");
+  std::ofstream logfile(logname.c_str());
+  logfile.precision(1);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  
+  FullMatrix<double> A(4,4,left),
+                     B(4,4,right);
+  LAPACKFullMatrix<double> LA(4,4),
+                           LB(4,4);
+  for(unsigned int itype=1;itype<=3; ++itype)
+    {                     
+      deallog << std::endl 
+              << "generalized eigenvalue problem of type " 
+             << itype << std::endl;
+      LA = A;
+      LB = B;
+      std::vector<Vector<double> > eigenvectors(0);
+      Vector<double> eigenvalues(0);
+      
+      LA.compute_generalized_eigenvalues_symmetric (LB, 0.5, 3.0,
+                                                   2.0*DBL_MIN,
+                                                   eigenvalues,
+                                                   eigenvectors,
+                                                   itype);
+      
+      for (unsigned int i=0;i<eigenvectors.size();++i)
+       {
+         deallog << "generalized eigenvalue "
+                 << std::scientific << eigenvalues(i) << std::endl
+                 << "generalized eigenvector ";
+         for (unsigned int j=0;j<A.m();++j)
+           {
+             deallog << std::scientific 
+                     << eigenvectors[i](j)/eigenvectors[i](0) 
+                     << '\t';
+           }
+         deallog << std::endl;
+       }
+    }
+}
diff --git a/tests/lapack/full_matrix_06/cmp/generic b/tests/lapack/full_matrix_06/cmp/generic
new file mode 100644 (file)
index 0000000..8fa76a7
--- /dev/null
@@ -0,0 +1,17 @@
+
+DEAL::
+DEAL::generalized eigenvalue problem of type 1
+DEAL::generalized eigenvalue 6.768858e-01
+DEAL::generalized eigenvector 1.000000e+00     1.721100e+00    6.171030e+00    -3.892130e+00   
+DEAL::generalized eigenvalue 8.071810e-01
+DEAL::generalized eigenvector 1.000000e+00     6.144108e+00    -1.482613e+00   -6.614950e-01   
+DEAL::generalized eigenvalue 1.000000e+00
+DEAL::generalized eigenvector 1.000000e+00     0.000000e+00    0.000000e+00    0.000000e+00    
+DEAL::
+DEAL::generalized eigenvalue problem of type 2
+DEAL::generalized eigenvalue 2.288432e+00
+DEAL::generalized eigenvector 1.000000e+00     8.195699e-01    6.942977e-01    6.022441e-01    
+DEAL::
+DEAL::generalized eigenvalue problem of type 3
+DEAL::generalized eigenvalue 2.288432e+00
+DEAL::generalized eigenvector 1.000000e+00     9.561649e-01    9.257303e-01    9.033661e-01    
diff --git a/tests/lapack/full_matrix_06/exe b/tests/lapack/full_matrix_06/exe
new file mode 100755 (executable)
index 0000000..87afd3a
Binary files /dev/null and b/tests/lapack/full_matrix_06/exe differ
diff --git a/tests/lapack/full_matrix_06/output b/tests/lapack/full_matrix_06/output
new file mode 100644 (file)
index 0000000..8fa76a7
--- /dev/null
@@ -0,0 +1,17 @@
+
+DEAL::
+DEAL::generalized eigenvalue problem of type 1
+DEAL::generalized eigenvalue 6.768858e-01
+DEAL::generalized eigenvector 1.000000e+00     1.721100e+00    6.171030e+00    -3.892130e+00   
+DEAL::generalized eigenvalue 8.071810e-01
+DEAL::generalized eigenvector 1.000000e+00     6.144108e+00    -1.482613e+00   -6.614950e-01   
+DEAL::generalized eigenvalue 1.000000e+00
+DEAL::generalized eigenvector 1.000000e+00     0.000000e+00    0.000000e+00    0.000000e+00    
+DEAL::
+DEAL::generalized eigenvalue problem of type 2
+DEAL::generalized eigenvalue 2.288432e+00
+DEAL::generalized eigenvector 1.000000e+00     8.195699e-01    6.942977e-01    6.022441e-01    
+DEAL::
+DEAL::generalized eigenvalue problem of type 3
+DEAL::generalized eigenvalue 2.288432e+00
+DEAL::generalized eigenvector 1.000000e+00     9.561649e-01    9.257303e-01    9.033661e-01    
diff --git a/tests/lapack/full_matrix_06/status b/tests/lapack/full_matrix_06/status
new file mode 100644 (file)
index 0000000..ce1b499
--- /dev/null
@@ -0,0 +1 @@
+diff ok

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.