Skip to content
Snippets Groups Projects
Commit 2aaf64d6 authored by Marian Piatkowski's avatar Marian Piatkowski Committed by Steffen Müthing
Browse files

[Tests] added tests using complex nonsingular matrices and complex hermitian...

[Tests] added tests using complex nonsingular matrices and complex hermitian matrices to test the MinRes and GMRes solver on purely complex problems
parent af950964
No related branches found
No related tags found
No related merge requests found
void assemblecomplexmatrix(Dune::FieldMatrix<std::complex<double>,10,10>& complexmatrix) {
{
std::complex<double> temp(-0.967399,-0.514226);
complexmatrix[0][0] = temp;
}
{
std::complex<double> temp(0.05349,0.539828);
complexmatrix[0][1] = temp;
}
{
std::complex<double> temp(-0.52344,0.941268);
complexmatrix[0][2] = temp;
}
{
std::complex<double> temp(0.375723,-0.668052);
complexmatrix[0][3] = temp;
}
{
std::complex<double> temp(-0.0350187,-0.56835);
complexmatrix[0][4] = temp;
}
{
std::complex<double> temp(-0.793658,-0.747849);
complexmatrix[0][5] = temp;
}
{
std::complex<double> temp(-0.85094,0.900208);
complexmatrix[0][6] = temp;
}
{
std::complex<double> temp(0.146637,0.511162);
complexmatrix[0][7] = temp;
}
{
std::complex<double> temp(-0.281809,0.10497);
complexmatrix[0][8] = temp;
}
{
std::complex<double> temp(0.958868,0.487622);
complexmatrix[0][9] = temp;
}
{
std::complex<double> temp(-0.725537,0.608354);
complexmatrix[1][0] = temp;
}
{
std::complex<double> temp(-0.199543,0.783059);
complexmatrix[1][1] = temp;
}
{
std::complex<double> temp(0.804416,0.70184);
complexmatrix[1][2] = temp;
}
{
std::complex<double> temp(-0.119791,0.76015);
complexmatrix[1][3] = temp;
}
{
std::complex<double> temp(0.900505,0.840257);
complexmatrix[1][4] = temp;
}
{
std::complex<double> temp(-0.00911187,0.52095);
complexmatrix[1][5] = temp;
}
{
std::complex<double> temp(-0.894941,0.0431268);
complexmatrix[1][6] = temp;
}
{
std::complex<double> temp(-0.896122,-0.684386);
complexmatrix[1][7] = temp;
}
{
std::complex<double> temp(0.15886,-0.0948483);
complexmatrix[1][8] = temp;
}
{
std::complex<double> temp(0.806733,0.967191);
complexmatrix[1][9] = temp;
}
{
std::complex<double> temp(-0.686642,-0.198111);
complexmatrix[2][0] = temp;
}
{
std::complex<double> temp(-0.433371,-0.295083);
complexmatrix[2][1] = temp;
}
{
std::complex<double> temp(-0.466669,0.0795207);
complexmatrix[2][2] = temp;
}
{
std::complex<double> temp(0.658402,-0.339326);
complexmatrix[2][3] = temp;
}
{
std::complex<double> temp(-0.70468,0.762124);
complexmatrix[2][4] = temp;
}
{
std::complex<double> temp(0.969503,0.870008);
complexmatrix[2][5] = temp;
}
{
std::complex<double> temp(-0.647579,-0.519875);
complexmatrix[2][6] = temp;
}
{
std::complex<double> temp(0.999987,-0.591343);
complexmatrix[2][7] = temp;
}
{
std::complex<double> temp(0.374775,-0.80072);
complexmatrix[2][8] = temp;
}
{
std::complex<double> temp(0.333761,-0.00548296);
complexmatrix[2][9] = temp;
}
{
std::complex<double> temp(-0.740419,-0.782382);
complexmatrix[3][0] = temp;
}
{
std::complex<double> temp(0.615449,0.838053);
complexmatrix[3][1] = temp;
}
{
std::complex<double> temp(-0.249586,0.520497);
complexmatrix[3][2] = temp;
}
{
std::complex<double> temp(-0.542064,0.786745);
complexmatrix[3][3] = temp;
}
{
std::complex<double> temp(0.282161,-0.136093);
complexmatrix[3][4] = temp;
}
{
std::complex<double> temp(0.36889,-0.233623);
complexmatrix[3][5] = temp;
}
{
std::complex<double> temp(0.595596,0.465309);
complexmatrix[3][6] = temp;
}
{
std::complex<double> temp(0.779911,-0.749063);
complexmatrix[3][7] = temp;
}
{
std::complex<double> temp(0.061616,0.514588);
complexmatrix[3][8] = temp;
}
{
std::complex<double> temp(-0.672064,0.660024);
complexmatrix[3][9] = temp;
}
{
std::complex<double> temp(0.997849,-0.563486);
complexmatrix[4][0] = temp;
}
{
std::complex<double> temp(-0.860489,0.898654);
complexmatrix[4][1] = temp;
}
{
std::complex<double> temp(0.0250707,0.335448);
complexmatrix[4][2] = temp;
}
{
std::complex<double> temp(-0.29928,0.37334);
complexmatrix[4][3] = temp;
}
{
std::complex<double> temp(0.239193,-0.437881);
complexmatrix[4][4] = temp;
}
{
std::complex<double> temp(0.499542,-0.262673);
complexmatrix[4][5] = temp;
}
{
std::complex<double> temp(0.313127,0.93481);
complexmatrix[4][6] = temp;
}
{
std::complex<double> temp(0.995598,-0.891885);
complexmatrix[4][7] = temp;
}
{
std::complex<double> temp(-0.39141,0.984457);
complexmatrix[4][8] = temp;
}
{
std::complex<double> temp(0.777898,-0.846011);
complexmatrix[4][9] = temp;
}
{
std::complex<double> temp(0.0258648,0.678224);
complexmatrix[5][0] = temp;
}
{
std::complex<double> temp(0.0519907,-0.827888);
complexmatrix[5][1] = temp;
}
{
std::complex<double> temp(0.0632129,-0.921439);
complexmatrix[5][2] = temp;
}
{
std::complex<double> temp(0.912937,0.17728);
complexmatrix[5][3] = temp;
}
{
std::complex<double> temp(0.572004,-0.385084);
complexmatrix[5][4] = temp;
}
{
std::complex<double> temp(-0.411679,-0.535477);
complexmatrix[5][5] = temp;
}
{
std::complex<double> temp(0.278917,0.51947);
complexmatrix[5][6] = temp;
}
{
std::complex<double> temp(0.74108,-0.855342);
complexmatrix[5][7] = temp;
}
{
std::complex<double> temp(0.153942,0.755228);
complexmatrix[5][8] = temp;
}
{
std::complex<double> temp(0.299414,-0.503912);
complexmatrix[5][9] = temp;
}
{
std::complex<double> temp(0.22528,-0.407937);
complexmatrix[6][0] = temp;
}
{
std::complex<double> temp(-0.615572,0.326454);
complexmatrix[6][1] = temp;
}
{
std::complex<double> temp(-0.124725,0.86367);
complexmatrix[6][2] = temp;
}
{
std::complex<double> temp(0.314608,0.717353);
complexmatrix[6][3] = temp;
}
{
std::complex<double> temp(-0.105933,-0.547787);
complexmatrix[6][4] = temp;
}
{
std::complex<double> temp(0.168977,-0.511175);
complexmatrix[6][5] = temp;
}
{
std::complex<double> temp(-0.813039,-0.730195);
complexmatrix[6][6] = temp;
}
{
std::complex<double> temp(-0.991677,0.846138);
complexmatrix[6][7] = temp;
}
{
std::complex<double> temp(0.495619,0.25782);
complexmatrix[6][8] = temp;
}
{
std::complex<double> temp(0.258959,-0.541726);
complexmatrix[6][9] = temp;
}
{
std::complex<double> temp(0.275105,0.0485744);
complexmatrix[7][0] = temp;
}
{
std::complex<double> temp(0.780465,-0.302214);
complexmatrix[7][1] = temp;
}
{
std::complex<double> temp(0.86162,0.441905);
complexmatrix[7][2] = temp;
}
{
std::complex<double> temp(-0.12088,0.84794);
complexmatrix[7][3] = temp;
}
{
std::complex<double> temp(-0.624934,-0.447531);
complexmatrix[7][4] = temp;
}
{
std::complex<double> temp(-0.69522,0.464297);
complexmatrix[7][5] = temp;
}
{
std::complex<double> temp(0.0404201,-0.843536);
complexmatrix[7][6] = temp;
}
{
std::complex<double> temp(0.187784,-0.639255);
complexmatrix[7][7] = temp;
}
{
std::complex<double> temp(-0.929158,0.495606);
complexmatrix[7][8] = temp;
}
{
std::complex<double> temp(0.40124,-0.366266);
complexmatrix[7][9] = temp;
}
{
std::complex<double> temp(-0.012834,0.94555);
complexmatrix[8][0] = temp;
}
{
std::complex<double> temp(-0.871657,-0.959954);
complexmatrix[8][1] = temp;
}
{
std::complex<double> temp(-0.431413,0.477069);
complexmatrix[8][2] = temp;
}
{
std::complex<double> temp(-0.203127,0.629534);
complexmatrix[8][3] = temp;
}
{
std::complex<double> temp(0.112888,-0.166997);
complexmatrix[8][4] = temp;
}
{
std::complex<double> temp(-0.74905,0.586941);
complexmatrix[8][5] = temp;
}
{
std::complex<double> temp(-0.860187,-0.59069);
complexmatrix[8][6] = temp;
}
{
std::complex<double> temp(-0.673737,-0.21662);
complexmatrix[8][7] = temp;
}
{
std::complex<double> temp(0.666477,0.850753);
complexmatrix[8][8] = temp;
}
{
std::complex<double> temp(-0.342446,-0.537144);
complexmatrix[8][9] = temp;
}
{
std::complex<double> temp(-0.414966,0.542715);
complexmatrix[9][0] = temp;
}
{
std::complex<double> temp(-0.0845965,-0.873808);
complexmatrix[9][1] = temp;
}
{
std::complex<double> temp(0.279958,-0.291903);
complexmatrix[9][2] = temp;
}
{
std::complex<double> temp(0.368437,0.821944);
complexmatrix[9][3] = temp;
}
{
std::complex<double> temp(-0.660786,0.813608);
complexmatrix[9][4] = temp;
}
{
std::complex<double> temp(-0.671796,0.490143);
complexmatrix[9][5] = temp;
}
{
std::complex<double> temp(-0.0771591,0.639355);
complexmatrix[9][6] = temp;
}
{
std::complex<double> temp(0.826053,0.63939);
complexmatrix[9][7] = temp;
}
{
std::complex<double> temp(0.746543,0.662075);
complexmatrix[9][8] = temp;
}
{
std::complex<double> temp(-0.851678,0.266144);
complexmatrix[9][9] = temp;
}
}
void assemblecomplexsol(Dune::FieldVector<std::complex<double>,10>& complexsol) {
{
std::complex<double> temp(0.680375,-0.211234);
complexsol[0] = temp;
}
{
std::complex<double> temp(0.566198,0.59688);
complexsol[1] = temp;
}
{
std::complex<double> temp(0.823295,-0.604897);
complexsol[2] = temp;
}
{
std::complex<double> temp(-0.329554,0.536459);
complexsol[3] = temp;
}
{
std::complex<double> temp(-0.444451,0.10794);
complexsol[4] = temp;
}
{
std::complex<double> temp(-0.0452059,0.257742);
complexsol[5] = temp;
}
{
std::complex<double> temp(-0.270431,0.0268018);
complexsol[6] = temp;
}
{
std::complex<double> temp(0.904459,0.83239);
complexsol[7] = temp;
}
{
std::complex<double> temp(0.271423,0.434594);
complexsol[8] = temp;
}
{
std::complex<double> temp(-0.716795,0.213938);
complexsol[9] = temp;
}
}
void assemblehermitianmatrix(Dune::FieldMatrix<std::complex<double>,10,10>& hermitianmatrix) {
{
std::complex<double> temp(7.1979,0);
hermitianmatrix[0][0] = temp;
}
{
std::complex<double> temp(-3.79613,0.337878);
hermitianmatrix[0][1] = temp;
}
{
std::complex<double> temp(-0.779261,-2.0295);
hermitianmatrix[0][2] = temp;
}
{
std::complex<double> temp(0.242436,-0.521006);
hermitianmatrix[0][3] = temp;
}
{
std::complex<double> temp(1.21578,-2.01008);
hermitianmatrix[0][4] = temp;
}
{
std::complex<double> temp(2.00739,1.26115);
hermitianmatrix[0][5] = temp;
}
{
std::complex<double> temp(0.840054,0.355666);
hermitianmatrix[0][6] = temp;
}
{
std::complex<double> temp(-0.536624,1.06516);
hermitianmatrix[0][7] = temp;
}
{
std::complex<double> temp(-0.310006,-0.185391);
hermitianmatrix[0][8] = temp;
}
{
std::complex<double> temp(-0.136951,-2.19192);
hermitianmatrix[0][9] = temp;
}
{
std::complex<double> temp(-3.79613,-0.337878);
hermitianmatrix[1][0] = temp;
}
{
std::complex<double> temp(8.17735,0);
hermitianmatrix[1][1] = temp;
}
{
std::complex<double> temp(3.42368,-0.832754);
hermitianmatrix[1][2] = temp;
}
{
std::complex<double> temp(-0.573885,1.28575);
hermitianmatrix[1][3] = temp;
}
{
std::complex<double> temp(-1.00032,-1.68604);
hermitianmatrix[1][4] = temp;
}
{
std::complex<double> temp(-2.16182,-2.2912);
hermitianmatrix[1][5] = temp;
}
{
std::complex<double> temp(3.31168,-0.170324);
hermitianmatrix[1][6] = temp;
}
{
std::complex<double> temp(0.00156628,0.235513);
hermitianmatrix[1][7] = temp;
}
{
std::complex<double> temp(-2.05228,0.726318);
hermitianmatrix[1][8] = temp;
}
{
std::complex<double> temp(0.651714,-0.53826);
hermitianmatrix[1][9] = temp;
}
{
std::complex<double> temp(-0.779261,2.0295);
hermitianmatrix[2][0] = temp;
}
{
std::complex<double> temp(3.42368,0.832754);
hermitianmatrix[2][1] = temp;
}
{
std::complex<double> temp(6.0996,0);
hermitianmatrix[2][2] = temp;
}
{
std::complex<double> temp(0.936352,2.43134);
hermitianmatrix[2][3] = temp;
}
{
std::complex<double> temp(-0.451209,0.476809);
hermitianmatrix[2][4] = temp;
}
{
std::complex<double> temp(-0.719716,1.03015);
hermitianmatrix[2][5] = temp;
}
{
std::complex<double> temp(-0.16819,1.93903);
hermitianmatrix[2][6] = temp;
}
{
std::complex<double> temp(-0.368538,0.874901);
hermitianmatrix[2][7] = temp;
}
{
std::complex<double> temp(-0.33095,0.647156);
hermitianmatrix[2][8] = temp;
}
{
std::complex<double> temp(1.11793,-1.25097);
hermitianmatrix[2][9] = temp;
}
{
std::complex<double> temp(0.242436,0.521006);
hermitianmatrix[3][0] = temp;
}
{
std::complex<double> temp(-0.573885,-1.28575);
hermitianmatrix[3][1] = temp;
}
{
std::complex<double> temp(0.936352,-2.43134);
hermitianmatrix[3][2] = temp;
}
{
std::complex<double> temp(6.33101,0);
hermitianmatrix[3][3] = temp;
}
{
std::complex<double> temp(-0.29934,-0.0254698);
hermitianmatrix[3][4] = temp;
}
{
std::complex<double> temp(0.680716,0.684221);
hermitianmatrix[3][5] = temp;
}
{
std::complex<double> temp(-1.58563,0.571855);
hermitianmatrix[3][6] = temp;
}
{
std::complex<double> temp(-0.397706,0.698965);
hermitianmatrix[3][7] = temp;
}
{
std::complex<double> temp(3.47475,-0.980498);
hermitianmatrix[3][8] = temp;
}
{
std::complex<double> temp(0.383783,0.29558);
hermitianmatrix[3][9] = temp;
}
{
std::complex<double> temp(1.21578,2.01008);
hermitianmatrix[4][0] = temp;
}
{
std::complex<double> temp(-1.00032,1.68604);
hermitianmatrix[4][1] = temp;
}
{
std::complex<double> temp(-0.451209,-0.476809);
hermitianmatrix[4][2] = temp;
}
{
std::complex<double> temp(-0.29934,0.0254698);
hermitianmatrix[4][3] = temp;
}
{
std::complex<double> temp(5.78251,0);
hermitianmatrix[4][4] = temp;
}
{
std::complex<double> temp(2.35225,-1.91541);
hermitianmatrix[4][5] = temp;
}
{
std::complex<double> temp(-0.0505014,1.72034);
hermitianmatrix[4][6] = temp;
}
{
std::complex<double> temp(-1.38429,-1.61064);
hermitianmatrix[4][7] = temp;
}
{
std::complex<double> temp(-1.49723,-0.714079);
hermitianmatrix[4][8] = temp;
}
{
std::complex<double> temp(2.64429,1.53753);
hermitianmatrix[4][9] = temp;
}
{
std::complex<double> temp(2.00739,-1.26115);
hermitianmatrix[5][0] = temp;
}
{
std::complex<double> temp(-2.16182,2.2912);
hermitianmatrix[5][1] = temp;
}
{
std::complex<double> temp(-0.719716,-1.03015);
hermitianmatrix[5][2] = temp;
}
{
std::complex<double> temp(0.680716,-0.684221);
hermitianmatrix[5][3] = temp;
}
{
std::complex<double> temp(2.35225,1.91541);
hermitianmatrix[5][4] = temp;
}
{
std::complex<double> temp(6.70879,0);
hermitianmatrix[5][5] = temp;
}
{
std::complex<double> temp(-0.93953,0.554215);
hermitianmatrix[5][6] = temp;
}
{
std::complex<double> temp(0.0637686,-1.07886);
hermitianmatrix[5][7] = temp;
}
{
std::complex<double> temp(-0.607236,-2.56897);
hermitianmatrix[5][8] = temp;
}
{
std::complex<double> temp(0.56042,0.792441);
hermitianmatrix[5][9] = temp;
}
{
std::complex<double> temp(0.840054,-0.355666);
hermitianmatrix[6][0] = temp;
}
{
std::complex<double> temp(3.31168,0.170324);
hermitianmatrix[6][1] = temp;
}
{
std::complex<double> temp(-0.16819,-1.93903);
hermitianmatrix[6][2] = temp;
}
{
std::complex<double> temp(-1.58563,-0.571855);
hermitianmatrix[6][3] = temp;
}
{
std::complex<double> temp(-0.0505014,-1.72034);
hermitianmatrix[6][4] = temp;
}
{
std::complex<double> temp(-0.93953,-0.554215);
hermitianmatrix[6][5] = temp;
}
{
std::complex<double> temp(8.32866,0);
hermitianmatrix[6][6] = temp;
}
{
std::complex<double> temp(1.91184,-3.72418);
hermitianmatrix[6][7] = temp;
}
{
std::complex<double> temp(0.113768,0.560428);
hermitianmatrix[6][8] = temp;
}
{
std::complex<double> temp(-0.731302,-0.846837);
hermitianmatrix[6][9] = temp;
}
{
std::complex<double> temp(-0.536624,-1.06516);
hermitianmatrix[7][0] = temp;
}
{
std::complex<double> temp(0.00156628,-0.235513);
hermitianmatrix[7][1] = temp;
}
{
std::complex<double> temp(-0.368538,-0.874901);
hermitianmatrix[7][2] = temp;
}
{
std::complex<double> temp(-0.397706,-0.698965);
hermitianmatrix[7][3] = temp;
}
{
std::complex<double> temp(-1.38429,1.61064);
hermitianmatrix[7][4] = temp;
}
{
std::complex<double> temp(0.0637686,1.07886);
hermitianmatrix[7][5] = temp;
}
{
std::complex<double> temp(1.91184,3.72418);
hermitianmatrix[7][6] = temp;
}
{
std::complex<double> temp(10.876,0);
hermitianmatrix[7][7] = temp;
}
{
std::complex<double> temp(-1.7118,0.00877277);
hermitianmatrix[7][8] = temp;
}
{
std::complex<double> temp(-0.0866127,0.762093);
hermitianmatrix[7][9] = temp;
}
{
std::complex<double> temp(-0.310006,0.185391);
hermitianmatrix[8][0] = temp;
}
{
std::complex<double> temp(-2.05228,-0.726318);
hermitianmatrix[8][1] = temp;
}
{
std::complex<double> temp(-0.33095,-0.647156);
hermitianmatrix[8][2] = temp;
}
{
std::complex<double> temp(3.47475,0.980498);
hermitianmatrix[8][3] = temp;
}
{
std::complex<double> temp(-1.49723,0.714079);
hermitianmatrix[8][4] = temp;
}
{
std::complex<double> temp(-0.607236,2.56897);
hermitianmatrix[8][5] = temp;
}
{
std::complex<double> temp(0.113768,-0.560428);
hermitianmatrix[8][6] = temp;
}
{
std::complex<double> temp(-1.7118,-0.00877277);
hermitianmatrix[8][7] = temp;
}
{
std::complex<double> temp(6.47601,0);
hermitianmatrix[8][8] = temp;
}
{
std::complex<double> temp(-2.9372,0.407539);
hermitianmatrix[8][9] = temp;
}
{
std::complex<double> temp(-0.136951,2.19192);
hermitianmatrix[9][0] = temp;
}
{
std::complex<double> temp(0.651714,0.53826);
hermitianmatrix[9][1] = temp;
}
{
std::complex<double> temp(1.11793,1.25097);
hermitianmatrix[9][2] = temp;
}
{
std::complex<double> temp(0.383783,-0.29558);
hermitianmatrix[9][3] = temp;
}
{
std::complex<double> temp(2.64429,-1.53753);
hermitianmatrix[9][4] = temp;
}
{
std::complex<double> temp(0.56042,-0.792441);
hermitianmatrix[9][5] = temp;
}
{
std::complex<double> temp(-0.731302,0.846837);
hermitianmatrix[9][6] = temp;
}
{
std::complex<double> temp(-0.0866127,-0.762093);
hermitianmatrix[9][7] = temp;
}
{
std::complex<double> temp(-2.9372,-0.407539);
hermitianmatrix[9][8] = temp;
}
{
std::complex<double> temp(7.2643,0);
hermitianmatrix[9][9] = temp;
}
}
......@@ -18,6 +18,7 @@
#include <dune/istl/solvers.hh>
#include <dune/istl/preconditioners.hh>
#include "laplacian.hh"
#include "assemble_random_matrix_vectors.hh"
#if HAVE_SUPERLU
#include <dune/istl/superlu.hh>
......@@ -246,5 +247,96 @@ int main(int argc, char** argv)
const int errorCount = solverTest.getNumFailures();
std::cout << "Tested " << testCount << " different solvers or preconditioners " << " for a laplacian with complex rhs. " << testCount - errorCount << " out of " << testCount << " solvers converged! " << std::endl << std::endl;
std::cout << "============================================" << '\n'
<< "starting solver tests with complex matrices and complex rhs... "
<< std::endl
<< std::endl;
std::cout << "============================================" << '\n'
<< "solving system with Hilbert matrix of size 10 times imaginary unit... "
<< std::endl
<< std::endl;
Dune::FieldMatrix<std::complex<double>,10,10> hilbertmatrix;
for(int i=0; i<10; i++) {
for(int j=0; j<10; j++) {
std::complex<double> temp(0.0,1./(i+j+1));
hilbertmatrix[i][j] = temp;
}
}
Dune::FieldVector<std::complex<double>,10> hilbertsol(1.0);
Dune::FieldVector<std::complex<double>,10> hilbertiter(0.0);
Dune::MatrixAdapter<Dune::FieldMatrix<std::complex<double>,10,10>,Dune::FieldVector<std::complex<double>,10>,Dune::FieldVector<std::complex<double>,10> > hilbertadapter(hilbertmatrix);
Dune::FieldVector<std::complex<double>,10> hilbertrhs(0.0);
hilbertadapter.apply(hilbertsol,hilbertrhs);
Dune::Richardson<Dune::FieldVector<std::complex<double>,10>,Dune::FieldVector<std::complex<double>,10> > noprec(1.0);
Dune::RestartedGMResSolver<Dune::FieldVector<std::complex<double>,10> > realgmrestest(hilbertadapter,noprec,reduction,maxIter,maxIter,2);
Dune::InverseOperatorResult stat;
realgmrestest.apply(hilbertiter,hilbertrhs,stat);
std::cout << hilbertiter << std::endl;
// error of solution
hilbertiter -= hilbertsol;
std::cout << "error of solution with GMRes:" << std::endl;
std::cout << hilbertiter.two_norm() << std::endl;
std::cout << "============================================" << '\n'
<< "solving system with complex matrix of size 10" << '\n'
<< "randomly generated with the Eigen library... "
<< std::endl << std::endl;
Dune::FieldMatrix<std::complex<double>,10,10> complexmatrix(0.0), hermitianmatrix(0.0);
Dune::FieldVector<std::complex<double>,10> complexsol, complexrhs(0.0), complexiter(0.0);
// assemble randomly generated matrices from Eigen
assemblecomplexmatrix(complexmatrix);
assemblecomplexsol(complexsol);
assemblehermitianmatrix(hermitianmatrix);
Dune::MatrixAdapter<Dune::FieldMatrix<std::complex<double>,10,10>,Dune::FieldVector<std::complex<double>,10>,Dune::FieldVector<std::complex<double>,10> > complexadapter(complexmatrix), hermitianadapter(hermitianmatrix);
Dune::SeqJac<Dune::FieldMatrix<std::complex<double>,10,10>,Dune::FieldVector<std::complex<double>,10>,Dune::FieldVector<std::complex<double>,10>,0> complexjacprec(complexmatrix,1,1.0);
Dune::Richardson<Dune::FieldVector<std::complex<double>,10>,Dune::FieldVector<std::complex<double>,10> > complexnoprec(1.0);
Dune::RestartedGMResSolver<Dune::FieldVector<std::complex<double>,10> > complexgmrestest(complexadapter,complexnoprec,1e-12,maxIter,maxIter*maxIter,2);
complexadapter.apply(complexsol,complexrhs);
complexgmrestest.apply(complexiter,complexrhs,stat);
std::cout << complexiter << std::endl;
// error of solution
complexiter -= complexsol;
std::cout << "error of solution with GMRes: " << complexiter.two_norm() << std::endl;
std::cout << "============================================" << '\n'
<< "solving system with hermitian matrix of size 10" << '\n'
<< "randomly generated with the Eigen libary... "
<< std::endl << std::endl;
Dune::RestartedGMResSolver<Dune::FieldVector<std::complex<double>,10> > hermitiangmrestest(hermitianadapter,complexnoprec,1e-12,maxIter,maxIter*maxIter,2);
Dune::MINRESSolver<Dune::FieldVector<std::complex<double>,10> > complexminrestest(hermitianadapter,complexnoprec,1e-12,maxIter,2);
complexiter = 0.0;
hermitianadapter.apply(complexsol,complexrhs);
hermitiangmrestest.apply(complexiter,complexrhs,stat);
std::cout << complexiter << std::endl;
// error of solution
complexiter -= complexsol;
std::cout << "error of solution with GMRes: " << complexiter.two_norm() << std::endl;
complexiter = 0.0;
hermitianadapter.apply(complexsol,complexrhs);
complexminrestest.apply(complexiter,complexrhs,stat);
std::cout << complexiter << std::endl;
// error of solution
complexiter-= complexsol;
std::cout << "error of solution with MinRes: " << complexiter.two_norm() << std::endl;
return errorCount;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment