From: guido Date: Tue, 22 Apr 2003 19:44:16 +0000 (+0000) Subject: new test for Eigensolvers X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c2a1134860b095f17c6fa1447c6939b04e2ad4a;p=dealii-svn.git new test for Eigensolvers git-svn-id: https://svn.dealii.org/trunk@7444 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/lac/Makefile b/tests/lac/Makefile index 2b8db44ea2..f50f5edbac 100644 --- a/tests/lac/Makefile +++ b/tests/lac/Makefile @@ -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 index 0000000000..9ed17e26c0 --- /dev/null +++ b/tests/lac/eigen.cc @@ -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 +#include +#include +#include +#include "testmatrix.h" +#include +#include +#include +#include +#include +#include +#include + + +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 A(structure); + testproblem.five_point(A); + + Vector 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; +}