1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-09 23:45:36 +00:00

Naming and argument types

This commit is contained in:
Julian Lenz 2023-05-03 01:51:46 +01:00
parent 339c4fda79
commit 42b0e1125d

View File

@ -3,16 +3,14 @@
using namespace Grid; using namespace Grid;
template <typename T> template <typename T>
bool has_correct_block_structure(T U){ bool has_correct_group_block_structure(const T& U){
// checks on elements
const int nsp = Nc / 2;
Complex i(0., 1.);
std::cout << GridLogMessage << "Checking the structure is " << std::endl; std::cout << GridLogMessage << "Checking the structure is " << std::endl;
std::cout << GridLogMessage << "U = ( W X ) " << std::endl; std::cout << GridLogMessage << "U = ( W X ) " << std::endl;
std::cout << GridLogMessage << " ( -X^* W^* ) " << std::endl; std::cout << GridLogMessage << " ( -X^* W^* ) " << std::endl;
std::cout <<GridLogMessage << std::endl; std::cout <<GridLogMessage << std::endl;
const int nsp = Nc / 2;
Complex i(0., 1.);
for (int c1 = 0; c1 < nsp; c1++) //check on W for (int c1 = 0; c1 < nsp; c1++) //check on W
{ {
for (int c2 = 0; c2 < nsp; c2++) for (int c2 = 0; c2 < nsp; c2++)
@ -47,24 +45,21 @@ bool has_correct_block_structure(T U){
}; };
template <typename T> template <typename T>
bool is_element_of_Sp2n(T U) { bool is_element_of_sp2n_group(T U) {// does explicitly take a copy in order to not spoil the matrix for further use
LatticeColourMatrixD aux(U.Grid()); LatticeColourMatrixD aux(U.Grid());
LatticeColourMatrixD identity(U.Grid()); LatticeColourMatrixD identity(U.Grid());
identity = 1.0; identity = 1.0;
double vol = U.Grid()->gSites();
std::cout << GridLogMessage << "Unitary check" << std::endl; std::cout << GridLogMessage << "Unitary check" << std::endl;
aux = U*adj(U) - identity; aux = U*adj(U) - identity;
std::cout << GridLogMessage << "U adjU - 1 = " << norm2(aux) << std::endl; std::cout << GridLogMessage << "U adjU - 1 = " << norm2(aux) << std::endl;
assert( norm2(aux) < 1e-8); assert( norm2(aux) < 1e-8);
// actual sp2n check
std::cout << GridLogMessage << "Checking Omega invariance" << std::endl; std::cout << GridLogMessage << "Checking Omega invariance" << std::endl;
Sp<Nc>::OmegaInvariance(U); // no assertion here, but the next check will kill us if we are not simplectic Sp<Nc>::OmegaInvariance(U); // no assertion here, but the next check will kill us if we are not simplectic
return has_correct_block_structure(U); return has_correct_group_block_structure(U);
} }
template<typename T> template<typename T>
@ -83,8 +78,9 @@ void test_group_projections(T U) {
std::cout << GridLogMessage << "Testing "<< name << std::endl; std::cout << GridLogMessage << "Testing "<< name << std::endl;
std::cout << GridLogMessage << "Apply to deformed matrix" << std::endl; std::cout << GridLogMessage << "Apply to deformed matrix" << std::endl;
U = U + Delta*identity;
U = ProjectOnSpGroup(U); U = ProjectOnSpGroup(U);
assert(is_element_of_Sp2n(U)); assert(is_element_of_sp2n_group(U));
name = "ProjectOnGaugeGroup"; name = "ProjectOnGaugeGroup";
std::cout << GridLogMessage << "Testing "<< name << std::endl; std::cout << GridLogMessage << "Testing "<< name << std::endl;
@ -92,7 +88,7 @@ void test_group_projections(T U) {
U = U + Delta*identity; U = U + Delta*identity;
Sp<Nc>::ProjectOnGaugeGroup(U); Sp<Nc>::ProjectOnGaugeGroup(U);
assert(is_element_of_Sp2n(U)); assert(is_element_of_sp2n_group(U));
name = "ProjectGn"; name = "ProjectGn";
std::cout << GridLogMessage << "Testing "<< name << std::endl; std::cout << GridLogMessage << "Testing "<< name << std::endl;
@ -100,7 +96,7 @@ void test_group_projections(T U) {
U = U + Delta*identity; U = U + Delta*identity;
Sp<Nc>::ProjectGn(U); Sp<Nc>::ProjectGn(U);
assert(is_element_of_Sp2n(U)); assert(is_element_of_sp2n_group(U));
} }
@ -115,7 +111,6 @@ int main (int argc, char **argv)
Coordinate mpi_layout = GridDefaultMpi(); Coordinate mpi_layout = GridDefaultMpi();
GridCartesian Grid(latt_size,simd_layout,mpi_layout); GridCartesian Grid(latt_size,simd_layout,mpi_layout);
GridRedBlackCartesian RBGrid(&Grid);
LatticeGaugeField Umu(&Grid); LatticeGaugeField Umu(&Grid);