Skip to content

Commit

Permalink
added check for gcr inverter
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlhansen committed Apr 6, 2024
1 parent ebcb2b5 commit ce04fa4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
6 changes: 1 addition & 5 deletions checks/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ void run_checks()
{
lprintf("CHECK", INFO, "Status: PASSED (all checks succeded)");
}
else if(failed == 1)
{
lprintf("CHECK", INFO, "Status: FAILED (%d check reported an error)", failed);
}
else
{
lprintf("CHECK", INFO, "Status: FAILED (%d checks reported an error)", failed);
lprintf("CHECK", INFO, "Status: FAILED (%d check(s) reported an error)", failed);
}
}
46 changes: 46 additions & 0 deletions checks/inverters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static int check_bicgstab()
spinor_allocate(Mu);

// Random spinor fields
spinor_zero(Mu);
spinor_random(u);
norm = spinor_sqnorm(u);

Expand Down Expand Up @@ -61,6 +62,7 @@ static int check_minres()
spinor_allocate(Mu);

// Random spinor fields
spinor_zero(Mu);
spinor_random(u);
norm = spinor_sqnorm(u);

Expand Down Expand Up @@ -89,6 +91,48 @@ static int check_minres()
}
}

static int check_gcr()
{
SpinorField u, Mu, v;
double r1, norm;
inv_par par;
int it;

// Allocate memory
spinor_allocate(u);
spinor_allocate(v);
spinor_allocate(Mu);

// Random spinor fields
spinor_zero(Mu);
spinor_random(u);
norm = spinor_sqnorm(u);

// Apply dirac operator
par.prec = prec;
par.mass = mass;
par.log = 0;
par.mvm = Dphi;
it = gcr_inverter(par, Mu, u);

// Check result
Dphi(mass, v, Mu);
spinor_sub_assign(v,u);
r1 = spinor_sqnorm(v) / norm;

// Evaluate result
if(r1 < prec)
{
lprintf("CHECK", INFO, "GCR inverter: PASSED [diff = %1.6e, iter = %d]", r1, it);
return 0;
}
else
{
lprintf("CHECK", INFO, "GCR inverter: FAILED [diff = %1.6e, iter = %d]", r1, it);
return 1;
}
}

static int check_cg()
{
SpinorField u, Mu, v;
Expand All @@ -102,6 +146,7 @@ static int check_cg()
spinor_allocate(Mu);

// Random spinor fields
spinor_zero(Mu);
spinor_random(u);
norm = spinor_sqnorm(u);

Expand Down Expand Up @@ -195,6 +240,7 @@ int check_inverters()
int ret = 0;
ret += check_bicgstab();
ret += check_minres();
ret += check_gcr();
ret += check_cg();
ret += check_cg_mshift();
return ret;
Expand Down

0 comments on commit ce04fa4

Please sign in to comment.