From ce469f414ae26bd9400985117a510776c2e3387a Mon Sep 17 00:00:00 2001 From: Mauro Iazzi Date: Mon, 23 Feb 2009 23:02:24 +0100 Subject: [PATCH] started Lua-ization --- Makefile | 11 ++++++++++- main.cpp | 30 +++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index c9697ea..f88d251 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,22 @@ CXXFLAGS=-O3 -march=core2 #CXXFLAGS=-g -ggdb LDFLAGS=-lm +SYSTEM=linux +LUA=lua-5.1.4 all: main debug: $(MAKE) CXXFLAGS="-g -ggdb" -main.o: Makefile .main.dep +lua-%: + wget http://lua.org/ftp/$@.tar.gz + tar -xvzf $@.tar.gz + +lua: $(LUA) + make -C $< $(SYSTEM) + +main.o: Makefile .main.dep lua .main.dep: main.cpp $(CXX) -MM main.cpp > .main.dep diff --git a/main.cpp b/main.cpp index fb6ec33..2c31f0f 100644 --- a/main.cpp +++ b/main.cpp @@ -365,13 +365,17 @@ void print_help () { void print_state (const SpinChain& s) { cout << s << endl; } +void load_file () { +} + int main (int argc, char **argv) { - string filename("data"); ofstream out; + srand(time(NULL)); + string filename(""); int nspins = 20; int niter = 1e3; double alpha = 0.3; - srand(time(NULL)); + SpinChain init = SpinChain::neel(nspins); for (int i=1;i qmc(VarProb(alpha), SpinChain::half(nspins)); + if (filename!="") out.open(filename.c_str()); + QMC qmc(VarProb(alpha), init); Energy en; int nacc = 0; @@ -432,13 +436,21 @@ int main (int argc, char **argv) { } accepted = qmc.step(); nacc += accepted?1:0; - // out << double(nacc)/(i) << " " << e/nspins << " " << esum/(i*nspins) << endl; + if (out.is_open()) out << i << " " << double(nacc)/(i) << " " << e/nspins << " " << esum/(i*nspins) << "\n"; } - cout << qmc.state() << endl; - cout << alpha << " " << (esum/(niter*nspins)) << endl; - for (int j=0;j