27 ifstream f(filename,ios::in);
31 while(getline(f, buffer))
33 buffer = trim(buffer);
35 npos = buffer.find(tag);
36 if(npos != string::npos) alpha = ReadDataFromLine(buffer,tag,npos);
38 npos = buffer.find(tag);
39 if(npos != string::npos) lmean = ReadDataFromLine(buffer,tag,npos);
41 npos = buffer.find(tag);
42 if(npos != string::npos) lmax = ReadDataFromLine(buffer,tag,npos);
44 npos = buffer.find(tag);
45 if(npos != string::npos) tfn = ReadDataFromLine(buffer,tag,npos);
47 npos = buffer.find(tag);
48 if(npos != string::npos) bsigma = ReadOneDataFromLine(buffer,tag,npos);
50 npos = buffer.find(tag);
51 if(npos != string::npos) lambda_au = ReadDataFromSeveralLines(f,5);
53 npos = buffer.find(tag);
54 if(npos != string::npos) lambda_as = ReadDataFromSeveralLines(f,5);
56 npos = buffer.find(tag);
57 if(npos != string::npos) t_thresh = ReadOneDataFromLine(buffer,tag,npos);
59 npos = buffer.find(tag);
60 if(npos != string::npos) ppl = ReadPPLFromLine(buffer,tag,npos);
62 npos = buffer.find(tag);
63 if(npos != string::npos) ppt = ReadPPTFromLine(buffer,tag,npos);
65 npos = buffer.find(tag);
66 if(npos != string::npos) ilambda = ReadIndexFromLine(buffer,tag,npos);
68 npos = buffer.find(tag);
69 if(npos != string::npos) iT = ReadIndexFromLine(buffer,tag,npos);
75 cerr <<
"fichier: " << filename <<
" inexistant!" << endl;
84void PrePostNN::display(
string tag,vector<double> vec)
87 for(
unsigned int i=0; i<vec.size(); i++)
88 cout << vec[i] <<
" ";
92void PrePostNN::display(
string tag,vector<int> vec)
95 for(
unsigned int i=0; i<vec.size(); i++)
96 cout << vec[i] <<
" ";
100void PrePostNN::display(
string tag,vector<vector<double>> mat)
103 for(
unsigned int i=0; i<mat.size(); i++)
105 for(
unsigned int j=0; j<mat[i].size(); j++)
106 cout << mat[i][j] <<
" ";
111string PrePostNN::trim(
const std::string& str,
const std::string& whitespace)
113 const auto strBegin = str.find_first_not_of(whitespace);
114 if (strBegin == std::string::npos)
117 const auto strEnd = str.find_last_not_of(whitespace);
118 const auto strRange = strEnd - strBegin + 1;
120 return str.substr(strBegin, strRange);
123vector<double> PrePostNN::ReadDataFromLine(
string buffer,
string tag,
size_t npos)
131 sval = buffer.substr(npos+ltag,buffer.length()-ltag);
132 istringstream iss(sval);
142double PrePostNN::ReadOneDataFromLine(
string buffer,
string tag,
size_t npos)
149 sval = buffer.substr(npos+ltag,buffer.length()-ltag);
150 istringstream iss(sval);
156enum pp_T PrePostNN::ReadPPTFromLine(
string buffer,
string tag,
size_t npos)
160 enum pp_T ret = INDEFT;
163 tmp = buffer.substr(npos+ltag,buffer.length()-ltag);
164 tmp.erase(remove(tmp.begin(), tmp.end(),
' '), tmp.end());
166 if( tmp.compare(
"TR") == 0 ) ret = TR;
167 else if( tmp.compare(
"TF") == 0 ) ret = TF;
172enum pp_lambda PrePostNN::ReadPPLFromLine(
string buffer,
string tag,
size_t npos)
176 enum pp_lambda ret = INDEFL;
179 tmp = buffer.substr(npos+ltag,buffer.length()-ltag);
180 tmp.erase(remove(tmp.begin(), tmp.end(),
' '), tmp.end());
182 if( tmp.compare(
"LNORM") == 0 ) ret = LNORM;
183 else if( tmp.compare(
"LU") == 0 ) ret = LU;
184 else if( tmp.compare(
"LUS") == 0 ) ret = LUS;
189vector<int> PrePostNN::ReadIndexFromLine(
string buffer,
string tag,
size_t npos)
197 sval = buffer.substr(npos+ltag,buffer.length()-ltag);
198 istringstream iss(sval);
208vector<vector<double>> PrePostNN::ReadDataFromSeveralLines(ifstream& f,
int nblines)
210 vector<vector<double>> ret;
214 for(
int i=0; i<nblines; i++)
217 tmp = ReadDataFromLine(buffer,
"",0);
226 display(
"ALPHA:",alpha);
227 display(
"LAMBDA_MEAN:",lmean);
228 display(
"LAMBDA_MAX:",lmax);
229 display(
"LAMBDA_AU:",lambda_au);
230 display(
"LAMBDA_AS:",lambda_as);
231 display(
"T_FN:",tfn);
232 cout <<
"B_SIGMA: " << bsigma << endl;
233 cout <<
"T_THRESH: " << t_thresh << endl;
234 cout <<
"PP_LAMBDA:" <<
" " << (
unsigned int) ppl << endl;
235 cout <<
"PP_T:" <<
" " << (
unsigned int) ppt << endl;
236 display(
"ILAMBDA:",ilambda);
PrePostNN(string filename)
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.