diff --git a/.gitignore b/.gitignore index 8531fbd55f33726807bb59e7319fadc9d1064988..f959ac7844162e3603bc2f29898e25a14e04def3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ *.so *.so.* *.swp +*.bak html/ frida2-*/ frida diff --git a/pub/CHANGELOG b/pub/CHANGELOG index 924349e50b135608c0b24db4190e15a3a7c2bfb1..60e52545cfea1a95c43b3b345cb7453ee5fc83a9 100644 --- a/pub/CHANGELOG +++ b/pub/CHANGELOG @@ -5,6 +5,7 @@ Release 2.1.7c of , comes with fridalibs- - code cleanup - some steps towards cpplint compliance - correct comment header: FRIDA expands to "fast reliable", period. + - data type "uint" eliminated Release 2.1.7b of 18feb13, comes with fridalibs-130218: diff --git a/pub/src/calc.cpp b/pub/src/calc.cpp index 9e37abb6da2a4f7900c01d85fd1dbee91fa9b628..3b51295ad1a74d1b2894a198e24c980504b15ad4 100644 --- a/pub/src/calc.cpp +++ b/pub/src/calc.cpp @@ -35,7 +35,7 @@ void NCalc::Calculator( string s ) printf( "\n" ); } else { while ( (fiter()) ) { - uint k = fiter.k(); + int k = fiter.k(); T->tree_point_val( &ret, &dret, k ); if ( fiter.size()>1 ) printf( "f%d: ", k ); diff --git a/pub/src/calc.h b/pub/src/calc.h index e5793759694dca465e185a9c987a2d84bf890c0c..7a4ba220e223fe770b3d97f6a88d584c244c1454 100644 --- a/pub/src/calc.h +++ b/pub/src/calc.h @@ -11,4 +11,4 @@ namespace NCalc { void Calculator( string expr ); -}; +} diff --git a/pub/src/commands.cpp b/pub/src/commands.cpp index e8fb7b138bacf96852ff2580cec5ebf22e428eff..2f979fa2be48a2da7be7395768bc045c9f796f61 100644 --- a/pub/src/commands.cpp +++ b/pub/src/commands.cpp @@ -40,7 +40,7 @@ bool fridaCommand( string cmd ) { - uint i; + int i; // Extract overwrite marker: NOlm::overwrite = 0; @@ -340,7 +340,7 @@ bool fridaCommand( string cmd ) NPloWin::Plots[NPloWin::iPlot]->writePostscript( ps_outdir, ps_head, ps_dict ); } else if ( cmd == "gw" ) { - for( uint i=0; i<NPloWin::nPlot; ++i ){ + for( int i=0; i<NPloWin::nPlot; ++i ){ printf( " %c %1i %s\n", i==NPloWin::iPlot ? '*' : ' ', i, NPloWin::Plots[i]->info().c_str() ); } diff --git a/pub/src/coord.cpp b/pub/src/coord.cpp index c47491d92d363eed628836c18c567a9cb450d28d..4729a0d02bf38e09bd65971508eb7c7e86e32447 100644 --- a/pub/src/coord.cpp +++ b/pub/src/coord.cpp @@ -29,11 +29,11 @@ using namespace std; CCoord::CCoord( const string in ) { - uint i, j, np, n; + int i, j, np, n; n = in.size(); if (in[n-1]!=')') throw "input must terminate with ')'"; - for(j=n-2, np=1; j!=(uint)-1; j--) { + for(j=n-2, np=1; j!=(int)-1; j--) { if (in[j]==')') np++; else if (in[j]=='(') { @@ -73,13 +73,13 @@ void CCoord::ask_and_set( const string& quest ) cout << "just press ENTER to let current value unchanged [" << str_std() << "]\n"; } else { - uint i, j, np, n; + int i, j, np, n; n = resp.size(); if (resp[n-1]!=')') { cout << "input must terminate with ')'\n"; continue; } - for(j=n-2, np=1; j!=(uint)-1; j--) { + for(j=n-2, np=1; j!=(int)-1; j--) { if (resp[j]==')') np++; else if (resp[j]=='(') { @@ -113,7 +113,7 @@ string CCoord::str_std() const //! Compact string for use in tables. -string CCoord::str_compact( int maxlen ) const +string CCoord::str_compact( size_t maxlen ) const { string ret = name + "(" + unit + ")"; if ( maxlen==0 || ret.length()<=maxlen ) diff --git a/pub/src/coord.h b/pub/src/coord.h index 59e8f03a1ab6ad1e8f7c3b9b10c08e29529f364c..80a7a902ef7fac0c3cf194b11b013c7feda786f1 100644 --- a/pub/src/coord.h +++ b/pub/src/coord.h @@ -22,7 +22,7 @@ class CCoord { friend ostream& operator<< (ostream &s, CCoord C); string str_std() const; - string str_compact( int maxlen=0 ) const; + string str_compact( size_t maxlen=0 ) const; string str_ps() const; string to_a01() const; bool defined() { return name!=""; }; diff --git a/pub/src/curve.cpp b/pub/src/curve.cpp index 479ab3f5eaab3ba6a39625fb5096a6bea993c755..ee40453147c5515c9a2d8360286a90d14903d47f 100644 --- a/pub/src/curve.cpp +++ b/pub/src/curve.cpp @@ -53,7 +53,7 @@ namespace NCurveFile int numint_mode=4; double numint_epsabs=1e-10; double numint_epsrel=1e-10; -}; +} bool allow_slow_conv = true; @@ -67,7 +67,7 @@ namespace NFitTune { int nPrint=0; int mFitMetric=2; double maxtime = 3; -}; +} //***************************************************************************// @@ -80,7 +80,7 @@ namespace NFitTune { void COlc::curveDefaults() { - for( uint ip=0; ip<nP; ip++ ) + for( int ip=0; ip<nP; ip++ ) PCo.push_back( CCoord("p" + S(ip), "") ); weighing = COlc::_ERR; } @@ -148,7 +148,7 @@ void COlc::askCurve( const string& quest ) //! Vectorial evaluation of a curve given by an expression tree. void COlc::curve_val_vec_expr( - vector<double>* ret, const vector<double>& vt, uint k, uint j ) const + vector<double>* ret, const vector<double>& vt, int k, int j ) const { CResult val; CContext ctx( k, j ); @@ -156,7 +156,7 @@ void COlc::curve_val_vec_expr( T->tree_val( val, ctx ); if ( val.vectorial ) throw "BUG: tree_curve_val did not get scalar result"; - for( uint i=0; i<ret->size(); ++i ) + for( size_t i=0; i<ret->size(); ++i ) (*ret)[i] = val.r; } else { ctx.request_VT( &vt ); @@ -171,7 +171,7 @@ void COlc::curve_val_vec_expr( //! Vectorial evaluation of a curve given by a system call. void COlc::curve_val_vec_syst( - vector<double>* ret, const vector<double>& vt, uint k, uint j ) const + vector<double>* ret, const vector<double>& vt, int k, int j ) const { // Create FIFO to receive return values. // TODO: choose name as: triv::next_tmp_file( "/tmp/frida.%d" ); @@ -196,7 +196,7 @@ void COlc::curve_val_vec_syst( // Parameters passed on command line. if ( scrInpMode==_CMDLIN ){ string pars = ""; - for ( uint ip=0; ip<nP; ++ip ) + for ( int ip=0; ip<nP; ++ip ) pars += " " + str( format("%g ") % VC(j)->P[ip] ); cmd += pars; } @@ -219,7 +219,7 @@ void COlc::curve_val_vec_syst( if ( scrInpMode==_STDIN ){ string out = str( format("%i ") % nP ); write( par_fifo, out.c_str(), out.size() ); - for ( uint ip=0; ip<nP; ++ip ) { + for ( int ip=0; ip<nP; ++ip ) { string out = str( format("%g ") % VC(j)->P[ip] ); write( par_fifo, out.c_str(), out.size() ); } @@ -227,7 +227,7 @@ void COlc::curve_val_vec_syst( if ( evaMode==_SCR ) { string out = str( format("%i ") % vt.size() ); write( par_fifo, out.c_str(), out.size() ); - for ( uint i=0; i<vt.size(); ++i ) { + for ( size_t i=0; i<vt.size(); ++i ) { string out = str( format("%g ") % vt[i] ); write( par_fifo, out.c_str(), out.size() ); } @@ -241,7 +241,7 @@ void COlc::curve_val_vec_syst( throw "BUG: cannot read results of system call"; if ( evaMode==_SCR ) { - for ( uint i=0; i<vt.size(); ++i ) { + for ( size_t i=0; i<vt.size(); ++i ) { double x; if ( fscanf( F, "%lg %lg\n", &x, &((*ret)[i]) )!=2 ) throw errmsg + " returns no x y pair for t["+S(i)+"]="+S(vt[i]); @@ -267,7 +267,7 @@ void COlc::curve_val_vec_syst( //! Evaluate a curve, vectorial version. Used in fitting and in plotting. void COlc::curve_val_vec( vector<double>* ret, const vector<double>& vt, - uint k, uint j ) const + int k, int j ) const // input: the function arguments vt[], and the context k, j // output: the curve evaluation result *ret[] { @@ -289,7 +289,7 @@ void COlc::curve_val_vec( vector<double>* ret, const vector<double>& vt, //! Dito, scalar version, to obtain isolated points. -double COlc::curve_val_sca( double farg, uint k, uint j ) const +double COlc::curve_val_sca( double farg, int k, int j ) const { vector<double> vt(1, farg), res(1); curve_val_vec( &res, vt, k, j ); @@ -322,7 +322,7 @@ void NCurveFile::CreateFitcurve() fout->ZCo = fd->ZCo; fout->RPar = fd->RPar; fout->lDoc.push_back( "cc " + fc->expr + " # z from " + fd->name ); - for (uint j=0; j<fd->nJ(); j++) { + for (int j=0; j<fd->nJ(); j++) { PCurve sout( new CCurve ); sout->z = fd->VS(j)->z; sout->P = P; @@ -367,19 +367,19 @@ void NCurveFile::ChangeExpr() NOlm::IterateC fiter; while( POlc fc = fiter() ) { - uint nPold = fc->nP; + int nPold = fc->nP; fc->expr = ftmp->expr; fc->T = ftmp->T; fc->nP = ftmp->nP; fc->lDoc.push_back( "cm " + ftmp->expr ); fc->PCo.resize(fc->nP); - for( uint ip=nPold; ip<fc->nP; ip++ ){ + for( int ip=nPold; ip<fc->nP; ip++ ){ fc->PCo[ip] = CCoord("p" + S(ip), ""); } - for (uint j=0; j<fc->nJ(); j++) { + for (int j=0; j<fc->nJ(); j++) { fc->VC(j)->P.resize( fc->nP ); fc->VC(j)->fixed.resize( fc->nP, false ); - for( uint ip=nPold; ip<fc->nP; ip++ ) + for( int ip=nPold; ip<fc->nP; ip++ ) fc->VC(j)->P[ip] = 1.0; } } @@ -429,11 +429,11 @@ void NCurveFile::ParsAbs() NOlm::IterateC fiter; while( POlc f=fiter() ) { pLis.evaluate( 0, f->nP-1 ); - for ( uint j=0; j<f->nJ(); j++ ) { + for ( int j=0; j<f->nJ(); j++ ) { if ( f->V[j]->protect ) continue; - for( uint iv=0; iv<pLis.size(); ++iv ) { - uint ip = pLis.V[iv]; + for( int iv=0; iv<pLis.size(); ++iv ) { + int ip = pLis.V[iv]; f->VC(j)->P[ip] = fabs( f->VC(j)->P[ip] ); } } @@ -456,18 +456,18 @@ void NCurveFile::ParsCopy() NOlm::IterateC fiter; while( POlc f = fiter() ) { pLis.evaluate( 0, f->nP-1 ); - for ( uint j=0; j<f->nJ(); j++ ) { + for ( int j=0; j<f->nJ(); j++ ) { if ( f->V[j]->protect ) continue; CContext ctx( fiter.k(), j ); - uint j2, k2; + int j2, k2; Tk->tree_uival( &k2, ctx ); Tj->tree_uival( &j2, ctx ); POlc f2 = NOlm::mem_get_C( k2 ); if( j2>=f2->nJ() ) throw "no curve " + S(j2) + " in file " + S(k2); - for( uint iv=0; iv<pLis.size(); ++iv ) { - uint ip = pLis.V[iv]; + for( int iv=0; iv<pLis.size(); ++iv ) { + int ip = pLis.V[iv]; if( ip>=f2->nP ) throw "no p" + S(ip) + " in file " + S(k2); f->VC(j)->P[ip] = f2->VC(j2)->P[ip]; @@ -532,11 +532,11 @@ string COlc::infoScanHeader() const string lin; // z's and parameters: lin = "j "; - for ( uint iz=0; iz<nZ(); iz++ ) { + for ( int iz=0; iz<nZ(); iz++ ) { snprintf( wrd, PINFO_WRD_SIZ, "z%i ", iz ); lin += wrd; } - for ( uint ip=0; ip<nP; ip++ ) { + for ( int ip=0; ip<nP; ip++ ) { snprintf( wrd, PINFO_WRD_SIZ, "p%d ", ip ); lin += wrd; } @@ -549,10 +549,10 @@ string COlc::pInfoCat() const { vector<string> vs = infoFile(); vs.push_back( infoScanHeader() ); - for( uint j=0; j<nJ(); j++ ) + for( int j=0; j<nJ(); j++ ) vs.push_back( infoLine( j ) ); string ret = ""; - for( int i=0; i<vs.size(); ++i ) + for( size_t i=0; i<vs.size(); ++i ) ret += vs[i] + "\n"; return ret; } @@ -571,8 +571,8 @@ void NCurveFile::SetFixed( bool fix ) while( POlc fc = fiter() ) { CList lis( sel, 0, fc->nP-1 ); - for( uint iv=0; iv<lis.size(); ++iv ) { - for( uint j=0; j<fc->nJ(); ++j ){ + for( int iv=0; iv<lis.size(); ++iv ) { + for( int j=0; j<fc->nJ(); ++j ){ if ( fc->V[j]->protect ) continue; fc->VC(j)->fixed[lis.V[iv]] = fix; @@ -607,7 +607,7 @@ void NCurveFile::SetFileReference( const string& which ) } while ( POlc fc = fiter() ) { - uint k = fiter.k(); + int k = fiter.k(); if ( which=="v-" ) fc->kconv = -1; else if ( expr=="" ) { @@ -617,7 +617,7 @@ void NCurveFile::SetFileReference( const string& which ) cout << format( "; convolute with %-2d" ) % fc->kconv; cout << "\n"; } else { - uint lval; + int lval; CContext ctx( k ); T->tree_uival( &lval, ctx ); NOlm::mem_get_D( lval ); // assert that it is a data file @@ -636,12 +636,12 @@ void NCurveFile::SetFileReference( const string& which ) //! Lookup data file and spectrum to be used as resolution. -void NCurveFile::setConv( PSpec *sv, uint *kv, uint *jv, uint k, uint j ) +void NCurveFile::setConv( PSpec *sv, int *kv, int *jv, int k, int j ) { // set *kv and *fv for given k: POlc fc = NOlm::mem_get_C(k); *kv = fc->kconv; - if( *kv==(uint)-1 ) { // no convolution + if( *kv==(int)-1 ) { // no convolution *jv = -1; // should not be needed return; } @@ -693,8 +693,8 @@ void NCurveFile::SetProperties( string which ) typedef struct { POld fd; POlc fc; - uint k; - uint j; + int k; + int j; double timeout; } FitDatTyp; @@ -719,8 +719,8 @@ void globalEvaluate( const double* par, int m_dat, const void *data, POld fd = mydata->fd; PCurve c = fc->VC(mydata->j); - uint ip = 0; - for( uint i=0; i<fc->nP; ++i ) + int ip = 0; + for( int i=0; i<fc->nP; ++i ) if ( !(fc->VC(mydata->j)->fixed[i]) ) c->P[i] = par[ip++]; @@ -731,7 +731,7 @@ void globalEvaluate( const double* par, int m_dat, const void *data, if ( fc->weighing==COlc::_ERR && s->dy.size()!=m_dat ) throw "missing error bars for weighing"; - for ( uint i=0; i<m_dat; i++) { + for ( int i=0; i<m_dat; i++) { if( fit[i]==INFINITY ) // TEMPORARY UNTIL exceptions can be // thrown everywhere @@ -782,10 +782,10 @@ void globalPrintout( int n_par, const double* par, int m_dat, const void *data, { if ( NFitTune::nPrint ) { printf( "fitmon (%i %i %i) %4i", printflags, iflag, nfev, iter ); - for( uint ip=0; ip<n_par; ++ip ) + for( int ip=0; ip<n_par; ++ip ) printf( " %19.11g", par[ip] ); double msd=0; - for( uint i=0; i<m_dat; ++i ) + for( int i=0; i<m_dat; ++i ) msd += fvec[i]*fvec[i]; printf( " -> %19.9g\n", msd ); } @@ -858,14 +858,14 @@ void NCurveFile::Fit( bool _allow_slow_conv ) if( fc->range_T ) { // overwrite fd with data that obye the range restriction: POld fdr( fd->new_old() ); - for ( uint j=0; j<fc->nJ(); j++ ) { + for ( int j=0; j<fc->nJ(); j++ ) { PSpec ein = fd->VS(j); PSpec eout = PSpec( new CSpec ); eout->copy_z_base( ein ); vector<double> range( ein->size() ); fc->range_T->tree_vec_val( &range, 0, fc->kd, j ); bool with_dy = ein->dy.size(); - for ( uint i=0; i<ein->size(); i++ ) { + for ( int i=0; i<ein->size(); i++ ) { if ( range[i] ) { if( with_dy ) eout->push_xyd( ein->x[i], ein->y[i], ein->dy[i] ); @@ -881,14 +881,14 @@ void NCurveFile::Fit( bool _allow_slow_conv ) data.fc = fc; data.fd = fd; - uint np = fc->nP; + int np = fc->nP; control = lm_control_double; control.epsilon = NFitTune::Epsilon; control.stepbound = NFitTune::Factor; control.maxcall = NFitTune::nCall; - for ( uint j=0; j<fc->nJ(); j++ ) { + for ( int j=0; j<fc->nJ(); j++ ) { if ( fc->V[j]->protect ) continue; data.j = j; @@ -897,22 +897,22 @@ void NCurveFile::Fit( bool _allow_slow_conv ) printf( "%3d", j ); D = fd->VS(j); C = fc->VC(j); - uint nd = D->size(); + int nd = D->size(); if ( !nd ){ printf( " empty data set\n" ); continue; } // handle fixed parameters: - uint npfree = 0; - for ( uint ip=0; ip<np; ++ip ) + int npfree = 0; + for ( int ip=0; ip<np; ++ip ) if( !fc->VC(j)->fixed[ip] ) ++npfree; if (npfree<=0) continue; Par.resize(npfree); - uint ipf=0; - for ( uint ip=0; ip<np; ip++ ) { + int ipf=0; + for ( int ip=0; ip<np; ip++ ) { if ( !fc->VC(j)->fixed[ip] ) Par[ipf++] = C->P[ip]; } @@ -936,7 +936,7 @@ void NCurveFile::Fit( bool _allow_slow_conv ) // Q: coefficient of determination R^2 (for linear regression) double ysum1 = 0, ysum2 = 0; - for( uint i=0; i<nd; ++i ){ + for( int i=0; i<nd; ++i ){ ysum1 += D->y[i]; ysum2 += SQR( D->y[i] ); } @@ -944,12 +944,12 @@ void NCurveFile::Fit( bool _allow_slow_conv ) C->Quality[1] = ydev2!=0 ? 1 - SQR(status.fnorm) / ydev2 : -1; // Q: mean deviation (chi^2 if fvec is weighed with 1/dy) - uint nfreedom = nd - npfree - 1; + int nfreedom = nd - npfree - 1; if( nfreedom<1 ) nfreedom = 1; C->Quality[2] = SQR(status.fnorm) / nfreedom; // print results: - for ( uint i=0; i<npfree; i++ ) + for ( int i=0; i<npfree; i++ ) printf(" %12g", Par[i]); printf( " (%3d->%9.7g)", status.nfev, C->Quality[NFitTune::mFitMetric] ); @@ -969,8 +969,8 @@ void NCurveFile::Fit( bool _allow_slow_conv ) typedef struct { POlc fc; - uint k; - uint j; + int k; + int j; } EvalDatTyp; @@ -1034,7 +1034,7 @@ void NCurveFile::IntegralProperty() if ( todo==" " ) return; else if ( todo=="*" ) { - uint maxP = 0; + int maxP = 0; while( (fin=fiter()) ){ if( fin->nP>maxP ) maxP = fin->nP; @@ -1043,7 +1043,7 @@ void NCurveFile::IntegralProperty() if( maxP==0 ) throw "no parameters in file(s)"; todo = ""; - uint ip=0; + int ip=0; while( 1 ){ todo += S(ip); if( ++ip==maxP ) @@ -1065,7 +1065,7 @@ void NCurveFile::IntegralProperty() todo = todo.erase( 0, ji+1 ); } - uint ip; + int ip; string label = mode; if ( mode=="i" ){ if( NRead::stack_empty() ) @@ -1086,7 +1086,7 @@ void NCurveFile::IntegralProperty() POld fout( new COld ); PSpec S; - uint nz = fin->ZCo.size(); + int nz = fin->ZCo.size(); bool savable = ( nz > 0 ); if( savable ){ @@ -1108,7 +1108,7 @@ void NCurveFile::IntegralProperty() bool newoutspec = true; - for (uint j=0; j<fin->nJ(); j++) { + for (int j=0; j<fin->nJ(); j++) { if( newoutspec ) { S = PSpec( new CSpec ); @@ -1195,7 +1195,7 @@ double NCurveFile::GridSum( POlc fc, int k, int j ) double ret = 0; ret = ((*xc)[1]-(*xc)[0])/2*yc[0]; ret += ((*xc)[n-1]-(*xc)[n-2])/2*yc[n-1]; - for ( uint i=1; i<n-1; ++i ) + for ( int i=1; i<n-1; ++i ) ret += ((*xc)[i+1]-(*xc)[i-1])/2*yc[i]; return ret; } @@ -1210,8 +1210,8 @@ double NCurveFile::GridSum( POlc fc, int k, int j ) typedef struct { POlc fc; - uint k; - uint j; + int k; + int j; double low; double hig; } CumDisDatTyp; @@ -1259,7 +1259,7 @@ void NCurveFile::CumulativeDistribution() fout->lDoc = fin->lDoc; fout->lDoc.push_back( "cumulative distribution" ); - for( uint j=0; j<fin->nJ(); j++ ){ + for( int j=0; j<fin->nJ(); j++ ){ PCurve c = fin->VC(j); PSpec s( new CSpec ); s->z = c->z; diff --git a/pub/src/curve.h b/pub/src/curve.h index f0b850f9aa67b24f0bf46824a6fa600256d76419..b58d7399fe5f960e364a82480e564fa2a3c1123f 100644 --- a/pub/src/curve.h +++ b/pub/src/curve.h @@ -28,9 +28,9 @@ namespace NCurveFile { void SetFitTuningPars( string which ); void Fit( bool _allow_slow_conv ); - void setConv( PSpec *sv, uint *kv, uint *jv, uint k, uint j ); + void setConv( PSpec *sv, int *kv, int *jv, int k, int j ); void SetIntTuningPars( string which ); void IntegralProperty(); void CumulativeDistribution(); -}; +} diff --git a/pub/src/defs.h b/pub/src/defs.h index 071589bed95e470dc395b1ceb47427592aec58c6..9662c017e85e2bc4ddf56e55744e21b6731e7456 100644 --- a/pub/src/defs.h +++ b/pub/src/defs.h @@ -12,6 +12,4 @@ #define SQR(a) ((a)*(a)) -#define uint unsigned int - using namespace std; diff --git a/pub/src/dualplot.cpp b/pub/src/dualplot.cpp index e16cc434b4f97ce11b47e3458cbb8385714cab97..3ca10344085d1c762fb38a1fa87cb5099c40896f 100644 --- a/pub/src/dualplot.cpp +++ b/pub/src/dualplot.cpp @@ -7,11 +7,9 @@ //! \file dualplot.cpp //! \brief collection NPlot of plot frames CPlot -#include <cstdlib> #include <cstdio> #include <cstring> #include <cmath> -#include <iostream> #include <string> #include <vector> #include <fcntl.h> @@ -31,7 +29,7 @@ static const int mLin = 80; // max num of chars in PostScript line //! Constructor for plot window: setup for gnuplot and postscript. -CPlot::CPlot( uint _iPlot, bool _logx, bool _logy ) : +CPlot::CPlot( int _iPlot, bool _logx, bool _logy ) : iPlot( _iPlot ), X( _logx ), Y( _logy ), maxpoints(20000), with_errors(true), equipoints(49), refine(true) { @@ -199,7 +197,7 @@ void CPlot::addSpec( bool as_line, bool new_style, int style_no, static int color[mColor] = { 0x880000, 0x008800, 0x000088, 0x006666, 0x660066, 0x666600 }; // Checks: - uint np=xp.size(); + size_t np=xp.size(); if ( !np ) throw "invalid call to CPLot::addSpec: no data points"; if ( np!=yp.size() ) @@ -218,8 +216,8 @@ void CPlot::addSpec( bool as_line, bool new_style, int style_no, FILE *gp_fd; if (!(gp_fd = fopen(gp_fnam.c_str(), "w"))) throw "cannot save gnuplot data to " + gp_fnam; - uint nout = 0; - for (uint i=0; i<np; i++){ + int nout = 0; + for (size_t i=0; i<np; i++){ if( std::isinf(xp[i]) || std::isinf(yp[i]) ) throw "Data point number " + S(i) + " is invalid: x=" + S(xp[i]) + ", y=" + S(yp[i]); @@ -242,7 +240,7 @@ void CPlot::addSpec( bool as_line, bool new_style, int style_no, if ( new_style ) { snprintf( outlin, mLin, "\n%3u [", ++ps_snum ); ps_accu.push_back( outlin ); - for (uint i=0; i<z.size(); i++){ + for (int i=0; i<z.size(); i++){ snprintf( outlin, mLin, " %12g", z[i]); ps_accu.push_back( outlin ); } @@ -259,7 +257,7 @@ void CPlot::addSpec( bool as_line, bool new_style, int style_no, } else { ps_accu.push_back( "\n" ); } - for (uint i=0; i<np; i++) { + for (int i=0; i<np; i++) { snprintf( outlin, mLin, "%6.3f %6.3f %6.3f t%c %% %13.7g wx %13.7g wy\n", X.pc(xp[i]), Y.pc(yp[i]), @@ -293,7 +291,7 @@ void CPlot::docTxLine( const string& line ) //! Add documentation line explaining a plot symbol to postscript output. -void CPlot::docPtTxLine( const string& line, uint num ) +void CPlot::docPtTxLine( const string& line, int num ) { ps_Doc.push_back( " " + S(num) + " {("+line+")} PtTxLine" ); } @@ -301,7 +299,7 @@ void CPlot::docPtTxLine( const string& line, uint num ) //! Add documentation line explaining a curve style to postscript output. -void CPlot::docCvTxLine( const string& line, uint num ) +void CPlot::docCvTxLine( const string& line, int num ) { ps_Doc.push_back( " " + S(num) + " {("+line+")} CvTxLine" ); } @@ -335,7 +333,7 @@ void CPlot::writePostscript( string ps_outdir, string ps_head, string ps_dict ) // append specific output to output file: if ( !(pssav = fopen( outf.c_str(), "a+" )) ) throw "cannot append contents to file " + outf; - for( uint i=0; i<ps_accu.size(); ++i ){ + for( size_t i=0; i<ps_accu.size(); ++i ){ // fprintf does not work here because output line may contain "%" fwrite( ps_accu[i].c_str(), 1, ps_accu[i].size(), pssav ); } @@ -343,7 +341,7 @@ void CPlot::writePostscript( string ps_outdir, string ps_head, string ps_dict ) // additional output (do not append this to ps_accu to allow // further incrementation of ps_accu): fprintf( pssav, "\n{ black 0 -4 13 1.65 NewList\n" ); - for ( uint i=0; i<ps_Doc.size(); i++ ) + for ( size_t i=0; i<ps_Doc.size(); i++ ) fprintf( pssav, "%s\n", ps_Doc[i].c_str() ); fprintf( pssav, "} oooinfo 1 eq { exec } { pop } ifelse\n" ); @@ -384,7 +382,7 @@ void CPlot::ps_ticktack( const vector<double>& Tacks, int ntpt, const double *ticklim, const CAxis *A ) { char outlin[ mLin ]; - uint i, ntack; + int i, ntack; ntack = Tacks.size(); if (ntack > 0 ) { ps_accu.push_back( " [\n" ); @@ -414,11 +412,11 @@ void CPlot::ps_ticktack( const vector<double>& Tacks, int ntpt, namespace NPloWin { vector<CPlot*> Plots; - uint nPlot; - uint iPlot; + int nPlot; + int iPlot; void initialize(); -}; +} //! Initialize default choice of plot windows. diff --git a/pub/src/dualplot.h b/pub/src/dualplot.h index e5994e40b3ef11328d5c7a570401e7cd2434187b..6696e651952cf1997ab3349d2456fd4f1d6d2084 100644 --- a/pub/src/dualplot.h +++ b/pub/src/dualplot.h @@ -13,16 +13,16 @@ class CPlot { public: - uint iPlot; ///< The index of this window in NPloWin::Plots. + int iPlot; ///< The index of this window in NPloWin::Plots. CAxis X, Y; // For data plotting: - uint maxpoints; + int maxpoints; bool with_errors; // For curve plotting: - uint equipoints; + int equipoints; bool refine; - CPlot( uint _iPlot, bool _logx, bool _logy ); + CPlot( int _iPlot, bool _logx, bool _logy ); void gp_write( string ); void clearFrame(); @@ -34,8 +34,8 @@ class CPlot { string xco, string yco, string info ); void showSpecs(); void docTxLine( const string& line ); - void docPtTxLine( const string& line, uint num ); - void docCvTxLine( const string& line, uint num ); + void docPtTxLine( const string& line, int num ); + void docCvTxLine( const string& line, int num ); void writePostscript( string ps_outdir, string ps_head, string ps_dict ); void setAux( string cmd ); string info() const; @@ -45,10 +45,10 @@ private: int gp_fno; string gp_fnames; - uint ps_fnum; // file - uint ps_snum; // spectrum - uint ps_pnum; // spectrum with pstyle - uint ps_cnum; // spectrum with cstyle + int ps_fnum; // file + int ps_snum; // spectrum + int ps_pnum; // spectrum with pstyle + int ps_cnum; // spectrum with cstyle void ps_ticktack( const vector<double>& Tacks, int ntpt, const double *ticklim, const CAxis *A ); vector<string> ps_Doc; @@ -60,8 +60,8 @@ private: namespace NPloWin { extern vector<CPlot*> Plots; ///< This vector holds all plot windows. - extern uint nPlot; ///< Must be kept equal to Plots.size(). - extern uint iPlot; ///< Index of currently active plot window. + extern int nPlot; ///< Must be kept equal to Plots.size(). + extern int iPlot; ///< Index of currently active plot window. void initialize(); -}; +} diff --git a/pub/src/edif.cpp b/pub/src/edif.cpp index dc292b42946390e5b607d1aaf0b8b14a85ba83ed..3869b0fef1d78db464213ccbf0240f8fb7286b64 100644 --- a/pub/src/edif.cpp +++ b/pub/src/edif.cpp @@ -67,7 +67,7 @@ void NEdif::ShowFiles() // prepare xytext string xytext; if( fd ) { - uint npts = fd->nPts(); + int npts = fd->nPts(); string txtpts; if (npts) txtpts = str( format( "%-6d" ) % npts ); @@ -96,15 +96,15 @@ void NEdif::ShowSpectra() printf(" "); POlc fc = P2C( f ); POld fd = P2D( f ); - for ( uint iz=0; iz<f->nZ(); iz++ ) { + for ( int iz=0; iz<f->nZ(); iz++ ) { printf(" %12s", f->ZCo[iz].str_compact().c_str()); } printf( "%8s %38s\n", "#pts.", "x" ); if( fd ) { - for ( uint j=0; j<f->nJ(); j++ ) { + for ( int j=0; j<f->nJ(); j++ ) { printf( "%3u%c", j, f->V[j]->protect ? '/' : ' ' ); - for ( uint iz=0; iz<f->nZ(); iz++ ) { + for ( int iz=0; iz<f->nZ(); iz++ ) { printf( " %12.6g", f->V[j]->z[iz] ); } printf( "%12.6g (%4u) %12.6g\n", @@ -127,7 +127,7 @@ void NEdif::ShowCoord() string out = str( format( "%3d" ) % fiter.k() ); out += " x: " + f->xco.str_compact(); out += " y: " + f->yco.str_compact(); - for ( uint i=0; i<f->nZ(); i++ ) { + for ( int i=0; i<f->nZ(); i++ ) { out += " z" + S(i) + ": " + f->ZCo[i].str_compact(); } cout << out << endl; @@ -142,13 +142,13 @@ void NEdif::ShowCoordZ() NOlm::IterateO fiter; POlo f = fiter(); // Get current coordinates: - uint k, nz, i; + int k; string act; vector<CCoord> ZCo = f->ZCo;; - nz = ZCo.size(); + size_t nz = ZCo.size(); if (nz) - for (i=0; i<nz; ++i) - printf(" %u: %s\n", i, ZCo[i].str_compact().c_str()); + for ( size_t i=0; i<nz; ++i) + printf(" %zu: %s\n", i, ZCo[i].str_compact().c_str()); else printf(" there are no z coordinates\n"); @@ -157,8 +157,7 @@ void NEdif::ShowCoordZ() k = fiter.k(); if ( f->ZCo.size()!=nz ) throw "file " + S(k) + " has different number of z coordinates"; - - for (i=0; i<nz; ++i) + for ( size_t i=0; i<nz; ++i) if ( f->ZCo[i]!=ZCo[i] ) throw "file " + S(k) + " has different z coordinate " + S(i); @@ -173,7 +172,7 @@ void NEdif::ShowNumpar() NOlm::IterateO fiter; while ( POlo f = fiter() ) { cout << "# file " << fiter.k() << ":\n"; - for ( uint m=0; m<f->RPar.size(); m++ ) { + for ( size_t m=0; m<f->RPar.size(); m++ ) { cout << " " << f->RPar[m].Co.str_compact() << ": " << f->RPar[m].val << "\n"; } @@ -189,7 +188,7 @@ void NEdif::ShowDoc() while( POlo f = fiter() ) { if( fiter.size()>1 ) cout << "# file " << fiter.k() << ":\n"; - for ( uint i=0; i<f->lDoc.size(); i++ ) + for ( size_t i=0; i<f->lDoc.size(); i++ ) cout << f->lDoc[i] << "\n"; } } @@ -281,7 +280,7 @@ void NEdif::EditDoc() ofstream Fo( fname.c_str() ); while ( f = fiter() ) { Fo << "### FILE " << fiter.k() << " " << f->name << " ###\n"; - for ( uint i=0; i<f->lDoc.size(); i++ ) + for ( size_t i=0; i<f->lDoc.size(); i++ ) Fo << f->lDoc[i] << "\n"; } Fo.close(); @@ -302,8 +301,8 @@ void NEdif::EditDoc() throw "invalid change in ### line: 'FILE' not found"; string aux; triv::string_extract_word( line.substr(9), &aux, &line ); - uint kin; - if ( !triv::any2uint( aux, &kin ) ) + int kin; + if ( !triv::any2int( aux, &kin ) ) throw "invalid change in ### line: file number not found"; if ( kin!=fiter.k() ) throw "invalid change in ### line: wrong file number"; @@ -326,12 +325,8 @@ void NEdif::EditDoc() void NEdif::DelNumpar() { + size_t iN = zask( "Index of numeric parameter to delete" ); NOlm::IterateO fiter; - - int iN = iask( "Number of numeric parameter to delete" ); - if( iN<0 ) - throw "invalid choice"; - while ( POlo f = fiter() ) { if( iN>=f->RPar.size() ) throw "file " + S( fiter.k() ) + " has no numpar n" + S(iN); @@ -454,7 +449,7 @@ void NEdif::ReadIn() } static int imcy_delta=0; - static uint imcy_last; + static int imcy_last; cout << "DEBUG "<< mInpZ << "\n"; if (mInpZ==2) { imcy_delta = iask("step in number of y column", imcy_delta); @@ -466,10 +461,10 @@ void NEdif::ReadIn() // *** loop over spectra *** - uint n = 0; - uint imcm; + int n = 0; + int imcm; string quest, line; - double val, zold; + double val, zold=NAN; vector<double> linv; int ns = 0; @@ -569,7 +564,7 @@ void NEdif::ReadIn() case 1: cout << "Enter " << n << " y values:\n"; s->y.resize(n); - for (uint i=0; i<n; i++) { + for (int i=0; i<n; i++) { quest = "x[" + S(i) + "] = " + S(s->x[i]) + " -> "; do { @@ -586,7 +581,7 @@ void NEdif::ReadIn() case 3: cout << "Enter " << n << " lines with y values:\n"; s->y.resize(n); - for (uint i=0; i<n; i++) { + for (int i=0; i<n; i++) { quest = "x[" + S(i) + "] =" + S(s->x[i]) + " -> "; while (1) { @@ -666,7 +661,7 @@ void NEdif::ReadTab( string qualif ) FILE *fd; string fdir, fshort, fext; - for( uint iF=0; iF<inFiles.size(); ++iF ) { + for( size_t iF=0; iF<inFiles.size(); ++iF ) { if( !(fd = fopen(inFiles[iF].c_str(), "r")) ) throw "cannot open file " + inFiles[iF]; cout << ".. reading from " << inFiles[iF] << "\n"; @@ -726,7 +721,7 @@ void NEdif::ReadTab( string qualif ) if( nblock==0 ){ // first header nzdat = zdat.size(); nz += nzdat; - for( uint iz=0; iz<nzdat; ++iz ) + for( int iz=0; iz<nzdat; ++iz ) fout->ZCo.push_back( CCoord("z"+S(iz), "") ); } else if( zdat.size() != nzdat ) throw "line " + S(n_in) + @@ -741,7 +736,7 @@ void NEdif::ReadTab( string qualif ) if( !horizontal ){ s = PSpec( new CSpec ); s->z.resize( nz ); - for( uint iz=0; iz<nzdat; ++iz ) + for( int iz=0; iz<nzdat; ++iz ) s->z[iz] = zdat[iz]; } nline = 0; @@ -767,11 +762,11 @@ void NEdif::ReadTab( string qualif ) if( horizontal ) { // new spectrum for every line s = PSpec( new CSpec ); s->z.resize( nz ); - for( uint iz=0; iz<nzdat; ++iz ) + for( int iz=0; iz<nzdat; ++iz ) s->z[iz] = zdat[iz]; // reactivate this in future z-y mode // s->z[nz-1] = nline; - for( int i=0; i<dat.size(); ++i ) + for( size_t i=0; i<dat.size(); ++i ) s->push_xy( (double)i, dat[i] ); fout->V.push_back(s); } else { // vertical @@ -845,7 +840,7 @@ void NEdif::MakeGrid() PSpec s( new CSpec ); s->x.resize(ni); - for( uint i=0; i<ni; ++i ) + for( int i=0; i<ni; ++i ) s->x[i] = ((double)i)/ni; s->y.clear(); s->y.resize( ni, 0. ); diff --git a/pub/src/edif.h b/pub/src/edif.h index de482cf940ba364dc79d413419af3ca6610aae13..57b4d7c7303caee834391931a5d2044b49c763b6 100644 --- a/pub/src/edif.h +++ b/pub/src/edif.h @@ -25,4 +25,4 @@ namespace NEdif { void ReadIn(); void ReadTab( string qualif ); void MakeGrid(); -}; +} diff --git a/pub/src/expr.cpp b/pub/src/expr.cpp index 79aad5ac387de19e98a7a509a318a1317ac2a0ca..611d81efa918a7fcf7bfa99f778bea8b0f48745e 100644 --- a/pub/src/expr.cpp +++ b/pub/src/expr.cpp @@ -27,14 +27,14 @@ //! Constructor. Set k,j,i, checking validity. Set other par's to default. -CContext::CContext( uint _k, uint _j, uint _i ) +CContext::CContext( int _k, int _j, int _i ) : k(_k), j(_j), i(_i), // set from arguments vt(0), dim(_1), want_error(false), nv(0) // can be changed later { - if ( k==(uint)-1 ) + if ( k==(int)-1 ) return; // not sure whether k=-1 makes sense POlo f = NOlm::mem_get(k); - if ( j==(uint)-1 ) { + if ( j==(int)-1 ) { if ( f->nJ()==1 ) j = 0; } else if ( j>=f->nJ() ) @@ -42,15 +42,15 @@ CContext::CContext( uint _k, uint _j, uint _i ) POld fd = P2D(f); if ( !fd ) { - if ( i!=(uint)-1 ) + if ( i!=(int)-1 ) throw "invalid evaluation context, i set for curve file"; return; } - if ( j==(uint)-1 ) + if ( j==(int)-1 ) return; - uint ni = fd->nPts(j); - if ( i==(uint)-1 ) { + int ni = fd->nPts(j); + if ( i==(int)-1 ) { if ( ni==1 ) i = 0; } else if ( i>=ni ) @@ -71,7 +71,7 @@ void CContext::request_VT( const vector<double> *_vt ) //! Request a vector of indices. -void CContext::request_VI( uint _nv ) +void CContext::request_VI( int _nv ) { dim = _VI; nv = _nv; @@ -140,27 +140,27 @@ string CRef::ref_info() const return out; } -uint CRef::get_k( const CContext& ctx ) const +int CRef::get_k( const CContext& ctx ) const { - uint k; + int k; if ( tk ) { CResult tmp; tk->tree_val( tmp, ctx ); if ( tmp.vectorial ) throw "BUG: K must not depend on i"; - k = (uint)( tmp.r + 0.5 ); + k = (int)( tmp.r + 0.5 ); } else { k = ctx.k; } - if ( k==(uint)-1 ) + if ( k==(int)-1 ) throw "missing or invalid k"; NOlm::mem_get( k ); // to assert existence of file return k; } -uint CRef::get_j( const CContext& ctx, uint nj ) const +int CRef::get_j( const CContext& ctx, int nj ) const { - uint j; + int j; if ( tj ) { CResult tmp; tj->tree_val( tmp, ctx ); @@ -168,15 +168,15 @@ uint CRef::get_j( const CContext& ctx, uint nj ) const /* what was this good for ?? if ( var.typ == CVar::_J ) { ret.preset_v( ctx.nv ); - for( uint i=0; i<ctx.nv; ++i ) + for( int i=0; i<ctx.nv; ++i ) ret.v[i] = tmp.v[i]; return; } else if ( var.typ == CVar::_Z ) { if ( var.num>= f->nZ() ) throw "invalid reference " + var.var_info(); ret.preset_v( ctx.nv ); - for( uint i=0; i<ctx.nv; ++i ) { - j = (uint)( tmp.v[i]+0.5 ); + for( int i=0; i<ctx.nv; ++i ) { + j = (int)( tmp.v[i]+0.5 ); if( j>=f->V.size() ) throw "j out of bounds"; ret.v[i] = f->V[j]->z[var.num]; @@ -186,7 +186,7 @@ uint CRef::get_j( const CContext& ctx, uint nj ) const */ throw "BUG: J must not depend on i"; } else - j = (uint)( tmp.r + 0.5 ); + j = (int)( tmp.r + 0.5 ); } else { j = ctx.j; } @@ -204,9 +204,9 @@ uint CRef::get_j( const CContext& ctx, uint nj ) const //! How many curve parameters are contained in the tree? -uint CNode::npar() const +int CNode::npar() const { - uint np=0; + int np=0; npar_exec( &np ); // implemented with pointer argument to allow recursion return np; } @@ -227,7 +227,7 @@ bool CNode::k_dependent() const //! Evaluate tree and convert result to integer, for use as index. -void CNode::tree_uival( uint *ret, const CContext& ctx ) const +void CNode::tree_uival( int *ret, const CContext& ctx ) const { CResult val; tree_val( val, ctx ); @@ -235,7 +235,7 @@ void CNode::tree_uival( uint *ret, const CContext& ctx ) const int i = (int) round( val.r ); if( i<0 ) throw "found negative index " + S(i); - *ret = (uint) i; + *ret = (int) i; } @@ -246,7 +246,7 @@ void CNode::tree_uival( uint *ret, const CContext& ctx ) const //! Evaluate tree. Public API. void CNode::tree_point_val( - double *ret, double *dret, uint k, uint j, uint i ) const + double *ret, double *dret, int k, int j, int i ) const { CContext ctx( k, j, i ); ctx.want_error = (bool)dret; @@ -262,11 +262,11 @@ void CNode::tree_point_val( //! Evaluate tree. Public API. void CNode::tree_vec_val( - vector<double> *ret, vector<double> *dret, uint k, uint j ) const + vector<double> *ret, vector<double> *dret, int k, int j ) const { CResult val; CContext ctx( k, j ); - uint nret = ret->size(); + int nret = ret->size(); ctx.request_VI( nret ); ctx.want_error = (bool)dret; tree_val( val, ctx ); @@ -290,7 +290,7 @@ void CNode::tree_vec_val( typedef struct { PSpec sv; - uint nv; + int nv; double t; CContext cv_ctx; CResult res; diff --git a/pub/src/expr.h b/pub/src/expr.h index 15e26c3b8c35edaaad03c850d9246cf0a68359d1..9d5e469e6d4d22b3d7d923e6bd084f4bd3b92000 100644 --- a/pub/src/expr.h +++ b/pub/src/expr.h @@ -19,17 +19,17 @@ typedef boost::shared_ptr<class CRegRef> PRgr; class CContext { public: - uint k, j, i; // file,scan,point we are refering to + int k, j, i; // file,scan,point we are refering to const vector<double> *vt; // a vector we may refer to double vt_step; // step of equidistant vt, otherwise 0 enum TDim { _1, _VI, _VT } dim; // kind of requested output bool want_error; // errors requested? - uint nv; // number of requested vector elements + int nv; // number of requested vector elements - CContext( uint _k=-1, uint _j=-1, uint _i=-1 ); + CContext( int _k=-1, int _j=-1, int _i=-1 ); void request_VT( const vector<double> *_vt ); - void request_VI( uint _nv ); + void request_VI( int _nv ); string context_info() const; }; @@ -76,8 +76,8 @@ class CRef { CRef( PNode _tk=PNode(), PNode _tj=PNode(), PNode _ti=PNode() ) : tk(_tk), tj(_tj), ti(_ti) {} - uint get_k( const CContext& ctx ) const; - uint get_j( const CContext& ctx, uint nj ) const; + int get_k( const CContext& ctx ) const; + int get_j( const CContext& ctx, int nj ) const; string ref_info() const; }; @@ -86,11 +86,11 @@ class CRef { class CNode { public: - virtual void npar_exec( uint *np ) const =0; + virtual void npar_exec( int *np ) const =0; //! Recursive: set *kd=true if a subnode is K dependent virtual void kdep_exec( bool *kd ) const {;} // default: do nothing - uint npar() const; + int npar() const; bool k_dependent() const; virtual bool has_dummy() const =0; // does node depend on t ? virtual bool has_conv() const =0; // does node depend on resolution ? @@ -98,16 +98,15 @@ class CNode { //! Evaluate tree. Private. User calls pass through API implemented below. virtual void tree_val( CResult& ret, const CContext& ctx ) const =0; //! API for tree evaluation: compute one index. - void tree_uival( uint *ret, const CContext& ctx ) const; + void tree_uival( int *ret, const CContext& ctx ) const; //! API for tree evaluation: compute one numeric value. void tree_point_val( double *ret, double *dret, - uint k=(uint)-1, uint j=(uint)-1, uint i=(uint)-1 ) const; + int k=-1, int j=-1, int i=-1 ) const; //! API for tree evaluation: compute an array. - void tree_vec_val( - vector<double> *ret, vector<double> *dret, - uint k=(uint)-1, uint j=(uint)-1 ) const; + void tree_vec_val( vector<double> *ret, vector<double> *dret, + int k=-1, int j=-1 ) const; - virtual void set_coord( CCoord& ret, uint k=(uint)-1 ) const =0; + virtual void set_coord( CCoord& ret, int k=-1 ) const =0; virtual string tree_info() const =0; // introspection, for debugging }; diff --git a/pub/src/file_in.cpp b/pub/src/file_in.cpp index 605662d57e165be62af87c8fcac9c9a70832e4be..0c499219d3366f62a4ff49484871d80a6c5145b7 100644 --- a/pub/src/file_in.cpp +++ b/pub/src/file_in.cpp @@ -48,7 +48,7 @@ void NFileIn::Load(void) triv::glob_file_list( fnames, "y08", &vflong ); FILE *F_in; // cout << "DEBUG: size " << vflong.size() << "\n"; - for( uint i=0; i<vflong.size(); ++i ) { + for( size_t i=0; i<vflong.size(); ++i ) { if( !(F_in = fopen(vflong[i].c_str(), "r")) ) throw "cannot open file " + vflong[i]; try{ @@ -92,7 +92,7 @@ void NFileIn::Load_08( ifstream& FS, string flong ) { string lin, key, val, fdir, fshort, fext, res; double num, vx, vy, dy; - uint iz; + int iz; bool isdata; CCoord co; @@ -144,7 +144,7 @@ void NFileIn::Load_08( ifstream& FS, string flong ) if ( doc["History"].Type() != YAML::NodeType::Sequence && doc["History"].size() > 0 ) throw "History is not a SEQUENCE type"; - for (unsigned int i = 0; i < doc["History"].size(); i++) { + for (size_t i = 0; i < doc["History"].size(); i++) { string str; doc["History"][i] >> str; fout->lDoc.push_back(str); @@ -180,7 +180,7 @@ void NFileIn::Load_08( ifstream& FS, string flong ) if ( doc["Param"].Type() != YAML::NodeType::Sequence && doc["Param"].size() > 0) throw "Param is not a SEQUENCE type"; - for( unsigned int iParam = 0; iParam < (doc["Param"].size()); iParam++ ){ + for( size_t iParam = 0; iParam < (doc["Param"].size()); iParam++ ){ if ( doc["Param"][iParam].Type() != YAML::NodeType::Map ) throw "Param " + S(iParam) + " is not a MAP type"; doc["Param"][iParam]["name"] >> co.name; @@ -208,7 +208,7 @@ void NFileIn::Load_08( ifstream& FS, string flong ) if ( doc["Tables"].Type() != YAML::NodeType::Sequence && doc["Tables"].size() > 0 ) throw "Tables is not a SEQUENCE type"; - for (unsigned int iTable = 0; iTable < (doc["Tables"].size()); iTable++) { + for (size_t iTable = 0; iTable < (doc["Tables"].size()); iTable++) { if ( doc["Tables"][iTable].Type() != YAML::NodeType::Map ) throw "Tables " + S(iTable) + " is not a MAP type"; vector<double> z; @@ -250,7 +250,7 @@ void NFileIn::Load_08( ifstream& FS, string flong ) } else { PCurve cout( new CCurve ); cout->z = z; - for( uint ip=0; ip<fc->nP; ++ip ){ + for( int ip=0; ip<fc->nP; ++ip ){ doc["Tables"][iTable]["p" + S(ip)] >> val; if( !triv::any2dbl( val, &num ) ) throw "p" + S(ip) + ": invalid value " + val; @@ -272,7 +272,7 @@ void NFileIn::Load_08( ifstream& FS, string flong ) void NFileIn::Load_01( FILE *F_in, string flong ) { string lin, key, val, fdir, fshort, fext; - uint iz, nj=0, j; + int iz, nj=0, j; CCoord co; POld fout( new COld ); @@ -325,7 +325,7 @@ void NFileIn::Load_01( FILE *F_in, string flong ) } else if (key=="y ") { fout->yco.load_a01(val); } else if (lin[0]=='z') { - if ( sscanf(lin.substr(1,3).c_str(), "%u", &iz)!=1 ) + if ( sscanf(lin.substr(1,3).c_str(), "%i", &iz)!=1 ) throw "z coordinates must be numbered"; if ( iz!=fout->ZCo.size() ) throw "z coordinates must be sorted"; @@ -333,17 +333,17 @@ void NFileIn::Load_01( FILE *F_in, string flong ) fout->ZCo.push_back(co); } else if (lin.substr(0,4)=="rpa ") { string in = lin.substr(4); - int ji = in.find_first_not_of(" \t"); + size_t ji = in.find_first_not_of(" \t"); double dval; if( ji>=20 || !triv::any2dbl( in.substr(ji,20), &dval ) ) throw "invalid rpa line\n"; fout->RPar.push_back( CParam( CCoord(), dval ) ); throw "a01 file contains rpa section. Check the source code preceeding this error message. It is possibly broken. If not, remove this exception."; } else if (key=="#j ") { - if ( sscanf(val.c_str(), "%u", &nj)!=1 ) + if ( sscanf(val.c_str(), "%i", &nj)!=1 ) throw "after key #j no no. of spectra"; } else if (key=="scn ") { - if ( sscanf(val.c_str(), "%u", &j)!=1 ) { + if ( sscanf(val.c_str(), "%i", &j)!=1 ) { cout << "warning: number of spectra not given\n"; } else if ( j!=fout->nJ() ) { cout << "warning: spec " << fout->nJ() << @@ -364,12 +364,12 @@ void NFileIn::Load_01( FILE *F_in, string flong ) void NFileIn::LoadSpec_01( FILE *F_in, PSpec& sout, int nz ) { int err; - uint i, m, n; + int i, m, n; char lab[4]; double v, w; // get z values: - if ((err=fscanf(F_in, "%4c%u\n", lab, &m))!=2) + if ((err=fscanf(F_in, "%4c%i\n", lab, &m))!=2) throw "expecting Z head line, found " + S(err) + " entries"; if (strncmp(lab, "Z ", 4)) throw "found [" + string(lab) + "] in Z head line"; @@ -382,7 +382,7 @@ void NFileIn::LoadSpec_01( FILE *F_in, PSpec& sout, int nz ) } // get xy values: - if ( (err=fscanf(F_in, "%4c%u\n", lab, &n))!=2 ) + if ( (err=fscanf(F_in, "%4c%i\n", lab, &n))!=2 ) throw "expecting XY head line, found " + S(err) + " entries"; if (strncmp(lab, "XY ", 4) ) throw "found [" + string(lab) + "] in XY head line"; @@ -402,7 +402,7 @@ void NFileIn::Load_96( FILE *F_in, string flong ) { string lin, key, val, fdir, fshort, fext; double r0, r1, r2; - uint n, nspec, ival; + int n, nspec, ival; POld fout( new COld ); CCoord co; PSpec sout; @@ -517,7 +517,7 @@ void NFileIn::Load_96( FILE *F_in, string flong ) sscanf( lin.c_str(), "%i %i", &nspec, &ival )!=2 ) throw "no nspec or 2nd arg in intro to block 7"; - for( uint j=0; j<nspec; ++j ){ + for( int j=0; j<nspec; ++j ){ sout = PSpec( new CSpec ); @@ -533,7 +533,7 @@ void NFileIn::Load_96( FILE *F_in, string flong ) sout->z.push_back( r0 ); - for( uint i=0; i<n; ++i ){ + for( int i=0; i<n; ++i ){ if ( !F_in || triv::freadln(F_in, &lin)<=0 ) throw "i96: failed to read data line " + S(i) + " of " + S(n); diff --git a/pub/src/file_out.cpp b/pub/src/file_out.cpp index f2fe4c972dd08c777961ac9e9d81ed83384b0419..5ba0db593313f3a3b0c3059dacddaa471a0cfe0f 100644 --- a/pub/src/file_out.cpp +++ b/pub/src/file_out.cpp @@ -87,7 +87,7 @@ void NFileOut::Save_y08( FILE *file, POlo f ) fd ? "generic tabular data" : "frida2 curve" ); fprintf( file, "History:\n" ); - for ( uint i=0; i<f->lDoc.size(); i++ ) + for ( size_t i=0; i<f->lDoc.size(); i++ ) fprintf( file, "- %s\n", triv::yaml(f->lDoc[i]).c_str() ); fprintf( file, "Coord:\n" ); @@ -95,13 +95,13 @@ void NFileOut::Save_y08( FILE *file, POlo f ) triv::yaml(f->xco.name).c_str(), triv::yaml(f->xco.unit).c_str() ); fprintf( file, " y:\n name: %s\n unit: %s\n", triv::yaml(f->yco.name).c_str(), triv::yaml(f->yco.unit).c_str() ); - for ( uint i=0; i<f->ZCo.size(); i++ ) - fprintf( file, " z%u:\n name: %s\n unit: %s\n", + for ( size_t i=0; i<f->ZCo.size(); i++ ) + fprintf( file, " z%zu:\n name: %s\n unit: %s\n", i, triv::yaml(f->ZCo[i].name).c_str(), triv::yaml(f->ZCo[i].unit).c_str() ); fprintf( file, "Param:\n" ); - for ( uint i=0; i<f->RPar.size(); i++ ) + for ( size_t i=0; i<f->RPar.size(); i++ ) fprintf( file, " -\n name: %s\n unit: %s\n value: %20.15g\n", triv::yaml(f->RPar[i].Co.name).c_str(), @@ -114,28 +114,28 @@ void NFileOut::Save_y08( FILE *file, POlo f ) fprintf( file, "Tables: # %u tables follow\n", f->nJ() ); - for( uint j=0; j<f->nJ(); j++ ){ + for( int j=0; j<f->nJ(); j++ ){ fprintf( file, " - # table %u\n", j ); if ( fd ) { PSpec s = fd->VS(j); - for ( uint i=0; i<f->nZ(); i++ ) + for ( int i=0; i<f->nZ(); i++ ) fprintf( file, " z%u: %18.10g\n", i, s->z[i] ); if( s->dy.size() ) { fprintf( file, " xyd: |2 # %u entries\n", s->size() ); - for( uint i=0; i<s->size(); i++ ) + for( size_t i=0; i<s->size(); i++ ) fprintf( file, " %20.15g %20.15g %20.15g\n", s->x[i], s->y[i], s->dy[i] ); } else { fprintf( file, " xy: |2 # %u entries\n", s->size() ); - for( uint i=0; i<s->size(); i++ ) + for( size_t i=0; i<s->size(); i++ ) fprintf( file, " %20.15g %20.15g\n", s->x[i], s->y[i] ); } } else { PCurve s = fc->VC(j); - for ( uint i=0; i<f->nZ(); i++ ) + for ( int i=0; i<f->nZ(); i++ ) fprintf( file, " z%u: %18.10g\n", i, s->z[i] ); - for ( uint i=0; i<fc->nP; i++ ) + for ( int i=0; i<fc->nP; i++ ) fprintf( file, " p%u: %18.10g\n", i, s->P[i] ); } } @@ -154,26 +154,26 @@ void NFileOut::Save_a01( FILE *file, POlo f ) else throw "ASCII-01 save only available for data files"; fprintf( file, "fil %s\n", f->name.c_str() ); - for ( uint i=0; i<f->lDoc.size(); i++ ) + for ( size_t i=0; i<f->lDoc.size(); i++ ) fprintf( file, "doc %s\n", f->lDoc[i].c_str() ); fprintf( file, "x %s\n", f->xco.to_a01().c_str() ); fprintf( file, "y %s\n", f->yco.to_a01().c_str() ); - for ( uint i=0; i<f->ZCo.size(); i++ ) + for ( size_t i=0; i<f->ZCo.size(); i++ ) fprintf( file, "z%-2u %s\n", i, f->ZCo[i].to_a01().c_str() ); - for ( uint i=0; i<f->RPar.size(); i++ ) + for ( size_t i=0; i<f->RPar.size(); i++ ) fprintf( file, "rpa %20.15g %s\n", f->RPar[i].val, f->RPar[i].Co.to_a01().c_str() ); fprintf( file, "#j %u\n", f->nJ() ); - for( uint j=0; j<f->nJ(); j++ ){ + for( int j=0; j<f->nJ(); j++ ){ PSpec s = fd->VS(j); fprintf( file, "scn %u\n", j ); fprintf( file, "Z %u\n", fd->nZ() ); - for ( uint i=0; i<fd->nZ(); i++ ) + for ( int i=0; i<fd->nZ(); i++ ) fprintf( file, "%18.10g\n", s->z[i] ); fprintf( file, "XY %u\n", s->size() ); - for( uint i=0; i<s->size(); i++ ) + for( size_t i=0; i<s->size(); i++ ) fprintf( file, "%20.15g %20.15g\n", s->x[i], s->y[i] ); } fprintf(file, "eof\n"); @@ -189,8 +189,8 @@ void NFileOut::Save_csv( FILE *file, POlo f ) POlc fc = P2C( f ); if( !fd ) throw "csv save only for data files"; - for( uint j=0; j<f->nJ(); j++ ){ - for( uint i=0; i<fd->VS(j)->size(); ++i ){ + for( int j=0; j<f->nJ(); j++ ){ + for( size_t i=0; i<fd->VS(j)->size(); ++i ){ fprintf( file, "%g\t", fd->VS(j)->y[i] ); } fprintf( file, "\n" ); @@ -206,13 +206,13 @@ void NFileOut::Save_tab( FILE *file, POlo f ) POlc fc = P2C( f ); if( !fd ) throw "tab save only for data files"; - for( uint j=0; j<f->nJ(); j++ ){ - for( uint iz=0; iz<f->ZCo.size(); ++iz ){ + for( int j=0; j<f->nJ(); j++ ){ + for( size_t iz=0; iz<f->ZCo.size(); ++iz ){ if( iz>0 ) fprintf( file, "\t" ); fprintf( file, "%g", fd->VS(j)->z[iz] ); } fprintf( file, "\n" ); - for( uint i=0; i<fd->VS(j)->size(); ++i ){ + for( size_t i=0; i<fd->VS(j)->size(); ++i ){ fprintf( file, "%g\t%g\n", fd->VS(j)->x[i], fd->VS(j)->y[i] ); } fprintf( file, "\n" ); diff --git a/pub/src/func.cpp b/pub/src/func.cpp index 2755386d313f63308907315dbbef514d557fe840..74f0a76e54a2f6d74ae4da9bfc3c3c566b008eee 100644 --- a/pub/src/func.cpp +++ b/pub/src/func.cpp @@ -325,7 +325,7 @@ CCoord CFunc::coord( class CCoord *co1, class CCoord *co2, class CCoord *co3 ) namespace NFunctions { // internals: map<string,CFunc> fmap; // unsorted hash, for expression evaluation vector<CFunc> flist; // sorted array, for help text -}; +} CFunc* NFunctions::find( string key ) { @@ -342,7 +342,7 @@ string NFunctions::list() string ret = ""; int prec = -1; ret += "Operators by precedence:"; - for( uint i=0; i<flist.size(); ++i ){ + for( int i=0; i<flist.size(); ++i ){ const CFunc *f; f = &(flist[i]); if( f->prec ) { // operators diff --git a/pub/src/func.h b/pub/src/func.h index 0ad701f1a888b1867d1d41446eb32908790329ff..7094ce807e1532d99caaa466bb9752a58086eeaf 100644 --- a/pub/src/func.h +++ b/pub/src/func.h @@ -34,11 +34,11 @@ class CFunc { class CCoord coord( class CCoord *co1, class CCoord *co2 ) const; class CCoord coord( class CCoord *co1, class CCoord *co2, class CCoord *co3 ) const; - CFunc( string _txt, func_f1 _f1, deri_f1 _d1, uint _prec, string _com="" ) + CFunc( string _txt, func_f1 _f1, deri_f1 _d1, int _prec, string _com="" ) : txt(_txt), narg(1), f1(_f1), d1(_d1), prec(_prec), com(_com) {}; - CFunc( string _txt, func_f2 _f2, deri_f2 _d2, uint _prec, string _com="" ) + CFunc( string _txt, func_f2 _f2, deri_f2 _d2, int _prec, string _com="" ) : txt(_txt), narg(2), f2(_f2), d2(_d2), prec(_prec), com(_com) {}; - CFunc( string _txt, func_f3 _f3, deri_f3 _d3, uint _prec, string _com="" ) + CFunc( string _txt, func_f3 _f3, deri_f3 _d3, int _prec, string _com="" ) : txt(_txt), narg(3), f3(_f3), d3(_d3), prec(_prec), com(_com) {}; void register_me() const; @@ -50,4 +50,4 @@ namespace NFunctions { // public (short) interface void initialize(); CFunc* find( string nam ); string list(); -}; +} diff --git a/pub/src/jsel.cpp b/pub/src/jsel.cpp index 10eb40241e4e2882e8c08270294e4c3e2e312d53..a5d47bb1b07e515b6c5a5d8aa892a1c01f2b2b96 100644 --- a/pub/src/jsel.cpp +++ b/pub/src/jsel.cpp @@ -23,7 +23,7 @@ void JSelAsk( string quest, string *jSel, ::CList *jLis ) { NOlm::IterateO fiter; - uint nJmax = 0; + int nJmax = 0; while ( POlo f=fiter() ) nJmax = max( nJmax, f->nJ() ); diff --git a/pub/src/list.cpp b/pub/src/list.cpp index a4c38281fc28e05297bef19b70d3009d2fce635c..6ce152985fb9a679837b0a1905eff0ab232dd2b7 100644 --- a/pub/src/list.cpp +++ b/pub/src/list.cpp @@ -38,7 +38,7 @@ CList::CList( string inp ) : //! Set limits and initialize by string. -CList::CList( string inp, uint _inf, uint _sup ) : +CList::CList( string inp, int _inf, int _sup ) : instruction( inp ), inf( _inf), sup( _sup ), limgiven( true ) { parse( instruction ); @@ -46,7 +46,7 @@ CList::CList( string inp, uint _inf, uint _sup ) : //! Initialize list containing one value. -CList::CList( uint val ) : +CList::CList( int val ) : instruction(""), limgiven( false ), limneeded( false ) { V.push_back(val); @@ -54,19 +54,19 @@ CList::CList( uint val ) : //! Initialize list containing one interval. Do not set limits. -CList::CList( uint from, uint to ) : +CList::CList( int from, int to ) : limgiven( false ) { - if( to == (uint)(from-1) ){ + if( to == (int)(from-1) ){ instruction = "-"; parse( instruction ); } else { - if ( to<from || to==(uint)-1 ) + if ( to<from || to==(int)-1 ) throw "abusive CList initialization (from " + S(from) + " to " + S(to) + ")"; instruction = ""; limneeded = 0; - for (uint val = from; val <= to; ++val) + for (int val = from; val <= to; ++val) V.push_back(val); } } @@ -77,7 +77,7 @@ CList::CList( uint from, uint to ) : //! Set bounds and evaluate instruction. -void CList::evaluate( uint _inf, uint _sup ) +void CList::evaluate( int _inf, int _sup ) { inf = _inf; sup = _sup; @@ -94,16 +94,16 @@ void CList::clear() //! Increment all members of list by given 'step'. -void CList::increment( int step, uint _inf, uint _sup ) +void CList::increment( int step, int _inf, int _sup ) { // First check whether new values will be within bounds. - for ( uint i=0; i<V.size(); ++i ) { - uint vv = V[i]+step; + for ( size_t i=0; i<V.size(); ++i ) { + int vv = V[i]+step; if( vv<_inf || vv>_sup ) throw "would exceed range "+S(_inf)+".."+S(_sup); } // Only now perform the incrementation. - for ( uint i=0; i<V.size(); ++i ) + for ( size_t i=0; i<V.size(); ++i ) V[i] += step; instruction = sel2text(); } @@ -126,12 +126,12 @@ void CList::sortReverse() void CList::append( const CList L ) { instruction = ""; - for ( uint i=0; i<L.V.size(); ++i ) + for ( size_t i=0; i<L.V.size(); ++i ) if ( !contains( L.V[i] ) ) V.push_back( L.V[i] ); } -void CList::append( const uint val ) +void CList::append( const int val ) { instruction = ""; if ( !contains(val) ) @@ -143,16 +143,16 @@ void CList::append( const uint val ) //* Inspect *// //***************************************************************************// -bool CList::contains( uint val ) const +bool CList::contains( int val ) const { - for (uint i=0; i<V.size(); i++) + for (size_t i=0; i<V.size(); i++) if (val==V[i]) return 1; return 0; } bool CList::all_between( int imi, int ima ) { - for ( uint i=0; i<size(); i++ ) + for ( size_t i=0; i<size(); i++ ) if ( V[i]<imi || V[i]>ima ) return false; return true; @@ -169,9 +169,9 @@ string CList::sel2text() const if(!V.size()) return "-"; string s; - vector<uint> VV=V; + vector<int> VV=V; auto iV=VV.begin(); - uint vi, vd; + int vi, vd; while(iV<VV.end()) { s += S(vi=*(iV++)); if(iV>=VV.end()) break; @@ -209,7 +209,7 @@ void CList::parse( string inp ) if (!limgiven) return; // cannot evaluate until limits are given CList VCompl( inp.substr(1), inf, sup ); - for( uint i=inf; i<=sup; ++i ) + for( int i=inf; i<=sup; ++i ) if( !VCompl.contains(i) ) V.push_back( i ); } else { @@ -249,7 +249,7 @@ int CList::parseSkipfactor( string inp ) void CList::parseInterval( string inp, int skip ) { string::size_type j; - uint vi, vf; + int vi, vf; if (inp==string("*")) { limneeded = 1; if (!limgiven) @@ -267,7 +267,7 @@ void CList::parseInterval( string inp, int skip ) return; // cannot evaluate until limits are given if(vi>vf) throw "invalid interval [" + inp + "]"; - for (uint vv=vi; vv<=vf; vv += skip) + for (int vv=vi; vv<=vf; vv += skip) V.push_back(vv); } @@ -288,7 +288,7 @@ int CList::parseListvalue( string inp, int which ) char dummy; if (sscanf(inp.c_str(), "%d%c", &val, &dummy)!=1 || val<0) throw "invalid list value [" + inp + "]"; - if ( limgiven && (val<inf || val>sup || sup==(uint)(-1)) ) + if ( limgiven && (val<inf || val>sup || sup==(int)(-1)) ) throw "list value [" + inp + "] out of bounds (" + S(inf) + "," + S((int)sup) + ")"; return val; diff --git a/pub/src/list.h b/pub/src/list.h index b7e0fb578e108f833c4bf60d9b0423c946c2ac9e..a4605fa3abdc689e549b4f3c673114087e558e17 100644 --- a/pub/src/list.h +++ b/pub/src/list.h @@ -31,41 +31,41 @@ class CList { private: string instruction; // either "", or a user-supplied input string - uint inf, sup; // user-supplied bounds; meaningful only if 'limgiven' + int inf, sup; // user-supplied bounds; meaningful only if 'limgiven' bool limgiven; // have bounds been supplied ? bool limneeded; // does instruction require bounds ? public: - vector<uint> V; // holds the list, except if not yet 'evaluated()' + vector<int> V; // holds the list, except if not yet 'evaluated()' CList(); // initialize by string: CList( string inp ); - CList( string inp, uint _inf, uint _sup ); + CList( string inp, int _inf, int _sup ); // initialize by values: - CList( uint val ); - CList( uint from, uint to ); + CList( int val ); + CList( int from, int to ); // interactive initialization: // void ask_and_set( const string& quest ); // set bounds and evaluate instruction: - void evaluate( uint _inf, uint _sup ); + void evaluate( int _inf, int _sup ); // modify: void clear(); - void increment( int step, uint _inf, uint _sup ); + void increment( int step, int _inf, int _sup ); void sort(); void sortReverse(); void append( const CList L ); - void append( uint val ); + void append( int val ); // inspect: bool evaluated() const { return !limneeded || limgiven; } - uint size() const { return V.size(); } - bool contains( uint val ) const; + int size() const { return V.size(); } + bool contains( int val ) const; bool all_between( int imi, int ima ); string str() const; friend ostream& operator<< ( ostream& s, CList L ) { diff --git a/pub/src/manip.cpp b/pub/src/manip.cpp index 622cdb58c96a2c075158e60162453e5ab5735684..7686aaf403c7d0b0a2d928bde39e9597ed96e1c2 100644 --- a/pub/src/manip.cpp +++ b/pub/src/manip.cpp @@ -55,7 +55,7 @@ void NManip::ProtectSpecs( bool on ) sel = "-"; while( POlo fio = fiter() ) { CList lis( sel, 0, fio->nJ()-1 ); - for( uint j=0; j<fio->nJ(); ++j ) + for( int j=0; j<fio->nJ(); ++j ) fio->V[j]->protect = lis.contains(j); fio->lDoc.push_back( "m/ " + sel ); } @@ -81,12 +81,12 @@ void NManip::PtsSelect( bool sel_del ) fout->lDoc.push_back( "mp" + string( sel_del ? "d" : "r" ) + " " + pSel ); - for ( uint j=0; j<fin->nJ(); j++ ) { + for ( int j=0; j<fin->nJ(); j++ ) { PSpec sin = fin->VS(j); PSpec sout( new CSpec ); sout->copy_z_base( sin ); pLis.evaluate( 0, sin->size()-1 ); - for ( uint i=0; i<sin->size(); i++ ) { + for ( size_t i=0; i<sin->size(); i++ ) { if ( sel_del ^ pLis.contains(i) ) { if( sin->dy.size() ) sout->push_xyd( sin->x[i], sin->y[i], sin->dy[i] ); @@ -119,7 +119,7 @@ void NManip::PtsAvge() POld fout( fin->new_old() ); fout->lDoc.push_back("mpa " + sel); - for( uint j=0; j<fin->nJ(); j++ ) { + for( int j=0; j<fin->nJ(); j++ ) { PSpec sin = fin->VS(j); PSpec sout( new CSpec() ); sout->copy_z_base( sin ); @@ -129,20 +129,20 @@ void NManip::PtsAvge() throw "BUG: unexpected empty bin list"; if ( groups.V[0]!=0 ) throw "First bin must start at 0"; - vector<uint> breaks( groups.V ); + vector<int> breaks( groups.V ); breaks.push_back( sin->size() ); - for ( uint iv=0; iv<breaks.size()-1; ++iv ) { - uint igi = breaks[iv]; - uint igf = breaks[iv+1]; + for ( size_t iv=0; iv<breaks.size()-1; ++iv ) { + int igi = breaks[iv]; + int igf = breaks[iv+1]; double xg = 0, yg = 0, vg = 0; - for ( uint i=igi; i<igf; ++i ) { + for ( int i=igi; i<igf; ++i ) { xg += sin->x[i]; yg += sin->y[i]; if( sin->dy.size() ) vg += SQR( sin->dy[i] ); } - uint ng = igf - igi; + int ng = igf - igi; if( sin->dy.size() ) sout->push_xyd(xg/ng, yg/ng, sqrt(vg)/ng ); else @@ -169,7 +169,7 @@ void NManip::PtsAvgeFixed() POld fout( fin->new_old() ); fout->lDoc.push_back( "mpaf " + S(ng) ); - for( uint j=0; j<fin->nJ(); j++ ) { + for( int j=0; j<fin->nJ(); j++ ) { PSpec sin = fin->VS(j); PSpec sout( new CSpec() ); sout->copy_z_base( sin ); @@ -177,9 +177,9 @@ void NManip::PtsAvgeFixed() if( sin->size()<ng ) throw "not enough points in spectrum " + S(j); - for ( uint iv=0; iv<sin->size()/ng; ++iv ) { + for ( size_t iv=0; iv<sin->size()/ng; ++iv ) { double xg = 0, yg = 0, vg = 0; - for ( uint i=iv*ng; i<(iv+1)*ng; ++i ) { + for ( int i=iv*ng; i<(iv+1)*ng; ++i ) { xg += sin->x[i]; yg += sin->y[i]; if( sin->dy.size() ) @@ -216,15 +216,15 @@ void NManip::PtsAvgeByErr( const string& subcmd ) while( POld fin = fiter() ) { POld fout( fin->new_old() ); string groupinfo; - for ( uint j=0; j<fin->nJ(); j++ ) { + for ( int j=0; j<fin->nJ(); j++ ) { PSpec sin = fin->VS(j); PSpec sout( new CSpec() ); sout->copy_z_base( sin ); if( !sin->dy.size() ) throw "no errors available"; double xg = 0, yg = 0, vg = 0; - uint ng = 0, istart=0; - for( uint i=0; i<sin->size(); ++i ) { + int ng = 0, istart=0; + for( size_t i=0; i<sin->size(); ++i ) { if ( !mode_abs && sin->y[i]<0 ) throw "negative counts not compatible with" " relative error bounds"; @@ -267,12 +267,12 @@ void NManip::PtsSort() throw "dummy argument t not allowed when operating on data"; while( POld fin = fiter() ) { - uint k, n, i; + int k, n, i; k = fiter.k(); POld fout( fin->new_old() ); fout->lDoc.push_back("mpo "+expr); - for ( uint j=0; j<fin->nJ(); j++ ) { + for ( int j=0; j<fin->nJ(); j++ ) { PSpec sin = fin->VS(j); PSpec sout( new CSpec ); sout->copy_z_base( sin ); @@ -306,20 +306,20 @@ void NManip::PtsAvgeEq(void) POld fout( fin->new_old() ); fout->lDoc.push_back("mpq # average points when x equal"); - for ( uint j=0; j<fin->nJ(); j++ ) { + for ( int j=0; j<fin->nJ(); j++ ) { const PSpec sin = fin->VS(j); PSpec sout( new CSpec ); sout->copy_z_base( sin ); - uint n = sin->size(); - uint ii=0; - for ( uint i=0; i<n; i=ii ) { + size_t n = sin->size(); + int ii=0; + for ( int i=0; i<n; i=ii ) { double xg = sin->x[i]; double yg = sin->y[i]; double eg; if( sin->dy.size() ) eg = SQR(sin->dy[i]); - uint ng = 1; + int ng = 1; for ( ii=i+1; ii<n; ++ii ) { if (sin->x[ii] != xg) break; yg += sin->y[ii]; @@ -350,12 +350,12 @@ void NManip::PtsSymmetrize() PNode T = user_xaxparse( expr.c_str() ); while( POld fin = fiter() ) { - uint k = fiter.k(); + int k = fiter.k(); POld fout( fin->new_old() ); fout->lDoc.push_back("mpsym "+expr); - uint n, i, il, ih, nl, nh; - for (uint j=0; j<fin->nJ(); j++) { + int n, i, il, ih, nl, nh; + for (int j=0; j<fin->nJ(); j++) { PSpec sin = fin->VS(j); PSpec sout( new CSpec ); sout->copy_z_base( sin ); @@ -415,12 +415,12 @@ void NManip::PtsSymmetrize() void NManip::ScaRemoveConstantZ( POlo fio ) { for( int iz=fio->nZ()-1; iz>=0; --iz ){ - uint nj = fio->nJ(); + int nj = fio->nJ(); if( nj<1 ) throw "file contains no spectrum"; double z = fio->z(0,iz); bool z_is_const = true; - for( uint j=1; j<nj; ++j ){ + for( int j=1; j<nj; ++j ){ if( fio->z(j,iz) != z ){ z_is_const = false; } @@ -476,15 +476,15 @@ void NManip::ScaAvge() if ( JSel.V.size()<1 || JSel.V[0]!=0 ) throw "spectrum selection must contain 0"; fout->lDoc.push_back("msa " + JSel.str()); - for( uint iv=0; iv<JSel.size(); iv++ ) { - uint ji = JSel.V[iv]; - uint jf = ( iv<JSel.size()-1 ? JSel.V[iv+1] : fin->nJ() ); - uint nz = fin->nZ(); + for( size_t iv=0; iv<JSel.size(); iv++ ) { + int ji = JSel.V[iv]; + size_t jf = ( iv<JSel.size()-1 ? JSel.V[iv+1] : fin->nJ() ); + int nz = fin->nZ(); vector<double> zout( nz ); - for( uint iz=0; iz<nz; ++iz ){ - uint mz = 0; + for( int iz=0; iz<nz; ++iz ){ + int mz = 0; double z = 0; - for ( uint jj=ji; jj<jf; jj++ ) { + for ( int jj=ji; jj<jf; jj++ ) { z += fin->z(jj,iz); ++mz; } @@ -493,26 +493,26 @@ void NManip::ScaAvge() if( fd ) { PSpec sout( new CSpec() ); bool with_dy = fd->VS(0)->dy.size(); - uint n = fd->nPts(ji); + int n = fd->nPts(ji); sout->resize( n, with_dy ); // x grids must be equal: sout->x = fd->VS(ji)->x; - for ( uint jj=ji+1; jj<jf; jj++ ){ + for ( int jj=ji+1; jj<jf; jj++ ){ if ( fd->nPts(jj) != fd->nPts(ji) ) throw "spectrum " + S(jj) + " has other size than spectrum " + S(ji); - for( uint i=0; i<fd->nPts(jj); ++i ){ + for( int i=0; i<fd->nPts(jj); ++i ){ if ( fd->VS(jj)->x[i] != sout->x[i] ) throw "spectrum " + S(jj) + " has other x[" + S(i) + "] than spectrum 0"; } } // bin y: - for ( uint i=0; i<n; i++ ){ - uint mj = 0; + for ( int i=0; i<n; i++ ){ + int mj = 0; double ym = 0; double vm = 0; - for ( uint jj=ji; jj<jf; jj++) { + for ( int jj=ji; jj<jf; jj++) { ym += fd->VS(jj)->y[i]; if( with_dy ) vm += SQR(fd->VS(jj)->dy[i] ); @@ -526,12 +526,12 @@ void NManip::ScaAvge() fout->V.push_back( sout ); } else if ( fc ) { PCurve cout( new CCurve ); - uint np = fc->nP; + int np = fc->nP; vector<double> p(np); - for ( uint ip=0; ip<np; ip++ ){ - uint mj = 0; + for ( int ip=0; ip<np; ip++ ){ + int mj = 0; double pm = 0; - for ( uint jj=ji; jj<jf; jj++) { + for ( int jj=ji; jj<jf; jj++) { pm += fc->VC(jj)->P[ip]; ++mj; } @@ -565,14 +565,14 @@ void NManip::ScaJoin() throw "spectrum selection must contain 0"; fout->lDoc.push_back("msj " + JSel.str()); cerr << "WARNING: z just taken from first spectrum of each group\n"; - for ( uint iv=0; iv<JSel.size(); iv++ ) { - uint ji, jf; + for ( size_t iv=0; iv<JSel.size(); iv++ ) { + int ji, jf; ji = JSel.V[iv]; jf = ( iv<JSel.size()-1 ? JSel.V[iv+1] : fin->nJ() ); PSpec sout( new CSpec( *(fin->VS(ji)) ) ); bool with_dy = fin->VS(ji)->dy.size(); - for ( uint jj=ji+1; jj<jf; jj++){ - for( uint i=0; i<fin->VS(jj)->size(); ++i ) + for ( int jj=ji+1; jj<jf; jj++){ + for( size_t i=0; i<fin->VS(jj)->size(); ++i ) if ( with_dy ) sout->push_xyd( fin->VS(jj)->x[i], fin->VS(jj)->y[i], fin->VS(jj)->dy[i]); @@ -603,8 +603,8 @@ void NManip::ScaSpawn() fout->ZCo.insert( fout->ZCo.begin(), CCoord("no-in-spawn", "")); - for( uint jj=0; jj<njj; ++jj ){ - for( uint j=0; j<fin->nJ(); j++ ){ + for( int jj=0; jj<njj; ++jj ){ + for( int j=0; j<fin->nJ(); j++ ){ PZentry eout = fin->new_zentry( j ); eout->z.insert( eout->z.begin(), jj ); fout->V.push_back( eout ); @@ -623,8 +623,8 @@ void NManip::ScaExch() while( POld fin = fiter() ) { POld fout( fin->new_old() ); - uint izco = fin->ZCo.size() - 1; - if ( izco==(uint)-1 ) + size_t izco = fin->ZCo.size() - 1; + if ( izco==(int)-1 ) throw "no input z coordinate"; fout->lDoc.push_back( "msx # exchanging x=" + fin->xco.str_compact() + @@ -636,23 +636,23 @@ void NManip::ScaExch() throw "no spectra in file"; vector<double> zcommon, xcommon; - uint ji, jf; + int ji, jf; for ( ji=0; ji<fin->nJ(); ) { zcommon.clear(); - for ( uint i=0; i<izco; ++i) + for ( int i=0; i<izco; ++i) zcommon.push_back(fin->V[ji]->z[i]); for ( jf=ji+1; jf<fin->nJ(); jf++ ) - for ( uint i=0; i<izco; ++i) + for ( int i=0; i<izco; ++i) if (fin->V[jf]->z[i] != zcommon[i]) goto end_group; end_group: // build common grid: xcommon.clear(); - for ( uint j=ji; j<jf; ++j ) - for ( uint i=0; i<fin->VS(j)->size(); ++i ) + for ( int j=ji; j<jf; ++j ) + for ( size_t i=0; i<fin->VS(j)->size(); ++i ) xcommon.push_back( fin->VS(j)->x[i] ); sort( xcommon.begin(), xcommon.end() ); triv::unique(&xcommon, 1e-180, 1e-20); @@ -660,14 +660,14 @@ void NManip::ScaExch() printf("group of spectra %u .. %u has %zu different x\n", ji, jf-1, xcommon.size()); - uint ii = 0; // a guess - for ( uint i=0; i<xcommon.size(); ++i ) { + int ii = 0; // a guess + for ( size_t i=0; i<xcommon.size(); ++i ) { PSpec sout( new CSpec ); sout->z = zcommon; sout->z.push_back(xcommon[i]); - for ( uint j=ji; j<jf; ++j ) { + for ( int j=ji; j<jf; ++j ) { PSpec sin = fin->VS( j ); bool with_dy = sin->dy.size(); if( sin->x[ii]!=xcommon[i] ){ // guess failed @@ -706,15 +706,15 @@ void NManip::ScaSortByExpr() POlo fout( fin->new_olo() ); fout->lDoc.push_back( "mso "+expr ); - uint nj = fin->nJ(); + int nj = fin->nJ(); vector<double> v(nj); - for (uint j=0; j<nj; j++) + for (int j=0; j<nj; j++) T->tree_point_val( &(v[j]), 0, fiter.k(), j ); size_t pos[nj]; gsl_sort_index( pos, &(v[0]), 1, nj ); - for (uint j=0; j<nj; j++) + for (int j=0; j<nj; j++) fout->V.push_back( fin->new_zentry( pos[j] ) ); NOlm::mem_store( fout, fiter.k() ); @@ -729,7 +729,7 @@ void NManip::ScaSortByZ() NOlm::IterateO fiter; while( POlo fin = fiter() ) { POlo fout( fin->new_olo() ); - for (uint j=0; j<fin->nJ(); j++) + for (int j=0; j<fin->nJ(); j++) fout->V.push_back( fin->new_zentry( j ) ); sort( fout->V.begin(), fout->V.end(), CompareZ ); NOlm::mem_store( fout, fiter.k() ); @@ -794,7 +794,7 @@ void NManip::ZExchange() while( POlo fin = fiter() ) { POlo fout( fin->new_olo() ); fout->lDoc.push_back( com ); - for (uint j=0; j<fin->nJ(); j++) + for (int j=0; j<fin->nJ(); j++) fout->V.push_back( fin->new_zentry( j ) ); int nz = fout->ZCo.size(); @@ -816,7 +816,7 @@ void NManip::ZExchange() fout->ZCo[num2] = fin->ZCo[num1]; } - for ( uint j=0; j<fin->V.size(); j++ ) { + for ( int j=0; j<fin->V.size(); j++ ) { if ( nz<nzmin ){ // do nothing } else if( mod=='r' ){ @@ -855,19 +855,19 @@ void NManip::ZDelete() if ( !fin->nJ() ) throw "BUG: no spectra"; - for ( uint j=0; j<fin->nJ(); j++ ) + for ( int j=0; j<fin->nJ(); j++ ) fout->V.push_back( fin->new_zentry( j ) ); CList lis( sel, 0, fin->ZCo.size()-1 ); lis.sortReverse(); - uint nRPar = fout->RPar.size(); - for ( uint iv=0; iv<lis.size(); ++iv ) { - uint iz = lis.V[iv]; + size_t nRPar = fout->RPar.size(); + for ( size_t iv=0; iv<lis.size(); ++iv ) { + int iz = lis.V[iv]; fout->RPar.insert( fout->RPar.begin()+nRPar, fout->ZCo[iz] ); fout->ZCo.erase( fout->ZCo.begin()+iz ); double zval = 0; - for ( uint j=0; j<fin->nJ(); j++ ) { + for ( int j=0; j<fin->nJ(); j++ ) { zval += fout->V[j]->z[iz]; fout->V[j]->z.erase( fout->V[j]->z.begin()+iz ); } @@ -893,9 +893,9 @@ void NManip::ScaBreak() ftmp->V.clear(); ftmp->lDoc.push_back( "msb # eliminating " + zco.str_compact() ); ftmp->ZCo.erase( ftmp->ZCo.begin() ); - uint jout = 0; + int jout = 0; - for ( uint j=0; j<fin->nJ(); ) { + for ( int j=0; j<fin->nJ(); ) { POlo fout( ftmp->new_olo() ); double zval = ftmp->z(j,0); fout->RPar.push_back( CParam( zco, zval ) ); @@ -963,7 +963,7 @@ void NManip::FilMerge( const string& opts ) throw "different y coordinates"; if ( fin->ZCo.size() != fout->ZCo.size() ) throw "different numer of z coordinates"; - for ( uint i=0; i<fout->ZCo.size(); ++i ) + for ( size_t i=0; i<fout->ZCo.size(); ++i ) if ( fin->ZCo[i] != fout->ZCo[i] ) throw "different z"+S(i)+" coordinate"; if ( POlc fc = P2C(fin) ) @@ -974,20 +974,20 @@ void NManip::FilMerge( const string& opts ) // check RPar, and prepare move to z if they differ: fiter.reset(); vector<CParam> RPar( fiter()->RPar ); - uint nR = RPar.size(); + size_t nR = RPar.size(); vector<bool> RParDiff( nR, false ); while ( (fin = fiter()) ) { if ( fin->RPar.size() != nR ) throw "different numer of r parameters"; - for ( uint i=0; i<nR; ++i ) + for ( size_t i=0; i<nR; ++i ) if (fin->RPar[i].Co != RPar[i].Co ) throw "different r parameter"; - for ( uint i=0; i<nR; ++i ) + for ( size_t i=0; i<nR; ++i ) if (fin->RPar[i].val != RPar[i].val ) RParDiff[i] = true; } auto zinsert = fout->ZCo.begin(); - for ( uint i=0; i<nR; ++i ) { + for ( size_t i=0; i<nR; ++i ) { if( RParDiff[i] ) fout->ZCo.insert( zinsert++, RPar[i].Co ); else @@ -1005,17 +1005,17 @@ void NManip::FilMerge( const string& opts ) fiter.reset(); fnam = fiter()->name; while ( fin = fiter() ) { - uint n2=fin->name.size(); + size_t n2=fin->name.size(); if ( n2<fnam.size() ) fnam.erase( fnam.begin()+n2, fnam.end() ); - for ( uint i=0; i<fnam.size(); ++i ) + for ( size_t i=0; i<fnam.size(); ++i ) if (fnam[i]!=(fin->name)[i]) fnam[i] = ' '; } for ( auto cp = fnam.begin(); cp != fnam.end(); ++cp ) if (*cp==' ') fnam.erase(cp--); if (fnam == "") { - static uint callNo=0; + static int callNo=0; fnam = str( format( "merge%03u" ) % callNo++ ); } //fnam = wask("Joined file name", fnam); @@ -1031,11 +1031,11 @@ void NManip::FilMerge( const string& opts ) while ( (fin = fiter()) ) { fout->lDoc.push_back(" " + fin->name); if ( fiter.iteration()==0 ) { - for ( uint i=0; i<fin->lDoc.size(); ++i ) + for ( size_t i=0; i<fin->lDoc.size(); ++i ) fout->lDoc.push_back(" " + fin->lDoc[i]); } else { string line = " "; - for ( uint i=0; i<fin->lDoc.size(); ++i ) { + for ( size_t i=0; i<fin->lDoc.size(); ++i ) { if ( i<f1->lDoc.size() && fin->lDoc[i]==f1->lDoc[i] ) { line += "="; } else { @@ -1048,10 +1048,10 @@ void NManip::FilMerge( const string& opts ) // now merge the Zentries, and add new z's: fiter.reset(); while ( fin = fiter() ) { - for ( uint j=0; j<fin->nJ(); j++ ) { + for ( int j=0; j<fin->nJ(); j++ ) { PZentry eout( fin->new_zentry(j) ); auto zinsert=eout->z.begin(); - for ( uint i=0; i<nR; ++i ) + for ( int i=0; i<nR; ++i ) if ( RParDiff[i] ) eout->z.insert( zinsert++, fin->RPar[i].val ); if ( add_zk ) @@ -1063,7 +1063,7 @@ void NManip::FilMerge( const string& opts ) if ( NOlm::overwrite ) { fiter.reset(); fiter(); - uint kout = fiter.k(); + int kout = fiter.k(); NOlm::mem_store( fout, kout ); while ( fiter() ) NOlm::mem_del( fiter.k() ); @@ -1092,17 +1092,17 @@ void NManip::FilMergePointwise() if ( fin->xco != fout->xco || fin->yco != fout->yco ) throw "different x/y coordinates"; - for ( uint j=0; j<fout->nJ(); ++j ) { + for ( int j=0; j<fout->nJ(); ++j ) { PSpec sin = fin->VS(j); PSpec sout = fout->VS(j); if ( sin->z.size() != sout->z.size() ) throw "different # z entries"; - for ( uint i=0; i<sout->z.size(); ++i ) + for ( size_t i=0; i<sout->z.size(); ++i ) if ( sin->z[i] != sout->z[i] ) throw "different # z values"; if( sin->dy.size() ^ sout->dy.size() ) throw "different on/off status of error bars"; - for ( uint i=0; i<sin->size(); ++i ) { + for ( size_t i=0; i<sin->size(); ++i ) { if( sin->dy.size() ) sout->push_xyd( sin->x[i], sin->y[i], sin->dy[i] ); else @@ -1132,25 +1132,25 @@ void NManip::Interpolate() NOlm::IterateD fiter; while( POld fin = fiter() ) { - uint k = fiter.k(); + int k = fiter.k(); POld fout( fin->new_old() ); fout->copy_mainvec( fin ); - uint k2; + int k2; CContext ctx( k ); T->tree_uival( &k2, ctx ); POld f2 = NOlm::mem_get_D( k2 ); fout->lDoc.push_back( "mi " + S(k2) ); - for ( uint j=0; j<fin->nJ(); j++ ) { + for ( int j=0; j<fin->nJ(); j++ ) { PSpec sin = fin ->VS(j); PSpec s2 = f2 ->VS(j); PSpec sout= fout->VS(j); - uint i2 = 0; + int i2 = 0; if( sin->y[0]<s2->x[0] ) throw "File "+S(k)+", spec "+S(j)+": y[0] not in reference"; - for ( uint i=0; i<sin->size(); i++ ) { + for ( size_t i=0; i<sin->size(); i++ ) { double p = sin->y[i]; if( p==s2->x[i2] ) { sout->y[i] = s2->y[i2]; diff --git a/pub/src/manip.h b/pub/src/manip.h index 7e053fc1bc15a85cf509d7075b158b3a3d922cf0..ff9f1d2a155596155314190781537689e6eba0bf 100644 --- a/pub/src/manip.h +++ b/pub/src/manip.h @@ -33,4 +33,4 @@ namespace NManip { void FilMerge( const string& opts ); void FilMergePointwise(); void Interpolate(); -}; +} diff --git a/pub/src/mem.cpp b/pub/src/mem.cpp index b84417d7dc04726866dcf0ffaa6e540c327c394a..7464b282e1be2a2ed064036119f2bf076660b948 100644 --- a/pub/src/mem.cpp +++ b/pub/src/mem.cpp @@ -27,7 +27,7 @@ namespace NOlm { vector<POlo> BAK; bool overwrite; CList FSel, FSelOld, FSelNew; -}; +} //***************************************************************************// @@ -78,7 +78,7 @@ namespace NOlm { //! Step up or down. void sel_increment( int step ) { - for( uint i=0; i<FSel.size(); ++i ) + for( int i=0; i<FSel.size(); ++i ) FSel.V[i] += step; } @@ -97,10 +97,10 @@ namespace NOlm { } //! Maximum number of scans in selected files. - uint nJ_max() + int nJ_max() { - uint ret = 0; - for( uint i=0; i<FSel.size(); ++i ) + int ret = 0; + for( int i=0; i<FSel.size(); ++i ) ret = max( ret, MOM[FSel.V[i]]->nJ() ); return ret; } @@ -117,16 +117,16 @@ namespace NOlm { class MyIterate { public: // TODO: should become private - uint iV; + int iV; CList Sel; public: MyIterate( int mode ); void reset(); POlo get(); bool going() const; - uint k() const; - uint iteration() const; - uint size() const; + int k() const; + int iteration() const; + int size() const; }; MyIterate::MyIterate( int mode ) @@ -139,10 +139,10 @@ namespace NOlm { Sel = FSel; } reset(); - }; + } void MyIterate::reset() - { iV = 0; }; + { iV = 0; } POlo MyIterate::get() { return MOM[Sel.V[iV++]]; } @@ -150,13 +150,13 @@ namespace NOlm { bool MyIterate::going() const { return iV<Sel.size(); } - uint MyIterate::k() const + int MyIterate::k() const { return Sel.V[iV-1]; } - uint MyIterate::iteration() const + int MyIterate::iteration() const { return iV-1; } - uint MyIterate::size() const + int MyIterate::size() const { return Sel.V.size(); } } @@ -183,13 +183,13 @@ namespace NOlm { void IterateO::reset() { return pimpl->reset(); } - uint IterateO::k() const + int IterateO::k() const { return pimpl->k(); } - uint IterateO::iteration() const + int IterateO::iteration() const { return pimpl->iteration(); } - uint IterateO::size() const + int IterateO::size() const { return pimpl->size(); } POld IterateD::operator()() @@ -199,10 +199,10 @@ namespace NOlm { return e; }; - uint IterateD::size() const + int IterateD::size() const { IterateD iter2; - uint ret = 0; + int ret = 0; for( ; iter2(); ++ret ) {}; return ret; } @@ -214,10 +214,10 @@ namespace NOlm { return e; } - uint IterateC::size() const + int IterateC::size() const { IterateC iter2; - uint ret = 0; + int ret = 0; for( ; iter2(); ++ret ) {}; return ret; } @@ -286,7 +286,7 @@ namespace NOlm { //! Remove selected files from online memory. void mem_del() { - for (uint i = FSel.size()-1; i!=(uint)-1; --i) + for (int i = FSel.size()-1; i!=(int)-1; --i) mem_del( FSel.V[i] ); sel_pop(); } @@ -295,7 +295,7 @@ namespace NOlm { void mem_del( int k ) { MOM.erase(MOM.begin()+k); - for( uint i=0; i<FSelOld.size(); ++i ) + for( int i=0; i<FSelOld.size(); ++i ) if ( FSelOld.V[i] > k ) --FSelOld.V[i]; } @@ -345,7 +345,7 @@ namespace NOlm { if( !BAK.size() ) throw "no files in backup"; sel_collect_begin(); - for( uint kb=0; kb<BAK.size(); ++kb ){ + for( int kb=0; kb<BAK.size(); ++kb ){ mem_store( BAK[kb], -1 ); } sel_collect_end(); diff --git a/pub/src/mem.h b/pub/src/mem.h index e51eadee5622304cd974edfa057a2ac0bdf3a8b4..d768bef68390dd3ff06dd0a72d7b3210991e2279 100644 --- a/pub/src/mem.h +++ b/pub/src/mem.h @@ -28,7 +28,7 @@ namespace NOlm { // Access file selection: string sel_str(); POlo sel_first(); - uint nJ_max(); + int nJ_max(); // Modify file selection: void sel_push( class CList* _FSel ); @@ -50,9 +50,9 @@ namespace NOlm { ~IterateO(); POlo operator()(); void reset(); - uint k() const; - uint iteration() const; - uint size() const; + int k() const; + int iteration() const; + int size() const; }; //! Bit values of 'mode' parameter in IterateO constructor. @@ -63,16 +63,16 @@ namespace NOlm { class IterateD : public IterateO { public: POld operator()(); - uint size() const; + int size() const; }; //! Iterate over curve files in selection. class IterateC : public IterateO { public: POlc operator()(); - uint size() const; + int size() const; }; //! Allow command to overwrite its input files? extern bool overwrite; -}; // namespace NOlm +} // namespace NOlm diff --git a/pub/src/node.cpp b/pub/src/node.cpp index 417841d7b206335c71e847b7ce17b5bdee82a839..b22bf8a9ed05f7e267c9503c12fb92cfc8821cc1 100644 --- a/pub/src/node.cpp +++ b/pub/src/node.cpp @@ -64,19 +64,19 @@ void CNodeFun::tree_val( CResult& ret, const CContext& ctx ) const { CResult a[maxarg]; // evaluate arguments - for ( uint iarg=0; iarg<narg; ++iarg ) { + for ( int iarg=0; iarg<narg; ++iarg ) { arg[iarg]->tree_val( a[iarg], ctx ); } // scalar arguments ? bool is_scalar = true; - for ( uint iarg=0; iarg<narg; ++iarg ) { + for ( int iarg=0; iarg<narg; ++iarg ) { if ( !a[iarg].vectorial ) continue; is_scalar = false; } // some input has errors ? bool err_input = false; - for ( uint iarg=0; iarg<narg; ++iarg ) { + for ( int iarg=0; iarg<narg; ++iarg ) { if ( a[iarg].has_err() ){ err_input = true; break; @@ -85,7 +85,7 @@ void CNodeFun::tree_val( CResult& ret, const CContext& ctx ) const // size of vectorial arguments int n=0; if( !is_scalar ) { - for ( uint iarg=0; iarg<narg; ++iarg ) { + for ( int iarg=0; iarg<narg; ++iarg ) { if ( !a[iarg].vectorial ) continue; if ( n==0 ) @@ -164,7 +164,7 @@ void CNodeFun::tree_val( CResult& ret, const CContext& ctx ) const } if( DEBUG ) { cout << "tree_op:\n"; - for ( uint iarg=0; iarg<narg; ++iarg ) + for ( int iarg=0; iarg<narg; ++iarg ) cout << " arg: " << a[iarg].result_info() << "\n"; cout << " res: " << ret.result_info() << "\n"; } @@ -172,7 +172,7 @@ void CNodeFun::tree_val( CResult& ret, const CContext& ctx ) const bool CNodeFun::has_dummy() const { - for ( uint iarg=0; iarg<narg; ++iarg ) + for ( int iarg=0; iarg<narg; ++iarg ) if( arg[iarg]->has_dummy() ) return true; return false; @@ -180,7 +180,7 @@ bool CNodeFun::has_dummy() const bool CNodeFun::has_conv() const { - for ( uint iarg=0; iarg<narg; ++iarg ) + for ( int iarg=0; iarg<narg; ++iarg ) if( arg[iarg]->has_conv() ) return true; return false; @@ -188,19 +188,19 @@ bool CNodeFun::has_conv() const void CNodeFun::kdep_exec( bool *kd ) const { - for ( uint iarg=0; iarg<narg; ++iarg ) + for ( int iarg=0; iarg<narg; ++iarg ) arg[iarg]->kdep_exec( kd ); } -void CNodeFun::npar_exec( uint *np ) const +void CNodeFun::npar_exec( int *np ) const { - for ( uint iarg=0; iarg<narg; ++iarg ) + for ( int iarg=0; iarg<narg; ++iarg ) arg[iarg]->npar_exec( np ); } -void CNodeFun::set_coord( CCoord& ret, uint k ) const { +void CNodeFun::set_coord( CCoord& ret, int k ) const { CCoord r[maxarg]; - for ( uint iarg=0; iarg<narg; ++iarg ) + for ( int iarg=0; iarg<narg; ++iarg ) arg[iarg]->set_coord( r[iarg], k ); if ( narg==1 ) ret = fun->coord( r+0); @@ -213,7 +213,7 @@ void CNodeFun::set_coord( CCoord& ret, uint k ) const { string CNodeFun::tree_info() const { string ret = fun->txt + "("; - for ( uint iarg=0; iarg<narg; ++iarg ) + for ( int iarg=0; iarg<narg; ++iarg ) ret += arg[iarg]->tree_info() + (iarg<narg-1 ? "," : ")" ); return ret; } @@ -225,7 +225,7 @@ string CNodeFun::tree_info() const CNodeVal::CNodeVal( double _val ) : val( _val ) {} -void CNodeVal::set_coord( CCoord& ret, uint k ) const { +void CNodeVal::set_coord( CCoord& ret, int k ) const { ret = CCoord(S(val), ""); } string CNodeVal::tree_info() const { return "val[" + S(val) + "]"; } @@ -233,7 +233,7 @@ string CNodeVal::tree_info() const { return "val[" + S(val) + "]"; } //* CNodeIva: indexed variable node *// //***************************************************************************// -void CNodeIva::npar_exec( uint *np ) const +void CNodeIva::npar_exec( int *np ) const { if ( var->typ == CVar::_CP ) *np = max( *np, var->num+1 ); @@ -248,7 +248,7 @@ void CNodeIva::tree_val( CResult& ret, const CContext& ctx ) const throw "invalid cross reference: index cannot be indexed"; // Get k from context: - uint k = ref->get_k( ctx ); + int k = ref->get_k( ctx ); // Return k-dependent reference (unless already done above): if ( var->typ == CVar::_K ) { @@ -270,7 +270,7 @@ void CNodeIva::tree_val( CResult& ret, const CContext& ctx ) const } // We need j: - uint j = ref->get_j( ctx, f->nJ() ); + int j = ref->get_j( ctx, f->nJ() ); // Return k-j-dependent reference (unless done above): if ( var->typ == CVar::_J ) { @@ -295,12 +295,12 @@ void CNodeIva::tree_val( CResult& ret, const CContext& ctx ) const if ( var->typ == CVar::_DY && !sj->dy.size() ) throw "dy not set"; if ( ctx.dim==CContext::_1 ) { - uint i; + int i; if ( ref->ti ) { ref->ti->tree_uival( &i, ctx ); } else { i = ctx.i; - if ( i==(uint)-1 ) + if ( i==(int)-1 ) throw "missing index i"; } if( i>= sj->size() ) @@ -325,9 +325,9 @@ void CNodeIva::tree_val( CResult& ret, const CContext& ctx ) const if ( var->typ == CVar::_Y && ctx.want_error && sj->dy.size() ) ret.dv.resize( ctx.nv ); - for( uint ii=0; ii<ctx.nv; ++ii ){ + for( int ii=0; ii<ctx.nv; ++ii ){ myctx.i = ii; - uint i; + int i; ref->ti->tree_uival( &i, myctx ); if( i >= sj->size() ) throw "i=" + S(i) + " exceeds scan size" + @@ -351,7 +351,7 @@ void CNodeIva::tree_val( CResult& ret, const CContext& ctx ) const "), found vec(" + S( sj->size() ); if ( var->typ == CVar::_I ) { ret.preset_v( ctx.nv ); - for( uint i=0; i<ctx.nv; ++i ) + for( int i=0; i<ctx.nv; ++i ) ret.v[i] = i; } else if ( var->typ == CVar::_X ) { ret.set_v( sj->x ); @@ -396,7 +396,7 @@ void CNodeIva::tree_val( CResult& ret, const CContext& ctx ) const //! Description of reference (for use in ??) -void CNodeIva::set_coord( CCoord& ret, uint k_in ) const +void CNodeIva::set_coord( CCoord& ret, int k_in ) const { if ( var->typ == CVar::_K ) { ret = CCoord("k",""); @@ -409,7 +409,7 @@ void CNodeIva::set_coord( CCoord& ret, uint k_in ) const return; } - uint k; + int k; if (ref->tk) { // get k from reference : CContext ctx( k_in ); @@ -468,7 +468,7 @@ CNodeRgr::CNodeRgr( PRgr& _rgr ) void CNodeRgr::tree_val( CResult& ret, const CContext& ctx ) const { ret.set_r( NReg::lastresult ); } -void CNodeRgr::set_coord( CCoord& ret, uint k ) const { +void CNodeRgr::set_coord( CCoord& ret, int k ) const { ret = CCoord( "$", "" ); } // primitiver gehts nicht //***************************************************************************// @@ -491,13 +491,13 @@ CNodeCev::CNodeCev( PRef& _ref, PNode _arg ) void CNodeCev::tree_val( CResult& ret, const CContext& ctx ) const { // get k from context: - uint k = ref->get_k( ctx ); + int k = ref->get_k( ctx ); // k points to a curve: POlc fc = NOlm::mem_get_C( k ); // get j from context: - uint j = ref->get_j( ctx, fc->nJ() ); + int j = ref->get_j( ctx, fc->nJ() ); // evaluate and pack function argument: CResult farg; @@ -511,7 +511,7 @@ void CNodeCev::tree_val( CResult& ret, const CContext& ctx ) const ret.set_r( fc->curve_val_sca( farg.r, k, j ) ); } -void CNodeCev::set_coord( CCoord& ret, uint k ) const { +void CNodeCev::set_coord( CCoord& ret, int k ) const { ret = CCoord( "c", "" ); } // primitiver gehts nicht @@ -531,12 +531,12 @@ void CNodeConv1::tree_val( CResult& ret, const CContext& ctx ) const // Return values are requested for n values of _DUMMY ( = t ): if ( !(ctx.vt) ) throw "BUG: convolution tree_val with *vt=0"; - uint n = ctx.vt->size(); + int n = ctx.vt->size(); ret.preset_v( n ); ret.dv.clear(); // Resolution is given by context 'ctx': - uint kconv, jconv; + int kconv, jconv; PSpec sv; NCurveFile::setConv( &sv, &kconv, &jconv, ctx.k, ctx.j ); @@ -564,7 +564,7 @@ void CNodeConv2::kdep_exec( bool *kd ) const shift->kdep_exec( kd ); } -void CNodeConv2::npar_exec( uint *np ) const +void CNodeConv2::npar_exec( int *np ) const { theory->npar_exec( np ); shift->npar_exec( np ); @@ -588,8 +588,8 @@ void CNodeConv::convolve( CResult& ret, const CContext& ctx, double theshift, const PSpec& sv, double conv_norm, double conv_step ) const { - uint n = ctx.vt->size(); - uint nv = sv->size(); + int n = ctx.vt->size(); + int nv = sv->size(); CResult res_theory; CContext cv_ctx(ctx); vector<double> tt; // theory grid @@ -649,8 +649,8 @@ void CNodePConv::convolve( CResult& ret, const CContext& ctx, double theshift, const PSpec& sv, double conv_norm, double conv_step ) const { - uint n = ctx.vt->size(); - uint nv = sv->size(); + int n = ctx.vt->size(); + int nv = sv->size(); CContext cv_ctx(ctx); vector<double> tt; cv_ctx.vt = &tt; @@ -732,7 +732,7 @@ void CNodeDirac::kdep_exec( bool *kd ) const shift->kdep_exec( kd ); } -void CNodeDirac::npar_exec( uint *np ) const +void CNodeDirac::npar_exec( int *np ) const { shift->npar_exec( np ); } @@ -743,7 +743,7 @@ void CNodeDirac::convolve( CResult& ret, const CContext& ctx, double theshift, const PSpec& sv, double conv_norm, double conv_step ) const { - uint n = ctx.vt->size(); + int n = ctx.vt->size(); // Delta function copies resolution. vector<double> tt(n), yy(n); // shift in t @@ -764,5 +764,5 @@ void CNodeDirac::copy_theory( CResult& ret, const CContext& ctx, ret.v[i] = fabs((*(ctx.vt))[i]-theshift)<1e-2 ? 1e2 : 0; } -void CNodeDirac::set_coord( CCoord& ret, uint k ) const { +void CNodeDirac::set_coord( CCoord& ret, int k ) const { ret = CCoord("resol", ""); } diff --git a/pub/src/node.h b/pub/src/node.h index d3d130f210bdf78ef36f1ff46d9229b80a6b396d..05f46c15bb7d00674e6afcd39702d4aee762f8cd 100644 --- a/pub/src/node.h +++ b/pub/src/node.h @@ -13,11 +13,11 @@ typedef boost::shared_ptr<class CVar> PVar; class CNodeFun: public CNode { private: - static const uint maxarg=3; + static const int maxarg=3; const class CFunc* fun; - uint narg; + int narg; PNode arg[maxarg]; - void npar_exec( uint *np ) const; + void npar_exec( int *np ) const; public: CNodeFun( const class CFunc *_fun, PNode a0 ); CNodeFun( const class CFunc *_fun, PNode a0, PNode a1 ); @@ -26,7 +26,7 @@ class CNodeFun: public CNode { bool has_dummy() const; bool has_conv() const; void kdep_exec( bool *kd ) const; - void set_coord( CCoord& ret, uint k ) const; + void set_coord( CCoord& ret, int k ) const; string tree_info() const; }; @@ -36,14 +36,14 @@ class CNodeFun: public CNode { class CNodeVal: public CNode { private: double val; - void npar_exec( uint *np ) const {;} + void npar_exec( int *np ) const {;} public: CNodeVal( double _val ); void tree_val( CResult& ret, const CContext& ctx ) const { ret.set_r( val ); } bool has_dummy() const { return false; } bool has_conv() const { return false; } - void set_coord( CCoord& ret, uint k ) const; + void set_coord( CCoord& ret, int k ) const; string tree_info() const; }; @@ -54,7 +54,7 @@ class CNodeIva: public CNode { private: PVar var; PRef ref; - void npar_exec( uint *np ) const; + void npar_exec( int *np ) const; public: CNodeIva( PVar _var, PRef _ref=PRef( new CRef() ) ) : var(_var), ref(_ref) {} @@ -62,7 +62,7 @@ class CNodeIva: public CNode { bool has_dummy() const { return false; } bool has_conv() const { return false; } void kdep_exec( bool *kd ) const { *kd = true; } - void set_coord( CCoord& ret, uint k ) const; + void set_coord( CCoord& ret, int k ) const; string tree_info() const { return "ref[" + var->var_info() + "]"; } }; @@ -72,13 +72,13 @@ class CNodeIva: public CNode { class CNodeRgr: public CNode { private: PRgr rgr; - void npar_exec( uint *np ) const {;} + void npar_exec( int *np ) const {;} public: CNodeRgr( PRgr& _rgr ); void tree_val( CResult& ret, const CContext& ctx ) const; bool has_dummy() const { return false; } bool has_conv() const { return false; } - void set_coord( CCoord& ret, uint k ) const; + void set_coord( CCoord& ret, int k ) const; string tree_info() const { return "$"; } }; @@ -87,7 +87,7 @@ class CNodeRgr: public CNode { class CNodeDummy: public CNode { private: - void npar_exec( uint *np ) const {;} + void npar_exec( int *np ) const {;} public: CNodeDummy() {} void tree_val( CResult& ret, const CContext& ctx ) const { @@ -95,7 +95,7 @@ class CNodeDummy: public CNode { ret.set_v( *(ctx.vt) ); } bool has_dummy() const { return true; } // this node _is_ t, so it has t bool has_conv() const { return false; } - void set_coord( CCoord& ret, uint k ) const { + void set_coord( CCoord& ret, int k ) const { throw "BUG: CNodeDummy::set_coord not expected to be needed"; } string tree_info() const { return "farg"; } }; @@ -107,14 +107,14 @@ class CNodeCev: public CNode { private: PRef ref; PNode arg; - void npar_exec( uint *np ) const {;} + void npar_exec( int *np ) const {;} public: CNodeCev( PRef& _ref, PNode _arg ); void tree_val( CResult& ret, const CContext& ctx ) const; bool has_dummy() const { return arg->has_dummy(); } bool has_conv() const { return arg->has_conv(); } void kdep_exec( bool *kd ) const { *kd = true; } - void set_coord( CCoord& ret, uint k ) const; + void set_coord( CCoord& ret, int k ) const; string tree_info() const { return "c[" + ref->ref_info() + "]"; } }; @@ -140,13 +140,13 @@ protected: class CNodeConv2: public CNodeConv1 { protected: PNode theory; - void npar_exec( uint *np ) const; + void npar_exec( int *np ) const; public: CNodeConv2( const PNode& _theory, const PNode& _shift ) : CNodeConv1( _shift ), theory(_theory) {} bool has_dummy() const { return theory->has_dummy(); } void kdep_exec( bool *kd ) const; - void set_coord( CCoord& ret, uint k ) const { theory->set_coord( ret, k ); } + void set_coord( CCoord& ret, int k ) const { theory->set_coord( ret, k ); } }; //! Convoluted function node. @@ -185,7 +185,7 @@ class CNodePConv: public CNodeConv2 { class CNodeDirac: public CNodeConv1 { private: - void npar_exec( uint *np ) const; + void npar_exec( int *np ) const; public: CNodeDirac( const PNode& _shift=PNode( new CNodeVal( 0.0 ) ) ) : CNodeConv1( _shift ) {}; @@ -196,7 +196,7 @@ class CNodeDirac: public CNodeConv1 { bool has_dummy() const { return true; } // has implicit t dependence bool has_conv() const { return true; } void kdep_exec( bool *kd ) const; - void set_coord( CCoord& ret, uint k ) const; + void set_coord( CCoord& ret, int k ) const; string tree_info() const { return "resol(" + shift->tree_info() + ")"; } }; diff --git a/pub/src/olf.cpp b/pub/src/olf.cpp index 296cc729260dbf167db63d97617187a1c84217e1..5d13755d091a70e2e2972d7758e19d405a4ce809 100644 --- a/pub/src/olf.cpp +++ b/pub/src/olf.cpp @@ -27,16 +27,16 @@ //! Remove one z. -void COlo::remove_z( uint iz ) +void COlo::remove_z( int iz ) { ZCo.erase( ZCo.begin()+iz ); - for( uint j=0; j<nJ(); ++j ) + for( int j=0; j<nJ(); ++j ) V[j]->z.erase( V[j]->z.begin()+iz ); -}; +} //! Line containing z values and curve parameters. -string COlo::infoLine( uint j ) const +string COlo::infoLine( int j ) const { const int LEN=15; char wrd[LEN]; @@ -48,7 +48,7 @@ string COlo::infoLine( uint j ) const //! Return value of iz-th z-variable for zentry j. -double COlo::z( uint j, uint iz ) const +double COlo::z( int j, int iz ) const { return V[j]->z[iz]; } @@ -72,7 +72,7 @@ COld::COld( class COlc const* c ) //! Return number of points in spectrum j. -uint COld::nPts( uint j ) const { +int COld::nPts( int j ) const { if ( !nJ() || j>=nJ() ) throw "BUG: nPts called with invalid j="+S(j); return VS(j)->size(); @@ -81,11 +81,11 @@ uint COld::nPts( uint j ) const { //! Return number of points if it is the same for all spectra. Else return 0. -uint COld::nPts() const { +int COld::nPts() const { if ( !nJ() ) throw "BUG: nPts() called while nSpec=0"; - uint np = VS(0)->size(); - for ( uint j=0; j<nJ(); ++j ) + int np = VS(0)->size(); + for ( int j=0; j<nJ(); ++j ) if (VS(j)->size()!=np) return 0; return np; } @@ -98,14 +98,14 @@ uint COld::nPts() const { //! Duplicate spectrum j, and return new shared pointer. -PZentry COld::new_zentry( uint j ) const +PZentry COld::new_zentry( int j ) const { return PZentry( new CSpec( *(VS(j)) ) ); } //! Duplicate curve j, and return new shared pointer. -PZentry COlc::new_zentry( uint j ) const +PZentry COlc::new_zentry( int j ) const { return PZentry( new CCurve( *(VC(j)) ) ); } @@ -146,7 +146,7 @@ void COld::copy_mainvec( POlo fin ) { POld fd = boost::dynamic_pointer_cast<class COld>( fin ); V.resize( fin->nJ() ); - for( uint j=0; j<fin->nJ(); ++j ) + for( int j=0; j<fin->nJ(); ++j ) V[j] = PZentry( new CSpec( *(fd->VS(j)) ) ); } @@ -154,14 +154,14 @@ void COlc::copy_mainvec( POlo fin ) { POlc fc = boost::dynamic_pointer_cast<class COlc>( fin ); V.resize( fin->nJ() ); - for( uint j=0; j<fin->nJ(); ++j ) + for( int j=0; j<fin->nJ(); ++j ) V[j] = PZentry( new CCurve( *(fc->VC(j)) ) ); } //! Return pointer to selected main vector entry. -PSpec COld::VS( uint j ) const +PSpec COld::VS( int j ) const { if( j>=V.size() ) throw "VS call with j=" + S(j) + " though V.size=" + S(V.size()); @@ -171,7 +171,7 @@ PSpec COld::VS( uint j ) const return s; } -PCurve COlc::VC( uint j ) const +PCurve COlc::VC( int j ) const { if( j>=V.size() ) throw "VC call with j=" + S(j) + " though V.size=" + S(V.size()); diff --git a/pub/src/olf.h b/pub/src/olf.h index 833a8ee62604637d3abf789fb708c3611e0d0619..7ab3f669eb2ba83cecc77daf6122569adf0408cb 100644 --- a/pub/src/olf.h +++ b/pub/src/olf.h @@ -30,16 +30,16 @@ class COlo { virtual ~COlo() {} ///< magic: makes dynamic_cast possible void clear() { V.clear(); } - void remove( uint j ) { V.erase( V.begin()+j ); } - void remove_z( uint iz ); - string infoLine( uint j ) const; + void remove( int j ) { V.erase( V.begin()+j ); } + void remove_z( int iz ); + string infoLine( int j ) const; virtual void copy_mainvec( POlo fin ) = 0; - uint nJ() const { return V.size(); } - uint nZ() const { return ZCo.size(); } - double z( uint j, uint iz ) const; - virtual PZentry new_zentry( uint j ) const = 0; + size_t nJ() const { return V.size(); } + size_t nZ() const { return ZCo.size(); } + double z( int j, int iz ) const; + virtual PZentry new_zentry( int j ) const = 0; virtual POlo new_olo( bool modified=true ) const = 0; virtual CCoord coord( class CVar* var ) const = 0; virtual void setCoord( class CVar* var, CCoord& co ) = 0; @@ -54,15 +54,15 @@ class COld : public COlo { explicit COld( class COlc const* fc ); // Trivially duplicated functions: - PSpec VS( uint j ) const; - PZentry new_zentry( uint j ) const; + PSpec VS( int j ) const; + PZentry new_zentry( int j ) const; POlo new_olo( bool modified=true ) const; POld new_old( bool modified=true ) const; void copy_mainvec( POlo fin ); // Pertinent functions: - uint nPts(uint j) const; - uint nPts() const; // 0 unless all spectra j have same nPts(j) + size_t nPts(int j) const; + size_t nPts() const; // 0 unless all spectra j have same nPts(j) CCoord coord( class CVar* var ) const; void setCoord( class CVar* var, CCoord& co ); }; @@ -76,21 +76,21 @@ class COlc : public COlo { enum TScrInp { _STDIN, _CMDLIN } scrInpMode; ///< Where pars are read from void curve_val_vec_expr( - vector<double> *ret, const vector<double>& vt, uint k, uint j ) const; + vector<double> *ret, const vector<double>& vt, int k, int j ) const; void curve_val_vec_syst( - vector<double> *ret, const vector<double>& vt, uint k, uint j ) const; + vector<double> *ret, const vector<double>& vt, int k, int j ) const; public: // Function: string expr; ///< The curve's definition (input expression). PNode T; ///< The curve's definition (parsed tree). - uint nP; ///< Number of parameters. + int nP; ///< Number of parameters. // Refined description: vector<CCoord> PCo; ///< Names and units of fit parameters. // Fitting: - uint kd; ///< Index of data file to be fitted. - uint kconv; ///< Index of resolution file to convolve with. + int kd; ///< Index of data file to be fitted. + int kconv; ///< Index of resolution file to convolve with. enum TWgt { _LIN, _LOG, _ERR } weighing; ///< Weight mode for fitting. bool plot_to_grid; ///< Use grid from file 'kd' ? string range_expr; ///< Restricts points to be fitted (input expression). @@ -100,8 +100,8 @@ class COlc : public COlo { kconv(-1), weighing( _ERR ), plot_to_grid( false ), range_expr("") {} // Trivially duplicated functions: - PCurve VC( uint j ) const; - PZentry new_zentry( uint j ) const; + PCurve VC( int j ) const; + PZentry new_zentry( int j ) const; POlo new_olo( bool modified=true ) const; POlc new_olc( bool modified=true ) const; void copy_mainvec( POlo fin ); @@ -119,8 +119,8 @@ class COlc : public COlo { void parseFunction( const string& expr ); void askCurve( const string& quest ); void curve_val_vec( - vector<double> *ret, const vector<double>& vt, uint k, uint j ) const; - double curve_val_sca( double farg, uint k, uint j ) const; + vector<double> *ret, const vector<double>& vt, int k, int j ) const; + double curve_val_sca( double farg, int k, int j ) const; }; diff --git a/pub/src/opr.cpp b/pub/src/opr.cpp index c25216c18ae667fefc7fdec9afc5507cadabd809..7379de16d8c150b53b85b2ed42494c90e7205b6a 100644 --- a/pub/src/opr.cpp +++ b/pub/src/opr.cpp @@ -47,7 +47,7 @@ void NOperate::Show( const string& subcmd ) throw "dummy argument t not allowed when operating on data"; while( POld fin=fiter() ) { - uint k = fiter.k(); + int k = fiter.k(); if ( fiter.size()>1 ) printf( ".. file %d:\n", fiter.k() ); @@ -55,16 +55,16 @@ void NOperate::Show( const string& subcmd ) string outj, outp; // determine length of longest spectrum: - uint ni = 0; - for ( uint j=0; j<fin->nJ(); j++) + int ni = 0; + for ( int j=0; j<fin->nJ(); j++) ni = max( ni, fin->VS(j)->size() ); // printout by i: - for ( uint i=0; i<ni; i++) { + for ( int i=0; i<ni; i++) { outj = ""; outp = ""; - for( uint j=0; j<fin->nJ(); j++ ){ + for( int j=0; j<fin->nJ(); j++ ){ const PSpec s = fin->VS(j); if( i>= s->size() ) continue; T->tree_point_val( &lval, 0, k, j, i ); @@ -113,7 +113,7 @@ void NOperate::Select( bool sel_del ) POlo fout( fin->new_olo() ); fout->lDoc.push_back((sel_del ? "md " : "mr ") + expr); - for ( uint j=0; j<fin->nJ(); j++ ) { + for ( int j=0; j<fin->nJ(); j++ ) { if ( fd ) { PSpec ein = fd->VS(j); PSpec eout = PSpec( new CSpec ); @@ -121,7 +121,7 @@ void NOperate::Select( bool sel_del ) vector<double> lvec( ein->size() ); T->tree_vec_val( &lvec, 0, fiter.k(), j ); bool with_dy = ein->dy.size(); - for ( uint i=0; i<ein->size(); i++ ) { + for ( int i=0; i<ein->size(); i++ ) { if ( sel_del ^ (bool) lvec[i] ) { if( with_dy ) eout->push_xyd( ein->x[i], ein->y[i], ein->dy[i] ); @@ -161,7 +161,7 @@ void NOperate::Pointwise( string llabel ) throw "dummy argument t not allowed when operating on data"; while( POlo fin=fiter() ){ - uint k = fiter.k(); + int k = fiter.k(); POld fd = P2D( fin ); POlc fc = P2C( fin ); @@ -184,14 +184,14 @@ void NOperate::Pointwise( string llabel ) } else if ( lref.typ==CVar::_Z ) { if( lref.num==-1 ) fout->ZCo.push_back( co ); - else if( lref.num>= fin->ZCo.size() ) + else if( lref.num >= fin->ZCo.size() ) throw "no such z coordinate to operate on"; else fout->ZCo[lref.num] = co; } else if ( lref.typ==CVar::_R ) { if( lref.num==-1 ) fout->RPar.push_back( CParam( co ) ); - else if( lref.num>= fin->RPar.size() ) + else if( lref.num >= fin->RPar.size() ) throw "no such real par to operate on"; else fout->RPar[lref.num].Co = co; @@ -213,7 +213,7 @@ void NOperate::Pointwise( string llabel ) fout->RPar[lref.num].val = val; } else { fout->V.resize( fin->nJ() ); - for( uint j=0; j<fin->nJ(); j++ ){ + for( int j=0; j<fin->nJ(); j++ ){ fout->V[j] = fin->new_zentry( j ); if ( fin->V[j]->protect ) continue; @@ -271,8 +271,8 @@ void NOperate::Integral(void) double res; while( POlo fin=fiter() ) { - uint k = fiter.k(); - uint nz = fin->ZCo.size(); + int k = fiter.k(); + int nz = fin->ZCo.size(); bool savable = nz > 0; POlo fout; @@ -288,7 +288,7 @@ void NOperate::Integral(void) sout->z.pop_back(); } - for ( uint j=0; j<fin->nJ(); j++ ) { + for ( int j=0; j<fin->nJ(); j++ ) { double xval, zval, dres; T->tree_point_val( &res, &dres, k, j ); if (!savable) { @@ -318,7 +318,7 @@ void NOperate::Integral(void) if ( !savable ) NReg::lastresult = res; } -}; +} //! Integral operations to generate not only new y, but also new x. @@ -337,7 +337,7 @@ void NOperate::IntXY(void) yco = CCoord( "y", "" ); while( POld fin=fiter() ) { - uint nz = fin->ZCo.size(); + int nz = fin->ZCo.size(); POld fout( fin->new_old() ); fout->lDoc.push_back( "oixy " + S(icolx) + " " + S(icoly) ); @@ -347,8 +347,8 @@ void NOperate::IntXY(void) PSpec sout( new CSpec ); - for ( uint j=0; j<fin->nJ(); j++ ) { - uint n = fin->nPts(j); + for ( int j=0; j<fin->nJ(); j++ ) { + int n = fin->nPts(j); if( icolx>=n || icoly>=n ) throw "not enough columns in spectrum " + S(j); sout->push_xy( fin->VS(j)->y[icolx], fin->VS(j)->y[icoly] ); @@ -363,7 +363,7 @@ void NOperate::IntXY(void) fout->V.push_back( sout ); NOlm::mem_store( fout, fiter.k() ); } -}; +} //***************************************************************************// @@ -375,7 +375,7 @@ namespace NIntOld { double evaluate( const PSpec& S ); static double arg2; static int iarg2; -}; +} void NIntOld::Opr() { @@ -489,7 +489,7 @@ void NIntOld::Opr() PSpec eout( new CSpec ); eout->z = fin->V[0]->z; eout->z.pop_back(); - for (uint j=0; j<fin->nJ(); j++) { + for (int j=0; j<fin->nJ(); j++) { double xval, zval, result; result = NIntOld::evaluate( fin->VS(j) ); if (!savable) { @@ -514,7 +514,7 @@ void NIntOld::Opr() NOlm::mem_store( fout ); } } -}; +} double NIntOld::evaluate( const PSpec& ein ) { @@ -669,23 +669,23 @@ void NOperate::Functional( const string& subcmd ) throw "invalid 'of' command"; } - for ( uint j=0; j<fin->nJ(); j++ ) { + for ( int j=0; j<fin->nJ(); j++ ) { PSpec sin = fin->VS(j); PSpec sout( new CSpec ); sout->copy_z_base( sin ); - uint n = sin->size(); + int n = sin->size(); if ( subcmd=="i" ) { // integrate sout->x = sin->x; sout->y.resize( n ); sout->y[0] = 0; - for ( uint i=1; i<n; ++i ) { + for ( int i=1; i<n; ++i ) { sout->y[i] = sout->y[i-1] + (sin->x[i] - sin->x[i-1]) * (sin->y[i] + sin->y[i-1]) / 2; } } else if ( subcmd=="d" ) { // derive - for( uint i=0; i<n-1; ++i ){ + for( int i=0; i<n-1; ++i ){ double dx = sin->x[i+1] - sin->x[i]; sout->push_xy( (sin->x[i+1] + sin->x[i] ) / 2, diff --git a/pub/src/opr.h b/pub/src/opr.h index 28078607d9d601f87b5ad63606dbbecfede3cb03..56becf2089323f04275a2e1af9d927563aaacead 100644 --- a/pub/src/opr.h +++ b/pub/src/opr.h @@ -16,10 +16,10 @@ namespace NOperate { void Integral(); void IntXY(); void Functional( const string& subcmd ); -}; +} //! Old-style integral operations with menu selection.* namespace NIntOld { void Opr(void); -}; +} diff --git a/pub/src/plot.cpp b/pub/src/plot.cpp index 5d828c74ef71e96c3f495047abe9de1401b69c75..7d5789097e06eb0ba254dbb86f1bbadc5ded9835 100644 --- a/pub/src/plot.cpp +++ b/pub/src/plot.cpp @@ -38,9 +38,9 @@ void determine_Xrange( CPlot* plot, CList* JSel ) POld fd; while((fd=fiter())) { JSel->evaluate( 0, fd->nJ()-1 ); - for ( uint iv=0; iv<JSel->size(); ++iv ) { + for ( size_t iv=0; iv<JSel->size(); ++iv ) { vx = &( fd->VS( JSel->V[iv] )->x ); - for ( uint i=0; i<vx->size(); ++i ){ + for ( size_t i=0; i<vx->size(); ++i ){ if ( plot->X.logflag && (*vx)[i]<=0 ) continue; if ( first ){ @@ -63,19 +63,18 @@ void determine_Xrange( CPlot* plot, CList* JSel ) void determine_Yrange( CPlot* plot, CList* JSel ) { - double inf, sup; - bool first=true; + double inf=INFINITY, sup=-INFINITY; NOlm::IterateO iter; POlo f; while( (f=iter()) ){ - uint k = iter.k(); + int k = iter.k(); POlc fc = P2C( f ); if ( fc && fc->kconv!=-1 ) continue; POld fd = P2D( f ); JSel->evaluate( 0, f->nJ()-1 ); - for ( uint iv=0; iv<JSel->size(); ++iv ){ - uint j = JSel->V[iv]; + for ( size_t iv=0; iv<JSel->size(); ++iv ){ + int j = JSel->V[iv]; PSpec s; if ( fd ){ s = fd->VS(j); @@ -84,22 +83,17 @@ void determine_Yrange( CPlot* plot, CList* JSel ) plot->X.set_xgrid( s->x, 97 ); fc->curve_val_vec( &(s->y), s->x, k, j ); } - for ( uint i=0; i<s->size(); i++ ) { + for ( size_t i=0; i<s->size(); i++ ) { if ( !plot->X.contains( s->x[i] ) ) continue; if ( plot->Y.logflag && s->y[i]<=0 ) continue; - if (first) { - inf=s->y[i], sup=s->y[i]; - first = false; - } else { - if (s->y[i]<inf) inf=s->y[i]; - if (s->y[i]>sup) sup=s->y[i]; - } + if (s->y[i]<inf) inf=s->y[i]; + if (s->y[i]>sup) sup=s->y[i]; } } } - if ( first ) + if ( inf==INFINITY || sup==-INFINITY ) throw "y range is empty"; plot->Y.setRoundedLimits( "y", inf, sup ); } @@ -111,16 +105,16 @@ void determine_Yrange( CPlot* plot, CList* JSel ) //! Plot scan j of data file fd; return number of points plotted. -int plot_data( CPlot* plot, POld fd, uint k, uint j, int pstyle ) +int plot_data( CPlot* plot, POld fd, int k, int j, int pstyle ) { const PSpec s = fd->VS(j); - uint n=s->x.size(); + size_t n=s->x.size(); if ( n!=s->y.size() ) throw "BUG: plot: x.size<>y.size"; // Filter: x,y -> xp,yp if inside frame - uint np=0, nxl=0, nxh=0, nyl=0, nyh=0; + int np=0, nxl=0, nxh=0, nyl=0, nyh=0; vector<double> xp, yp, dyp; - for ( uint i=0; i<n; i++ ) { + for ( int i=0; i<n; i++ ) { double x = s->x[i]; if ( !plot->X.contains(x) ) { if ( x<=plot->X.inf ){ @@ -180,21 +174,21 @@ int plot_data( CPlot* plot, POld fd, uint k, uint j, int pstyle ) //! Plot scan j of convolved curve file fc; return number of points plotted. -int plot_curve_convolved( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) +int plot_curve_convolved( CPlot* plot, POlc fc, int k, int j, int cstyle ) { vector<double> novec; - uint kconv, jconv; + int kconv, jconv; PSpec sconv; NCurveFile::setConv( &sconv, &kconv, &jconv, k, j ); vector<double> xp, yp; - for ( uint i=0; i<sconv->size(); ++i ){ + for ( size_t i=0; i<sconv->size(); ++i ){ double x = sconv->x[i]; if ( plot->X.contains( x ) ) xp.push_back( x ); } fc->curve_val_vec( &yp, xp, k, j ); vector<double> xo, yo; - for ( uint i=0; i<xp.size(); ++i ){ + for ( size_t i=0; i<xp.size(); ++i ){ if ( !( plot->X.contains( xp[i] ) && plot->Y.contains( yp[i] ) ) ) continue; @@ -213,7 +207,7 @@ int plot_curve_convolved( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) //! Plot scan j of curve file fc, using grid from file kd. -int plot_curve_to_grid( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) +int plot_curve_to_grid( CPlot* plot, POlc fc, int k, int j, int cstyle ) { if( fc->kd==-1 ) throw "data reference not set, incompatible with cg+"; @@ -225,7 +219,7 @@ int plot_curve_to_grid( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) vector<double> *xc = &(fd->VS(j)->x); vector<double> novec, yc, xp, yp; fc->curve_val_vec( &yc, *xc, k, j ); - for ( uint i=0; i<xc->size(); ++i ) { + for ( size_t i=0; i<xc->size(); ++i ) { if ( plot->X.contains((*xc)[i]) && plot->Y.contains(yc[i]) ) { xp.push_back( (*xc)[i] ); yp.push_back( yc[i] ); @@ -240,16 +234,16 @@ int plot_curve_to_grid( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) //! Plot scan j of non-convolved curve file fc on equidistant grid; //! return number of points plotted. -int plot_curve_equidist( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) +int plot_curve_equidist( CPlot* plot, POlc fc, int k, int j, int cstyle ) { vector<double> novec; // equidistant grid - uint npts = plot->equipoints; + int npts = plot->equipoints; vector<double> xc, yc, xp, yp; plot->X.set_xgrid( xc, npts ); fc->curve_val_vec( &yc, xc, k, j ); - for ( uint i=0; i<npts; ++i ) { + for ( int i=0; i<npts; ++i ) { if ( plot->X.contains(xc[i]) && plot->Y.contains(yc[i]) ) { xp.push_back( xc[i] ); yp.push_back( yc[i] ); @@ -264,7 +258,7 @@ int plot_curve_equidist( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) //! Plot scan j of non-convolved curve file fc, refining the grid where //! necessary; return number of points plotted. -int plot_curve_refine( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) +int plot_curve_refine( CPlot* plot, POlc fc, int k, int j, int cstyle ) { // refinement cares to: // - stop/start line when leaving/reentering/crossing(TODO) the frame @@ -275,7 +269,7 @@ int plot_curve_refine( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) vector<double> novec; // start with equidistant grid: - uint npts = plot->equipoints; + int npts = plot->equipoints; plot->X.set_xgrid( xc, npts ); // refinement loop: @@ -289,7 +283,7 @@ int plot_curve_refine( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) // cout << "DEB refinement #" <<iref<< ", xc.size=" <<xc.size()<< "\n"; // evaluate curve for grid xc: fc->curve_val_vec( &yc, xc, k, j ); - // for ( uint i=0; i<xc.size(); ++i ) + // for ( int i=0; i<xc.size(); ++i ) // printf ("DEB xc yc %12.6g %12.6g\n", xc[i], yc[i] ); // merge xc,yc and xn,yn: @@ -297,7 +291,7 @@ int plot_curve_refine( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) xn = xc; yn = yc; } else { vector<double> xa, ya; - uint ic=0, in=0; + size_t ic=0, in=0; for ( ; ic<xc.size() && in<xn.size(); ) { if ( plot->X.close_enough( xc[ic], xn[ic], 1e-7 ) ){ ++in; // skip new point @@ -322,7 +316,7 @@ int plot_curve_refine( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) xn = xa; yn = ya; } // cout << "DEB merger -> " << xn.size() << "\n"; - // for ( uint i=0; i<xn.size(); ++i ) + // for ( int i=0; i<xn.size(); ++i ) // printf ("DEB xn yn %12.6g %12.6g\n", xn[i], yn[i] ); // end of loop @@ -333,12 +327,12 @@ int plot_curve_refine( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) vector<double> xa, ya; xa.push_back( xn[0] ); ya.push_back( yn[0] ); - for ( uint i=1; i<xn.size()-1; ++i) { + for ( size_t i=1; i<xn.size()-1; ++i) { new_segment: xa.push_back( xn[i] ); ya.push_back( yn[i] ); if ( !plot->Y.contains(yn[i]) ) { - for ( uint ii=i+1; ii<xn.size()-1; ++ii ) { + for ( size_t ii=i+1; ii<xn.size()-1; ++ii ) { if ( plot->Y.contains(yn[ii]) ) { if ( ii-1>i ) { xa.push_back( xn[ii-1] ); @@ -354,13 +348,13 @@ int plot_curve_refine( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) ya.push_back( yn.back() ); xn = xa; yn = ya; // cout << "DEB within frame -> " << xn.size() << "\n"; - // for ( uint i=0; i<xn.size(); ++i ) + // for ( int i=0; i<xn.size(); ++i ) // printf ("DEB xy %12.6g %12.6g\n", xn[i], yn[i] ); // set additional base points: bool insert_next = false; xc.clear(); - for ( uint i=1; i<xn.size()-1; ++i ) { + for ( size_t i=1; i<xn.size()-1; ++i ) { if ( i<xn.size()-2 ) { double yi = ( (xn[i+1]-xn[i])*yn[i-1] + (xn[i]-xn[i-1])*yn[i+1] ) / @@ -389,7 +383,7 @@ int plot_curve_refine( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) } // temporary check if( xc.size() ) - for ( uint i=0; i<xc.size()-1; ++i ) + for ( size_t i=0; i<xc.size()-1; ++i ) if ( xc[i+1]<=xc[i] ) throw "BUG: new base points not sorted at " + S(i) + ": " + S(xc[i]) + " " + S(xc[i+1]); @@ -399,7 +393,7 @@ int plot_curve_refine( CPlot* plot, POlc fc, uint k, uint j, int cstyle ) vector<double> xa, ya; bool first_seg = true; npts = 0; - for ( uint i=0; i<xn.size(); ++i ) { + for ( size_t i=0; i<xn.size(); ++i ) { if ( plot->Y.contains(yn[i]) ) { xa.push_back( xn[i] ); ya.push_back( yn[i] ); @@ -467,23 +461,23 @@ void NPlot::Plot( class CPlot *plot, bool add, const string& mode ) // plot: while( POlo f = fiter() ){ - uint k = fiter.k(); + int k = fiter.k(); POld fd = P2D( f ); POlc fc = P2C( f ); plot->docTxLine( f->name ); - for (uint i=0; i<f->lDoc.size(); i++) + for (int i=0; i<f->lDoc.size(); i++) plot->docTxLine( " " + f->lDoc[i] ); if ( fc ) { vector<string> vs = fc->infoFile(); - for (uint i=0; i<vs.size(); i++) + for (int i=0; i<vs.size(); i++) plot->docTxLine( " " + vs[i] ); plot->docTxLine( " " + fc->infoScanHeader() ); } JSel.evaluate( 0, f->nJ()-1 ); - for ( uint iv=0; iv<JSel.size(); ++iv){ - uint j = JSel.V[iv]; + for ( size_t iv=0; iv<JSel.size(); ++iv){ + int j = JSel.V[iv]; if ( fd ) { if ( !plot_data( plot, fd, k, j, pstyle ) ) diff --git a/pub/src/plot.h b/pub/src/plot.h index 3531df94cb69ba3ddfed44ec8049dea85ae3d763..5e3ee2495c78a121f9712f0dc3dcd74c62632ebd 100644 --- a/pub/src/plot.h +++ b/pub/src/plot.h @@ -11,4 +11,4 @@ namespace NPlot { void Plot( class CPlot *plot, bool add, const string& mode="ask" ); -}; +} diff --git a/pub/src/reg.h b/pub/src/reg.h index 5f6844719cb0223c01d7edd41318e8ce31a20d15..3898a878095a12326de279402643ac2859946c82 100644 --- a/pub/src/reg.h +++ b/pub/src/reg.h @@ -12,9 +12,9 @@ class CRegRef { public: char typ; - uint num; + int num; - CRegRef( char _typ, uint _num=0 ) : typ(_typ), num(_num) {}; + CRegRef( char _typ, int _num=0 ) : typ(_typ), num(_num) {}; CRegRef( const string s ); }; @@ -22,4 +22,4 @@ class CRegRef { namespace NReg { extern double lastresult; -}; +} diff --git a/pub/src/rssm.cpp b/pub/src/rssm.cpp index 7ec9acbb93a02df7ce96c06e7ae9abcfb22c8114..d65f079560667134c6b8a8d9a61ea3b07634ed1e 100644 --- a/pub/src/rssm.cpp +++ b/pub/src/rssm.cpp @@ -38,7 +38,7 @@ class CRawfileSpheres { int measured_at; double measured_during; bool incremental; - uint ndet; + int ndet; vector<double> rawdata[6]; int maj_syntax, min_syntax, maj_outform, min_outform; }; @@ -104,7 +104,7 @@ void CRawfileSpheres::RdRawYam( ifstream& F_in ) strptime( date_string, "%F %A %H:%M:%S", &date_broken ); measured_until = mktime( &date_broken ); } else if ( key=="ndet" ){ - if( !triv::any2uint( val, &ndet ) ) + if( !triv::any2int( val, &ndet ) ) throw "DATA BUG: invalid ndet"; } else if ( key=="daq_time_step" ){ triv::string_extract_word( val, &bla, &blub ); @@ -123,8 +123,8 @@ void CRawfileSpheres::RdRawYam( ifstream& F_in ) throw "DATA BUG: no EnergyHistograms"; if ( doc["EnergyHistograms"].Type() != YAML::NodeType::Sequence ) throw "DATA BUG: EnergyHistograms is not a SEQUENCE"; - uint nEne = doc["EnergyHistograms"].size(); - for ( uint iEne = 0; iEne<nEne; iEne++ ) { + int nEne = doc["EnergyHistograms"].size(); + for ( int iEne = 0; iEne<nEne; iEne++ ) { if ( doc["EnergyHistograms"][iEne].Type() != YAML::NodeType::Sequence ) throw "DATA BUG: EnergyHistogram[" + S(iEne) + @@ -170,8 +170,8 @@ void CRawfileSpheres::RdRawYam( ifstream& F_in ) throw "no ChopperHistograms"; if ( doc["ChopperHistograms"].Type() != YAML::NodeType::Sequence ) throw "DATA BUG: ChopperHistograms is not a SEQUENCE"; - uint nCho = doc["ChopperHistograms"].size(); - for (uint iCho = 0; iCho<nCho; iCho++) { + size_t nCho = doc["ChopperHistograms"].size(); + for (size_t iCho = 0; iCho<nCho; iCho++) { if ( doc["ChopperHistograms"][iCho].Type() != YAML::NodeType::Sequence ) throw "DATA BUG: ChopperHistograms " + S(iCho) + " is not a SEQUENCE"; @@ -235,7 +235,7 @@ void NRSSM::ReadSpec( int flag ) double tstep = R.daq_time_step; vector<double> *raw = R.rawdata; - uint ndet = R.ndet; + int ndet = R.ndet; // *** set file headers *** @@ -280,7 +280,7 @@ void NRSSM::ReadSpec( int flag ) double x, tmeas, count; // transfer data from raw arrays: for( iolf=0; iolf<6; ++iolf ){ - for( int iraw=0; iraw<raw[iolf].size(); iraw+=(ndet+2) ){ + for( size_t iraw=0; iraw<raw[iolf].size(); iraw+=(ndet+2) ){ x = raw[iolf][iraw]; tmeas = raw[iolf][iraw+ndet+1]; if( tmeas<1 ) continue; @@ -312,7 +312,7 @@ void NRSSM::ReadSpec( int flag ) double x, tmeas, count; // transfer data from raw arrays: for( iolf=0; iolf<6; ++iolf ){ - for( int iraw=0; iraw<raw[iolf].size(); iraw+=(1+ndet*2) ){ + for( size_t iraw=0; iraw<raw[iolf].size(); iraw+=(1+ndet*2) ){ x = raw[iolf][iraw]; for ( int j=0; j<ndet; ++j ){ count = raw[iolf][iraw+1+j]; @@ -396,7 +396,7 @@ void NRSSM::ReadSeries( int flag ) RR.push_back( rf ); } - int nsub = RR.size(); + size_t nsub = RR.size(); if( nsub==0 ) throw "could not open file " + fnam; else if( nsub==1 ) diff --git a/pub/src/rssm.h b/pub/src/rssm.h index 93fc67e3932662e81fe161a339f02ae541d7e1d1..e3013c41d3c8d57b92b9611e43a3dc33d62d2d02 100644 --- a/pub/src/rssm.h +++ b/pub/src/rssm.h @@ -13,4 +13,4 @@ namespace NRSSM { void ReadSpec( int flag ); void ReadSeries( int flag ); void ReadSeries2Histo( int flag ); -}; +} diff --git a/pub/src/special.cpp b/pub/src/special.cpp index 94815ed71cf6c345026a181afe1c7526fdf8f185..5ceb9464d8a6ea026546bc67dc26339b4887d799 100644 --- a/pub/src/special.cpp +++ b/pub/src/special.cpp @@ -47,7 +47,7 @@ void NSpecial::FourierCosine() // olf.xco = CCoord("z", "m"); // olf.yco = CCoord("B_dim", "B-unit"); - for ( uint j=0; j<fin->nJ(); j++ ) { + for ( int j=0; j<fin->nJ(); j++ ) { PSpec sin = fin->VS(j); PSpec sout( new CSpec( *sin ) ); @@ -59,7 +59,7 @@ void NSpecial::FourierCosine() fftw_execute( plan ); sout->dy.clear(); - for ( uint i=0; i<n; ++i ) { + for ( int i=0; i<n; ++i ) { sout->y[i] /= sqrt(2.*n); } @@ -91,7 +91,7 @@ void NSpecial::Test() s->z.push_back( p ); s->resize(N,false); - for( uint n=0; n<N; ++n ) + for( int n=0; n<N; ++n ) s->x[n] = n; /// eigenvalue: @@ -100,17 +100,17 @@ void NSpecial::Test() // recursive calculation of eigenvector: s->y[0] = 1; s->y[1] = 1+lambda; - for( uint n=2; n<N; ++n ) + for( int n=2; n<N; ++n ) s->y[n] = -s->y[n-2] + (2+lambda)*s->y[n-1]; // normalize: double nor = 0; - for( uint n=0; n<N; ++n ) + for( int n=0; n<N; ++n ) nor += s->y[n] * s->y[n]; printf( "p=%i => check sum = %g, norm = %g\n", p, s->y[N-2]-(1+lambda)*s->y[N-1], nor ); s->z.push_back( nor ); - for( uint n=0; n<N; ++n ) + for( int n=0; n<N; ++n ) s->y[n] /= sqrt(nor); fout->V.push_back(s); diff --git a/pub/src/special.h b/pub/src/special.h index 9c647c5e01f674a9de27652bc5fecf6a2d4e2c9f..fb5fb0adc0e663d54b18abf0f17471f449686fc8 100644 --- a/pub/src/special.h +++ b/pub/src/special.h @@ -12,4 +12,4 @@ namespace NSpecial { void FourierCosine(); void Test(); -}; +} diff --git a/pub/src/var.h b/pub/src/var.h index b8e3563c365a34f7f1110ea40910e616dd57209c..7732eba48a62d6657e5d768ece39bc619d1ad93b 100644 --- a/pub/src/var.h +++ b/pub/src/var.h @@ -21,9 +21,9 @@ class CVar { _NJ, _NI // number of spectra in file, points in spectrum }; TTyp typ; - uint num; + int num; - CVar( TTyp _typ=_NOREF, uint _num=0 ) : typ(_typ), num(_num) {}; + CVar( TTyp _typ=_NOREF, int _num=0 ) : typ(_typ), num(_num) {}; CVar( const string s ); bool is_errvar() const { diff --git a/pub/src/zentry.cpp b/pub/src/zentry.cpp index 399b56f9719f21dd901a6cf478c7f7d69807c3c7..8edd0ef5478751cdc76dae27ac3d3e6a457bab18 100644 --- a/pub/src/zentry.cpp +++ b/pub/src/zentry.cpp @@ -41,8 +41,8 @@ bool CompareZ( const PZentry& E1, const PZentry& E2 ) { if( E1->z.size()!=E2->z.size() ) throw "BUG: inconsistent z.size in CompareZ"; - uint nz = E1->z.size(); - for( uint iz=0; iz<nz; ++iz ){ + size_t nz = E1->z.size(); + for( size_t iz=0; iz<nz; ++iz ){ if ( E1->z[iz] > E2->z[iz] ) return false; if ( E1->z[iz] < E2->z[iz] ) @@ -79,7 +79,7 @@ void CSpec::push_xyd( double _x, double _y, double _dy ) //! Remove data points according to given indices. -void CSpec::remove( uint from, uint to ) +void CSpec::remove( int from, int to ) { x.erase( x.begin()+from, x.begin()+to ); y.erase( y.begin()+from, y.begin()+to ); @@ -92,7 +92,7 @@ void CSpec::remove( uint from, uint to ) void CSpec::purge_dy() { - for( uint i=0; i<dy.size(); ++i ) + for( size_t i=0; i<dy.size(); ++i ) if( dy[i] ) return; dy.clear(); @@ -113,7 +113,7 @@ void CSpec::clear() //! Resize x,y,dy. -void CSpec::resize( uint n, bool with_dy ) +void CSpec::resize( int n, bool with_dy ) { x.resize( n ); y.resize( n ); @@ -123,7 +123,7 @@ void CSpec::resize( uint n, bool with_dy ) //! Return number of data points. -uint CSpec::size() const +int CSpec::size() const { if ( x.size()!=y.size() ) throw "BUG detected by spec::size: #x [" + @@ -139,10 +139,10 @@ uint CSpec::size() const void CSpec::intpol( const vector<double>& xx, vector<double>& yy ) const { - uint n = size(); + size_t n = size(); if( n<2 ) throw "invalid interpolation request: old grid has size " + S(n); - uint nn = xx.size(); + size_t nn = xx.size(); if( nn<1 ) throw "invalid interpolation request: new grid is empty"; yy.resize( nn, 0. ); @@ -157,7 +157,7 @@ void CSpec::intpol( const vector<double>& xx, vector<double>& yy ) const " required, while available data only cover " + S(x[0]) + " .. " + S(x[n-1]); - uint ii = 0, i = 0; + size_t ii = 0, i = 0; while ( i<n-1 && xx[ii]<x[n-1] ) { while ( xx[ii]>x[i+1] && i<n-1 ) ++i; @@ -174,7 +174,7 @@ void CSpec::intpol( const vector<double>& xx, vector<double>& yy ) const double CSpec::norm( string info ) const { - uint nv = size(); + size_t nv = size(); if ( nv < 2 ) throw "cannot compute norm of " + info + ": only " + S(nv) + " points"; @@ -191,7 +191,7 @@ double CSpec::norm( string info ) const throw "cannot compute norm of " + info + ": not ordered in x"; ret += y[nv-1] * dx; // the other steps: - for( int i=1; i<nv-1; ++i ) { + for( size_t i=1; i<nv-1; ++i ) { dx = ( x[i+1] - x[i-1] ) / 2; if ( dx <= 0 ) throw "cannot compute norm of " + info + ": not ordered in x"; @@ -211,7 +211,7 @@ bool CSpec::has_step( double step ) const { if( !step ) return false; - for( int i=0; i<size()-1; ++i ) { + for( size_t i=0; i<size()-1; ++i ) { if( fabs(x[i+1]-x[i]-step)>1e-12*step ) return false; } @@ -225,7 +225,7 @@ string CSpec::infoLine() const const int LEN=15; char wrd[LEN]; string out = ""; - for ( uint iz=0; iz<z.size(); iz++ ) { + for ( size_t iz=0; iz<z.size(); iz++ ) { snprintf( wrd, LEN, "%-12.7g", z[iz] ); out += wrd; if( iz<z.size()-1 ) @@ -256,12 +256,12 @@ string CCurve::infoLine() const const int LEN=15; char wrd[LEN]; string out = ""; - for ( uint iz=0; iz<z.size(); iz++ ) { + for ( size_t iz=0; iz<z.size(); iz++ ) { snprintf( wrd, LEN, "%-12.7g", z[iz] ); out += wrd; out += " "; } - for ( uint ip=0; ip<P.size(); ip++ ) { + for ( size_t ip=0; ip<P.size(); ip++ ) { out += fixed[ip] ? "x" : " "; snprintf( wrd, LEN, "%-12.7g", P[ip] ); out += wrd; diff --git a/pub/src/zentry.h b/pub/src/zentry.h index fd8fbc7952dff4ca6caaf012e9a98ca9dafecd56..5d7960b3490ffd66e1df3da5abc63ab18b53272a 100644 --- a/pub/src/zentry.h +++ b/pub/src/zentry.h @@ -46,12 +46,12 @@ class CSpec: public CZentry { void push_xy( double _x, double _y ); void push_xyd( double _x, double _y, double _dy ); void clear(); - void remove( uint begin, uint end ); - void resize( uint n, bool with_dy ); + void remove( int begin, int end ); + void resize( int n, bool with_dy ); void purge_dy(); // extract data: - uint size() const; + int size() const; void intpol( const vector<double>& in_x, vector<double>& out_y ) const; double intpol( double x ) const { vector<double> xx(1), yy(1); xx[0] = x; intpol(xx,yy); return yy[0]; }