From: kanschat Date: Thu, 28 Jul 2011 18:41:25 +0000 (+0000) Subject: test FullMatrix Schur complement X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4254ac72811ea813a515281d975f65a6cbb718b2;p=dealii-svn.git test FullMatrix Schur complement git-svn-id: https://svn.dealii.org/trunk@23982 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/lac/full_matrix_04.cc b/tests/lac/full_matrix_04.cc new file mode 100644 index 0000000000..7a23f27e0a --- /dev/null +++ b/tests/lac/full_matrix_04.cc @@ -0,0 +1,125 @@ +//---------------------------- full_matrix_03.cc,v --------------------------- +// $Id$ +// +// Copyright (C) 2011 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. +// +//---------------------------- full_matrix_03.cc,v --------------------------- + +//check method schur_complement of FullMatrix + +#include "../tests.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +void diff(FullMatrix& M) +{ + const double err = M.frobenius_norm(); + if (err < 1.e-14) + deallog << "ok" << std::endl; + else + deallog << "oops " << err << std::endl; +} + + +void test (const unsigned int n, const unsigned int m) +{ + // Create some random matrices + FullMatrix A(n,n); + FullMatrix C(m,m); + FullMatrix B(n,m); + FullMatrix D(m,n); + FullMatrix Bt(m,n); + FullMatrix Dt(n,m); + + for (unsigned int i=0;i S1(m,m); + S1.schur_complement(A, D, B, false, false); + + FullMatrix aux1(n,m); + A.mmult(aux1,B); + FullMatrix aux2(m,m); + D.mmult(aux2,aux1); + aux2.add(-1., S1); + diff(aux2); + + // Compare second Schur complement + // with mmult + FullMatrix S2(n,n); + S2.schur_complement(C, B, D, false, false); + + FullMatrix aux3(m,n); + C.mmult(aux3,D); + FullMatrix aux4(n,n); + B.mmult(aux4,aux3); + aux4.add(-1., S2); + diff(aux4); + + // Check transpose versions + aux2 = 0.; + aux2.schur_complement(A, Dt, B, true, false); + aux2.add(-1., S1); + diff(aux2); + aux2 = 0.; + aux2.schur_complement(A, D, Bt, false, true); + aux2.add(-1., S1); + diff(aux2); + aux2 = 0.; + aux2.schur_complement(A, Dt, Bt, true, true); + aux2.add(-1., S1); + diff(aux2); + + aux4 = 0.; + aux4.schur_complement(C, Bt, D, true, false); + aux4.add(-1., S2); + diff(aux4); + aux4 = 0.; + aux4.schur_complement(C, B, Dt, false, true); + aux4.add(-1., S2); + diff(aux4); + aux4 = 0.; + aux4.schur_complement(C, Bt, Dt, true, true); + aux4.add(-1., S2); + diff(aux4); +} + + +int +main () +{ + const std::string logname = JobIdentifier::base_name(__FILE__) + std::string("/output"); + std::ofstream logfile(logname.c_str()); + deallog.attach(logfile); + deallog.depth_console(0); + std::srand(3391466); + + test(3,4); + test(4,7); +} diff --git a/tests/lac/full_matrix_04/cmp/generic b/tests/lac/full_matrix_04/cmp/generic new file mode 100644 index 0000000000..95eb871617 --- /dev/null +++ b/tests/lac/full_matrix_04/cmp/generic @@ -0,0 +1,17 @@ + +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok +DEAL::ok