Last change
on this file since e34098 was 5a84ee, checked in by Frederik Heber <heber@…>, 15 years ago |
Rewrite of average.cpp and added first UnitTest.
- average.cpp is now called averager.cpp and uses a function AverageColumns().
- new function AverageColumns(): takes an input streamd and a set of column indices for which averages shall be computed
- Introduced unit tests to Utils part of ESPACK:
- new unit test AverageColumnsUnitTest testing the above.
- Makefile generation introduced into configure.ac
- subdir forked in Makefile.am
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | /*
|
---|
2 | * averager.cpp
|
---|
3 | *
|
---|
4 | * Created on: Apr 15, 2010
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | using namespace std;
|
---|
9 |
|
---|
10 | #include <iostream>
|
---|
11 | #include <iomanip>
|
---|
12 | #include <fstream>
|
---|
13 | #include <sstream>
|
---|
14 | #include <string>
|
---|
15 |
|
---|
16 |
|
---|
17 | #include "average.hpp"
|
---|
18 | #include "version.h"
|
---|
19 |
|
---|
20 | int main(int argc, char **argv) {
|
---|
21 | MeanErrorMap *Results = NULL;
|
---|
22 | IndexSet Columns;
|
---|
23 | int col;
|
---|
24 | int skiplines=0;
|
---|
25 | string zeile;
|
---|
26 | stringstream line;
|
---|
27 |
|
---|
28 | cout << ESPACKVersion << endl;
|
---|
29 |
|
---|
30 | if (argc <= 2) {
|
---|
31 | cout << "Usage: " << argv[0] << " <column (zero-based)> <data file> [#skip initial lines]\n";
|
---|
32 | return(1);
|
---|
33 | }
|
---|
34 | {
|
---|
35 | line.str(argv[1]);
|
---|
36 | line >> col;
|
---|
37 | cout << "Using column " << col << "." << endl;
|
---|
38 | Columns.insert(col);
|
---|
39 | line.clear();
|
---|
40 | }
|
---|
41 | if (argc > 3) {
|
---|
42 | line.str(argv[3]);
|
---|
43 | line >> skiplines;
|
---|
44 | cout << "Will skip first " << skiplines << " lines." << endl;
|
---|
45 | line.clear();
|
---|
46 | }
|
---|
47 | ifstream test(argv[2]);
|
---|
48 | if (test == NULL) {
|
---|
49 | cout << "Can't open File " << argv[2] << "\n";
|
---|
50 | return(255);
|
---|
51 | } else {
|
---|
52 | // skip initial lines
|
---|
53 | for (;skiplines>0;skiplines--)
|
---|
54 | getline(test, zeile, '\n');
|
---|
55 | // call average function and print result
|
---|
56 | if (!test.eof()) {
|
---|
57 | Results = AverageColumns(test, Columns);
|
---|
58 | cout << "Mean\tStd_deviation" << endl;
|
---|
59 | for (MeanErrorMap::const_iterator Runner = Results->begin(); Runner != Results->end(); ++Runner)
|
---|
60 | cout << Runner->second.first << "\t" << Runner->second.second << endl;
|
---|
61 | delete(Results);
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | return(0);
|
---|
66 | }
|
---|
67 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.