-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix_tool.cpp
104 lines (83 loc) · 3.5 KB
/
matrix_tool.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// std includes
#include <numeric>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <limits>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/assign/std/vector.hpp>
#include <boost/assign/std/set.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
namespace io = boost::iostreams;
#include <tclap/CmdLine.h>
#include "q_matrix.h"
#include "state.h"
int main (int argc, char *argv[])
{
std::string file1, file2, command, out_filename;
try
{
using namespace boost::assign;
TCLAP::CmdLine cmd("q_matrix", ' ', "0.9");
std::vector<std::string> allowed_commands_vec;
allowed_commands_vec += "compare","dos";
TCLAP::ValuesConstraint<std::string> allowed_commands(allowed_commands_vec);
TCLAP::UnlabeledValueArg<std::string> commandArg("command","Command to be executed",true,"", &allowed_commands, cmd);
TCLAP::UnlabeledValueArg<std::string> file1Arg("file1","Filename of the first parQ dat file",true,"","filename", cmd);
TCLAP::UnlabeledValueArg<std::string> file2Arg("file2","Filename of the second parQ dat file.\nLeave empty to use the first twice.",false,"","filename", cmd);
TCLAP::ValueArg<std::size_t> nminArg("","nmin","Minimum number of particles.",false,0,"int", cmd);
TCLAP::ValueArg<std::size_t> nmaxArg("","nmax","Maximum number of particles.",false,0,"int", cmd);
TCLAP::ValueArg<std::size_t> nEnergyArg("","nEnergy","Number of Energy bins. = 500",false,500,"int", cmd);
TCLAP::ValueArg<double> eminArg("","emin","Minimum energy.",false,-700.0,"float", cmd);
TCLAP::ValueArg<double> emaxArg("","emax","Maximum energy.",false,20.0,"float", cmd);
TCLAP::ValueArg<double> volumeArg("","volume","Box volume.",false,125.0,"float", cmd);
TCLAP::ValueArg<std::string> outArg("o","out","Filename for serialized output.",false,"","filename.gz", cmd);
commandArg.requires("dos") += &nminArg, &nmaxArg, &nEnergyArg, &eminArg, &emaxArg, &volumeArg;
cmd.parse( argc, argv );
command = commandArg.getValue();
file1 = file1Arg.getValue();
file2 = file2Arg.getValue();
State::lease s;
s->set_min_particles(nminArg.getValue());
s->set_max_particles(nmaxArg.getValue());
s->set_min_energy(eminArg.getValue());
s->set_max_energy(emaxArg.getValue());
s->set_n_energy(nEnergyArg.getValue());
s->set_volume(volumeArg.getValue());
out_filename = outArg.getValue();
}
catch (TCLAP::ArgException &e) // catch any exceptions
{
std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
return -1;
}
if (command == "compare") {
std::size_t nParticles(State::instance->n_particles());
std::size_t nEnergy(State::instance->n_energy());
QMatrix<uint32_t> q(nParticles,nParticles,nEnergy,nEnergy);
QMatrix<double> qD1(nParticles,nParticles,nEnergy,nEnergy);
QMatrix<double> qD2(nParticles,nParticles,nEnergy,nEnergy);
std::cerr << "reading 1" << std::endl;
gzFile parq_file_1 = q.read_file(file1, 10000000);
qD1.stochastic_from(q);
q.clear();
std::cerr << "reading 2" << std::endl;
if (file2 != "") {
q.read_file(file2, 10000000);
} else {
q.read_file(parq_file_1, 10000000);
}
qD2.stochastic_from(q);
qD1 -= qD2;
qD1.print();
} else if (command == "dos") {
} else {
std::cout << "Error: unknown command." << std::endl;
return -1;
}
return 0;
}