From 949918077442b56bad464c193c5c56ea41602090 Mon Sep 17 00:00:00 2001 From: guido Date: Wed, 23 Apr 2003 09:31:11 +0000 Subject: [PATCH] test for eigenvector iterations git-svn-id: https://svn.dealii.org/trunk@7450 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/lac/Makefile | 2 +- tests/lac/eigen.cc | 26 ++++++++++++++----- .../lac/eigen.output | 15 +++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 tests/results/sparc-sun-solaris2.7+gcc2.95/lac/eigen.output diff --git a/tests/lac/Makefile b/tests/lac/Makefile index f50f5edbac..1ec83d497f 100644 --- a/tests/lac/Makefile +++ b/tests/lac/Makefile @@ -39,7 +39,7 @@ vector-vector.exe : vector-vector.g.$(OBJEXT) $(librar tests = $(sort \ sparse_matrices block_matrices block_vector block_vector_iterator \ full_matrix \ - matrix_out solver sparsity_pattern sparse_ilu \ + matrix_out solver eigen sparsity_pattern sparse_ilu \ vector-vector) ############################################################ diff --git a/tests/lac/eigen.cc b/tests/lac/eigen.cc index 9ed17e26c0..9a0cf931c6 100644 --- a/tests/lac/eigen.cc +++ b/tests/lac/eigen.cc @@ -25,7 +25,6 @@ #include #include - int main() { std::ofstream logfile("eigen.output"); @@ -39,6 +38,19 @@ int main() const unsigned int size = 10; const unsigned int dim = (size-1)*(size-1); + + /* + * Compute minimal and maximal + * eigenvalues of the 5-point + * stencil matrix + * (Hackbusch:Iterative Lösung..., + * Satz 4.1.1) + */ + const double h = 1./size; + const double s = std::sin(M_PI*h/2.); + const double c = std::cos(M_PI*h/2.); + const double lambda_max = 8.*c*c; + const double lambda_min = 8.*s*s; FDMatrix testproblem(size, size); SparsityPattern structure(dim, dim, 5); @@ -53,24 +65,24 @@ int main() EigenPower<> mises(control, mem); mises.solve(lambda, A, u); - deallog << "Eigenvalue " << lambda << std::endl; + deallog << "Eigenvalue " << lambda << " Error " << lambda-lambda_max << std::endl; double lambda2; u = 1.; EigenPower<> mises2(control, mem, -1.5*lambda); mises2.solve(lambda2, A, u); - deallog << "Eigenvalue " << lambda2 << std::endl; + deallog << "Eigenvalue " << lambda2 << " Error " << lambda2-lambda_min << std::endl; u = 1.; lambda = 0.; - EigenInverse<> wieland(control, mem); + EigenInverse<> wielandt(control, mem); wieland.solve(lambda, A, u); - deallog << "Eigenvalue " << lambda << std::endl; + deallog << "Eigenvalue " << lambda << " Error " << lambda-lambda_min << std::endl; u = 1.; lambda = 10.; - EigenInverse<> wieland2(control, mem); + EigenInverse<> wielandt2(control, mem); wieland2.solve(lambda, A, u); - deallog << "Eigenvalue " << lambda << std::endl; + deallog << "Eigenvalue " << lambda << " Error " << lambda-lambda_max << std::endl; } diff --git a/tests/results/sparc-sun-solaris2.7+gcc2.95/lac/eigen.output b/tests/results/sparc-sun-solaris2.7+gcc2.95/lac/eigen.output new file mode 100644 index 0000000000..8a13ce0239 --- /dev/null +++ b/tests/results/sparc-sun-solaris2.7+gcc2.95/lac/eigen.output @@ -0,0 +1,15 @@ + +DEAL:Power method::Starting value 1.246 +DEAL:Power method::Convergence step 44 value 9.310e-06 +DEAL::Eigenvalue 7.802 Error 0.002634 +DEAL:Power method::Starting value 0.02241 +DEAL:Power method::Convergence step 21 value 9.269e-06 +DEAL::Eigenvalue 0.2045 Error 0.008767 +DEAL:Wieland::Starting value 0.08568 +DEAL:Wieland::Convergence step 6 value 6.201e-06 +DEAL::Eigenvalue 0.1958 Error 1.511e-10 +DEAL:Wieland::Starting value 0.7500 +DEAL:Wieland::Convergence step 12 value 6.576e-06 +DEAL::Eigenvalue 7.804 Error -3.202e-08 +DEAL::GrowingVectorMemory:Overall allocated vectors: 88 +DEAL::GrowingVectorMemory:Maximum allocated vectors: 6 -- 2.39.5