using namespace std; #include #include #include #include #include #include int main(int argc, char **argv) { double avg, dev; double tmp; int i, j, col, zaehler; int ecut; int flag; string zeile; stringstream line; if (argc < 4) { cout << "Usage: " << argv[0] << " ...\n"; return(1); } line.str(argv[1]); line >> col; line.clear(); line.str(argv[2]); line >> ecut; cout << "Using " << col << " with Ecut of " << ecut << "." << endl; // get average avg = 0.; zaehler=0; for (i=3;i> ws >> tmp; if (tmp==(double)ecut) { // found correct line! for (j=col;j>0;j--) if (!input.eof()) input >> ws >> tmp; else flag=0; //cout << tmp << "\n"; avg += tmp; } //else cout << " skipping\n"; } zaehler+=flag; test.close(); } if (zaehler != 0) avg /= zaehler; // get deviation dev = 0.; zaehler=0; for (i=3;i> ws >> tmp; if (tmp==(double)ecut) { // found correct line! for (j=col;j>0;j--) if (!input.eof()) input >> ws >> tmp; else flag=0; //cout << tmp << "\n"; dev += pow(tmp - avg, 2); } } zaehler+=flag; test.close(); } //dev = 1/(zaehler)*dev; dev /= zaehler; cout << setprecision(8) << avg << "\t" << setprecision(8) << sqrt(dev) << "\n"; return(0); }