From 598e7fc8e98f218993bf07a7b6cc39539d8f7690 Mon Sep 17 00:00:00 2001 From: Mauro Iazzi Date: Fri, 31 Jul 2009 13:00:57 +0200 Subject: [PATCH] last bunch of changes before jump to new version --- Makefile | 2 +- analyze.cpp | 0 compute_weights.cpp | 20 ++++++++++++++------ main.cpp | 9 +++++---- 4 files changed, 20 insertions(+), 11 deletions(-) mode change 100644 => 100755 Makefile mode change 100644 => 100755 analyze.cpp mode change 100644 => 100755 compute_weights.cpp mode change 100644 => 100755 main.cpp diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index 8075fff..87cd421 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ main: .main.dep main.o clean: make -C $(LUA) clean - rm -f main main.o + rm -f main main.o analyze.o compute_weights.o .PHONY: clean default all diff --git a/analyze.cpp b/analyze.cpp old mode 100644 new mode 100755 diff --git a/compute_weights.cpp b/compute_weights.cpp old mode 100644 new mode 100755 index db93ee9..0c35a8a --- a/compute_weights.cpp +++ b/compute_weights.cpp @@ -33,7 +33,7 @@ using namespace std; -void analyze_data_file (std::string filename, std::ostream& out, const int len, double c) { +void analyze_data_file (std::string filename, std::ostream& out, const int len, double c, bool use_log = true) { int n = 0; double *v = new double[len]; int i = 0; @@ -49,16 +49,23 @@ void analyze_data_file (std::string filename, std::ostream& out, const int len, if (line_string[0]=='#') { out << line_string << "\n"; } else if (line_string.size()!=0) { - double nw = 0.0; + double nw = use_log?0.0:1.0; line >> state >> energy >> weight; - weight = std::log(weight); + if (use_log) { + weight = std::log(weight) - c; + } else { + weight = weight * std::exp(-c); + } out << state << " " << energy; - weight -= c; v[i] = weight; for (int j=0;j