From: Alex Schmidt Date: Wed, 10 Oct 2012 10:32:03 +0000 (+0200) Subject: wrote neigh test routine X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/commitdiff_plain/c5c2e25140c048de78316f9d8faf01dc58509401?ds=sidebyside;hp=6b382d09f3825aca16f33e28e479b663d22e8a43 wrote neigh test routine --- diff --git a/.gitignore b/.gitignore index 382dfaa..9ed9ae9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ cmake_install.cmake Makefile *.a *~ +neigh_test diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b5abad..2f0439b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,3 +6,6 @@ target_link_libraries(lat_configcache boost_iostreams) add_library(lat_neigh neigh.cpp) add_library(lat_writeout writeout.cpp) + +add_executable(neigh_test neigh_test.cpp) +target_link_libraries(neigh_test lat_neigh) \ No newline at end of file diff --git a/neigh_test.cpp b/neigh_test.cpp new file mode 100644 index 0000000..38a74ec --- /dev/null +++ b/neigh_test.cpp @@ -0,0 +1,49 @@ +#include "neigh.h" +#include +#include +#include + +using namespace std; + +int main() +{ + neigh *n; + srand(time(NULL)); + + while( true ) + { + int l[] = { rand()%10 + 1, rand()%10 + 1, rand()%10 + 1 , rand()%10 + 1 }; + + n = new neigh(4,l[0],l[1],l[2],l[3]); + + cout << l[0] << "x" << l[1] << "x" << l[2] << "x" << l[3] << endl; + + for(int itry=0; itry<100000; itry++) + { + int dir0 = rand()%4; + int dir1 = rand()%3; + if(dir0 <= dir1) dir1++; + + int l0 = rand()%(3*l[dir0]); + int l1 = rand()%(3*l[dir1]); + + int startpos = rand()%l[0] + (rand()%l[1])*l[0] + (rand()%l[2])*l[0]*l[1] + (rand()%l[3])*l[0]*l[1]*l[2]; + + int pos = startpos; + + for(int istep=0; istep