]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
new test for Eigensolvers
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 22 Apr 2003 19:44:16 +0000 (19:44 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 22 Apr 2003 19:44:16 +0000 (19:44 +0000)
git-svn-id: https://svn.dealii.org/trunk@7444 0785d39b-7218-0410-832d-ea1e28bc413d

tests/lac/Makefile
tests/lac/eigen.cc [new file with mode: 0644]

index 2b8db44ea2bf7b96ea2c448325babdac013253bd..f50f5edbac48f32bb2e47fb87cb58777376d544c 100644 (file)
@@ -26,6 +26,7 @@ block_vector_iterator.exe : block_vector_iterator.g.$(OBJEXT)           $(librar
 full_matrix.exe           : full_matrix.g.$(OBJEXT)                     $(libraries)
 matrix_out.exe            : matrix_out.g.$(OBJEXT)                      $(libraries)
 solver.exe                : solver.g.$(OBJEXT)   testmatrix.g.$(OBJEXT) $(libraries)
+eigen.exe                 : eigen.g.$(OBJEXT)   testmatrix.g.$(OBJEXT) $(libraries)
 sparse_matrices.exe       : sparse_matrices.g.$(OBJEXT) testmatrix.g.$(OBJEXT) $(libraries)
 sparse_matrices.opt.exe   : sparse_matrices.$(OBJEXT) testmatrix.$(OBJEXT) $(libraries_o)
 sparsity_pattern.exe      : sparsity_pattern.g.$(OBJEXT) testmatrix.g.$(OBJEXT) $(libraries)
diff --git a/tests/lac/eigen.cc b/tests/lac/eigen.cc
new file mode 100644 (file)
index 0000000..9ed17e2
--- /dev/null
@@ -0,0 +1,76 @@
+//--------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 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.
+//
+//--------------------------------------------------------------------
+
+
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include "testmatrix.h"
+#include <base/logstream.h>
+#include <lac/sparse_matrix.h>
+#include <lac/vector.h>
+#include <lac/vector_memory.h>
+#include <lac/solver_control.h>
+#include <lac/eigen.h>
+#include <lac/precondition.h>
+
+
+int main()
+{
+    std::ofstream logfile("eigen.output");
+//  logfile.setf(std::ios::fixed);
+  logfile.precision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  GrowingVectorMemory<> mem;
+  SolverControl control(1000, 1.e-5);
+  
+  const unsigned int size = 10;
+  const unsigned int dim = (size-1)*(size-1);
+  
+  FDMatrix testproblem(size, size);
+  SparsityPattern structure(dim, dim, 5);
+  testproblem.five_point_structure(structure);
+  structure.compress();
+  SparseMatrix<double>  A(structure);
+  testproblem.five_point(A);
+
+  Vector<double> u(dim);
+  u = 1.;
+  double lambda;
+
+  EigenPower<> mises(control, mem);
+  mises.solve(lambda, A, u);
+  deallog << "Eigenvalue " << lambda << std::endl;
+
+  double lambda2;
+  u = 1.;
+  
+  EigenPower<> mises2(control, mem, -1.5*lambda);
+  mises2.solve(lambda2, A, u);
+  deallog << "Eigenvalue " << lambda2 << std::endl;
+
+  u = 1.;
+  lambda = 0.;
+  EigenInverse<> wieland(control, mem);
+  wieland.solve(lambda, A, u);
+  deallog << "Eigenvalue " << lambda << std::endl;  
+
+  u = 1.;
+  lambda = 10.;
+  EigenInverse<> wieland2(control, mem);
+  wieland2.solve(lambda, A, u);
+  deallog << "Eigenvalue " << lambda << std::endl;  
+}

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.