3#include "dirac/staggered.h" 
    4#include "dirac/wilson.h" 
    5#include "dirac/Hasenbusch.h" 
    6#include "dirac/conjugate_gradient.h" 
   10void test_gamma_matrices() {
 
   11    Wilson_vector<N, double> w1, w2, w3;
 
   17    w2 = w1 - gamma5 * (gamma5 * w1);
 
   18    assert(w2.squarenorm() < 0.0001 && 
"g5*g5 = 1");
 
   22        half_Wilson_vector<N, double> h1;
 
   23        w2 = w1 - gamma_matrix[d] * (gamma_matrix[d] * w1);
 
   24        assert(w2.squarenorm() < 0.0001 && 
"gamma_d*gamma_d = 1");
 
   26        w2 = w1 + gamma_matrix[d] * w1;
 
   27        h1 = half_Wilson_vector(w1, d, 1);
 
   28        double diff = w2.squarenorm() - 2 * h1.squarenorm();
 
   29        assert(diff * diff < 0.0001 && 
"half_Wilson_vector projection +1 norm");
 
   31        w3 = (U * h1).expand(d, 1) - U * w2;
 
   32        assert(w3.squarenorm() < 0.0001 && 
"half_wilson_vector expand");
 
   34        w2 = w1 - gamma_matrix[d] * w1;
 
   35        h1 = half_Wilson_vector(w1, d, -1);
 
   36        diff = w2.squarenorm() - 2 * h1.squarenorm();
 
   37        assert(diff * diff < 0.0001 && 
"half_Wilson_vector projection -1 norm");
 
   39        w3 = (U * h1).expand(d, -1) - U * w2;
 
   40        assert(w3.squarenorm() < 0.0001 && 
"half_wilson_vector expand");
 
   44int main(
int argc, 
char **argv) {
 
   60    test_gamma_matrices();
 
   69    hila::out0 << 
"Checking with dirac_staggered\n";
 
   74        a[X].gaussian_random();
 
   75        b[X].gaussian_random();
 
   78    double diffre = 0, diffim = 0;
 
   80    D.dagger(a, Ddaggera);
 
   82        diffre += a[X].dot(Db[X]).re - Ddaggera[X].dot(b[X]).re;
 
   83        diffim += a[X].dot(Db[X]).im - Ddaggera[X].dot(b[X]).im;
 
   86    assert(diffre * diffre < 1e-16 && 
"test dirac_staggered");
 
   87    assert(diffim * diffim < 1e-16 && 
"test dirac_staggered");
 
   92        a[X].gaussian_random();
 
   96    inverse.apply(Ddaggera, b);
 
  101    assert(diffre * diffre < 1e-16 && 
"test D (DdgD)^-1 Ddg");
 
  106    D.dagger(Db, DdaggerDb);
 
  110    assert(diffre * diffre < 1e-16 && 
"test DdgD (DdgD)^-1");
 
  114        b[X].gaussian_random();
 
  117    D.dagger(Db, DdaggerDb);
 
  119    inverse.apply(DdaggerDb, a);
 
  123    assert(diffre * diffre < 1e-16 && 
"test (DdgD)^-1 DdgD");
 
  141        a[X].gaussian_random();
 
  142        b[X].gaussian_random();
 
  145    double diffre = 0, diffim = 0;
 
  147    D.dagger(a, Ddaggera);
 
  149        diffre += a[X].dot(Db[X]).re - Ddaggera[X].dot(b[X]).re;
 
  150        diffim += a[X].dot(Db[X]).im - Ddaggera[X].dot(b[X]).im;
 
  153    assert(diffre * diffre < 1e-16 && 
"test Dirac_Wilson");
 
  154    assert(diffim * diffim < 1e-16 && 
"test Dirac_Wilson");
 
  160        a[X].gaussian_random();
 
  164    D.apply(Db, DdaggerDb);
 
  168    assert(diffre * diffre < 1e-8 && 
"test DdgD (DdgD)^-1");
 
  173        a[X].gaussian_random();
 
  175    D.dagger(a, Ddaggera);
 
  176    inverse.apply(Ddaggera, b);
 
  181    assert(diffre * diffre < 1e-8 && 
"test D (DdgD)^-1 Ddg");
 
  186    hila::out0 << 
"Checking with dirac_staggered_evenodd\n";
 
  190        a[X].gaussian_random();
 
  191        b[X].gaussian_random();
 
  194    double diffre = 0, diffim = 0;
 
  196    D.dagger(a, Ddaggera);
 
  198        diffre += a[X].dot(Db[X]).re - Ddaggera[X].dot(b[X]).re;
 
  199        diffim += a[X].dot(Db[X]).im - Ddaggera[X].dot(b[X]).im;
 
  202    assert(diffre * diffre < 1e-16 && 
"test dirac_staggered_evenodd");
 
  203    assert(diffim * diffim < 1e-16 && 
"test dirac_staggered_evenodd");
 
  208    inverse.apply(Ddaggera, b);
 
  212    assert(diffre * diffre < 1e-8 && 
"test CG");
 
  217    hila::out0 << 
"Checking with Dirac_Wilson_evenodd\n";
 
  232        a[X].gaussian_random();
 
  233        b[X].gaussian_random();
 
  236    double diffre = 0, diffim = 0;
 
  238    D.dagger(a, Ddaggera);
 
  240        diffre += a[X].dot(Db[X]).re - Ddaggera[X].dot(b[X]).re;
 
  241        diffim += a[X].dot(Db[X]).im - Ddaggera[X].dot(b[X]).im;
 
  244    assert(diffre * diffre < 1e-16 && 
"test Dirac_Wilson_evenodd");
 
  245    assert(diffim * diffim < 1e-16 && 
"test Dirac_Wilson_evenodd");
 
  252        a[X].gaussian_random();
 
  254    D.dagger(a, Ddaggera);
 
  255    inverse.apply(Ddaggera, b);
 
  261    assert(diffre * diffre < 1e-16 && 
"test D (DdgD)^-1 Ddg");
 
  265        a[X].gaussian_random();
 
  274    assert(diffre * diffre < 1e-16 && 
"test DdgD (DdgD)^-1");
 
  278        b[X].gaussian_random();
 
  281    D.dagger(Db, DdaggerDb);
 
  283    inverse.apply(DdaggerDb, a);
 
  287    assert(diffre * diffre < 1e-16 && 
"test (DdgD)^-1 DdgD");
 
  292    hila::out0 << 
"Checking with Hasenbusch_operator\n";
 
  294    dirac_base Dbase(0.1, U);
 
  303        a[X].gaussian_random();
 
  304        b[X].gaussian_random();
 
  308    double diffre = 0, diffim = 0;
 
  312        diffre += a[X].dot(Db[X]).re - Ddaggera[X].dot(b[X]).re;
 
  313        diffim += a[X].dot(Db[X]).im - Ddaggera[X].dot(b[X]).im;
 
  316    assert(diffre * diffre < 1e-16 && 
"test Hasenbusch_operator");
 
  317    assert(diffim * diffim < 1e-16 && 
"test Hasenbusch_operator");
 
  322    inverse.apply(Ddaggera, b);
 
  326    assert(diffre * diffre < 1e-16 && 
"test CG");
 
  330        a[X].gaussian_random();
 
  339    assert(diffre * diffre < 1e-16 && 
"test DdgD (DdgD)^-1");
 
  343        b[X].gaussian_random();
 
  346    D.dagger(Db, DdaggerDb);
 
  348    inverse.apply(DdaggerDb, a);
 
  352    assert(diffre * diffre < 1e-16 && 
"test (DdgD)^-1 DdgD");
 
hila::arithmetic_type< T > squarenorm(const Array< n, m, T > &rhs)
Return square norm of Array.
The conjugate gradient operator. Applies the inverse square of an operator on a vector.
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
void set_boundary_condition(Direction dir, hila::bc bc)
Set the boundary condition in a given Direction (periodic or antiperiodic)
Field< A > dagger() const
Returns dagger or Hermitian conjugate of Field depending on how it is defined for Field type T.
void copy_boundary_condition(const Field< A > &rhs)
Copy the boundary condition from another field.
void setup(const CoordinateVector &siz)
lattice.setup(CoordinateVector size) - set up the base lattice. Called at the beginning of the progra...
Mtype & gaussian_random(base_type width=1.0)
Fills Matrix with gaussian random elements from gaussian distribution.
const SU & random(int nhits=16)
Generate random SU(N) matrix.
constexpr Parity EVEN
bit pattern: 001
#define foralldir(d)
Macro to loop over (all) Direction(s)
constexpr Parity ODD
bit pattern: 010
constexpr Parity ALL
bit pattern: 011
std::ostream out0
This writes output only from main process (node 0)
void initialize(int argc, char **argv)
Initial setup routines.
void seed_random(uint64_t seed, bool device_rng=true)
Seed random generators with 64-bit unsigned value. On MPI shuffles the seed so that different MPI ran...
void finishrun()
Normal, controlled exit - all nodes must call this. Prints timing information and information about c...