Changeset 2265 in Sophya for trunk/SophyaPI/PIext/piacmd.cc
- Timestamp:
- Nov 15, 2002, 12:58:41 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/piacmd.cc
r2263 r2265 1233 1233 } 1234 1234 1235 int Sum_RPNStack_(stack<double>& s, double& sx, double& sx2, string& line) 1236 { 1237 sx = sx2 = 0.; 1238 int nn = 0; 1239 double x = 0.; 1240 while( !s.empty() ) { 1241 x = s.top(); s.pop(); 1242 sx += x; sx2 += x*x; 1243 nn++; 1244 } 1245 return(nn); 1246 } 1247 1248 int Product_RPNStack_(stack<double>& s, double& px, string& line) 1249 { 1250 px = 1.; 1251 int nn = 0; 1252 double x = 0.; 1253 while( !s.empty() ) { 1254 x = s.top(); s.pop(); 1255 px *= x; nn++; 1256 } 1257 return(nn); 1258 } 1235 1259 1236 1260 /* --Methode-- */ … … 1329 1353 if ( Check_myRPNStack_(rpnstack, x, y, line) ) return(1); 1330 1354 rpnstack.top() = atan2(x,y); 1355 } 1356 // Fonction a N arguments - Somme, produit, etc ... 1357 else if ((args[k] == "sum") || (args[k] == "mean") || 1358 (args[k] == "sigma") || (args[k] == "sigma2") ) { 1359 double sx, sx2; 1360 int nn = Sum_RPNStack_(rpnstack, sx, sx2, line); 1361 if (args[k] == "sum") rpnstack.push(sx); 1362 else { 1363 if (nn == 0) { 1364 cerr << "PIACmd::EvalRPNExpr: mean/sigma error- RPN stack empty: " 1365 << line << endl; 1366 return(1); 1367 } 1368 double fnn = nn; 1369 if (args[k] == "mean") rpnstack.push(sx/fnn); 1370 else if (args[k] == "sigma2") rpnstack.push(sx2/fnn-(x*x/(fnn*fnn))); 1371 else rpnstack.push(sqrt(sx2/fnn-(x*x/(fnn*fnn)))); 1372 } 1373 } 1374 else if (args[k] == "product") { 1375 double px; 1376 int nn = Product_RPNStack_(rpnstack, px, line); 1377 if (nn == 0) { 1378 cerr << "PIACmd::EvalRPNExpr: product error- RPN stack empty: " 1379 << line << endl; 1380 return(1); 1381 } 1382 rpnstack.push(px); 1331 1383 } 1332 1384 // Fonctions de manipulation de stack
Note:
See TracChangeset
for help on using the changeset viewer.