From: willems Date: Wed, 15 Feb 2012 08:52:15 +0000 (+0000) Subject: test for computing generalized eigenvalue problems with LAPACK added - this tests... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1f7696ea194bb86c9b22ba354f1851516773c58;p=dealii-svn.git test for computing generalized eigenvalue problems with LAPACK added - this tests the simple version of compute_generalized_eigenvalues_symmetric git-svn-id: https://svn.dealii.org/trunk@25075 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/lapack/full_matrix_05.cc b/tests/lapack/full_matrix_05.cc new file mode 100644 index 0000000000..7566138c9b --- /dev/null +++ b/tests/lapack/full_matrix_05.cc @@ -0,0 +1,82 @@ +//-------------------------------------------------------------------- +// $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 +#include +#include +#include + +#include +#include +#include + +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 A(4,4,left), + B(4,4,right); + LAPACKFullMatrix 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 > eigenvectors(A.m()); + LA.compute_generalized_eigenvalues_symmetric (LB, eigenvectors, itype); + + for (unsigned int i=0;i lambda = LA.eigenvalue(i); + deallog << "generalized eigenvalue " + << std::scientific << lambda.real() << '\t' + << std::scientific << lambda.imag() << std::endl + << "generalized eigenvector "; + for (unsigned int j=0;j