- Timestamp:
- 09/04/08 20:27:01 (16 years ago)
- Location:
- bdm
- Files:
-
- 10 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/CMakeLists.txt
r143 r162 2 2 3 3 SET(BdmMath math/libDC.cpp math/libDC.h math/chmat.cpp math/chmat.h) 4 SET(BdmStat stat/libDS.cpp stat/libDS.h stat/libFN.cpp stat/libFN.h stat/libBM.cpp stat/libBM.h stat/libEF.cpp stat/libEF.h stat/loggers.cpp stat/loggers.h stat/emix.cpp stat/emix.h )4 SET(BdmStat stat/libDS.cpp stat/libDS.h stat/libFN.cpp stat/libFN.h stat/libBM.cpp stat/libBM.h stat/libEF.cpp stat/libEF.h stat/loggers.cpp stat/loggers.h stat/emix.cpp stat/emix.h stat/merger.cpp) 5 5 SET(BdmEstim estim/libKF.cpp estim/libKF.h estim/libPF.cpp estim/libPF.h estim/arx.cpp estim/arx.h) 6 6 SET(BdmUI userinfo.cpp userinfo.h) -
bdm/estim/arx.cpp
r141 r162 6 6 double lnc; 7 7 8 V.opupdt ( dt,frg ); 9 nu+=frg; 8 if (frg<1.0) { 9 V*=frg; 10 nu*=frg; 11 if (evalll) { 12 last_lognc = est.lognc(); 13 } 14 } 15 V.opupdt ( dt,1.0); 16 nu+=1.0; 10 17 11 18 if ( evalll ) { -
bdm/math/libDC.cpp
r141 r162 183 183 184 184 ldmat& ldmat::operator *= ( double x ) { 185 int i; 186 for ( i=0;i<D.length();i++ ){D( i )*=x;}; 185 D*=x; 187 186 return *this; 188 187 } -
bdm/stat/emix.h
r148 r162 31 31 */ 32 32 class emix : public epdf { 33 34 35 36 37 38 39 40 emix(RV &rv) : epdf(rv) {};41 42 void set_parameters(const vec &w, const Array<epdf*> &Coms);33 protected: 34 //! weights of the components 35 vec w; 36 //! Component (epdfs) 37 Array<epdf*> Coms; 38 public: 39 //!Default constructor 40 emix ( RV &rv ) : epdf ( rv ) {}; 41 //! Set weights \c w and components \c R 42 void set_parameters ( const vec &w, const Array<epdf*> &Coms ); 43 43 44 45 46 int i; vec mu = zeros(rv.count());47 for (i = 0;i < w.length();i++) {mu += w(i) * Coms(i)->mean(); }48 49 50 double evalpdflog(const vec &val) const {51 52 53 for (i = 0;i < w.length();i++) {sum += w(i) * Coms(i)->evalpdflog(val);}54 return log(sum);55 44 vec sample() const; 45 vec mean() const { 46 int i; vec mu = zeros ( rv.count() ); 47 for ( i = 0;i < w.length();i++ ) {mu += w ( i ) * Coms ( i )->mean(); } 48 return mu; 49 } 50 double evalpdflog ( const vec &val ) const { 51 int i; 52 double sum = 0.0; 53 for ( i = 0;i < w.length();i++ ) {sum += w ( i ) * Coms ( i )->evalpdflog ( val );} 54 return log ( sum ); 55 }; 56 56 57 57 //Access methods 58 59 58 //! returns a pointer to the internal mean value. Use with Care! 59 vec& _w() {return w;} 60 60 }; 61 61 … … 68 68 Note that 69 69 */ 70 class eprod: public epdf { 71 protected: 72 // 73 int n; 74 // pointers to epdfs 75 Array<epdf*> epdfs; 76 Array<mpdf*> mpdfs; 77 // 78 Array<ivec> rvinds; 79 Array<ivec> rvcinds; 80 //! Indicate independence of its factors 81 bool independent; 82 //! Indicate internal creation of mpdfs which must be destroyed 83 bool intermpdfs; 84 public: 85 //!Constructor from list of eFacs or list of mFacs 86 eprod(Array<mpdf*> mFacs): epdf(RV()), n(mFacs.length()), epdfs(n), mpdfs(mFacs), rvinds(n), rvcinds(n) { 87 int i; 88 intermpdfs = false; 89 for (i = 0;i < n;i++) { 90 rv.add(mpdfs(i)->_rv()); //add rv to common rvs. 91 epdfs(i) = &(mpdfs(i)->_epdf()); // add pointer to epdf 92 }; 93 independent = true; 94 //test rvc of mpdfs and fill rvinds 95 for (i = 0;i < n;i++) { 96 // find ith rv in common rv 97 rvinds(i) = mpdfs(i)->_rv().dataind(rv); 98 // find ith rvc in common rv 99 rvcinds(i) = mpdfs(i)->_rvc().dataind(rv); 100 if (rvcinds(i).length()>0) {independent = false;} 101 } 102 70 class mprod: public mpdf { 71 protected: 72 // 73 int n; 74 // pointers to epdfs 75 Array<epdf*> epdfs; 76 Array<mpdf*> mpdfs; 77 // 78 //! Indeces of rvs in common rv 79 Array<ivec> rvinds; 80 //! Indeces of rvc in common rv 81 Array<ivec> rvcinrv; 82 //! Indeces of rvc in common rvc 83 Array<ivec> rvcinds; 84 //! Indicate independence of its factors 85 bool independent; 86 // //! Indicate internal creation of mpdfs which must be destroyed 87 // bool intermpdfs; 88 public: 89 //!Constructor from list of eFacs or list of mFacs 90 mprod ( Array<mpdf*> mFacs ) : mpdf ( RV(), RV() ), n ( mFacs.length() ), epdfs ( n ), mpdfs ( mFacs ), rvinds ( n ), rvcinrv ( n ), rvcinds ( n ) { 91 int i; 92 // Create rv 93 for ( i = 0;i < n;i++ ) { 94 rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs. 95 epdfs ( i ) = & ( mpdfs ( i )->_epdf() ); // add pointer to epdf 103 96 }; 104 eprod(Array<epdf*> eFacs): epdf(RV()), n(eFacs.length()), epdfs(eFacs), mpdfs(n), rvinds(n), rvcinds(n) { 105 int i; 106 intermpdfs = true; 107 for (i = 0;i < n;i++) { 108 if (rv.add(eFacs(i)->_rv())) {it_error("Incompatible eFacs.rv!");} //add rv to common rvs. 109 mpdfs(i) = new mepdf(*(epdfs(i))); 110 epdfs(i) = &(mpdfs(i)->_epdf()); // add pointer to epdf 111 }; 112 independent = true; 113 //test rvc of mpdfs and fill rvinds 114 for (i = 0;i < n;i++) { 115 // find ith rv in common rv 116 rvinds(i) = mpdfs(i)->_rv().dataind(rv); 117 } 97 // Create rvc 98 for ( i = 0;i < n;i++ ) { 99 rvc.add ( mpdfs ( i )->_rv().subt ( rv ) ); //add rv to common rvs. 118 100 }; 119 101 120 double evalpdflog(const vec &val) const { 121 int i; 122 double res = 0.0; 123 for (i = n - 1;i > 0;i++) { 124 if (rvcinds(i).length() > 0) 125 {mpdfs(i)->condition(val(rvcinds(i)));} 126 // add logarithms 127 res += epdfs(i)->evalpdflog(val(rvinds(i))); 102 independent = true; 103 //test rvc of mpdfs and fill rvinds 104 for ( i = 0;i < n;i++ ) { 105 // find ith rv in common rv 106 rvinds ( i ) = mpdfs ( i )->_rv().dataind ( rv ); 107 // find ith rvc in common rv 108 rvcinrv ( i ) = mpdfs ( i )->_rvc().dataind ( rv ); 109 // find ith rvc in common rv 110 rvcinds ( i ) = mpdfs ( i )->_rvc().dataind ( rvc ); 111 // 112 if ( rvcinds ( i ).length() >0 ) {independent = false;} 113 if ( rvcinds ( i ).length() >0 ) {independent = false;} 114 } 115 }; 116 117 double evalpdflog ( const vec &val ) const { 118 int i; 119 double res = 0.0; 120 for ( i = n - 1;i > 0;i++ ) { 121 if ( rvcinds ( i ).length() > 0 ) 122 {mpdfs ( i )->condition ( val ( rvcinds ( i ) ) );} 123 // add logarithms 124 res += epdfs ( i )->evalpdflog ( val ( rvinds ( i ) ) ); 125 } 126 return res; 127 } 128 vec samplecond ( const vec &cond, double &ll ) { 129 vec smp=zeros ( rv.count() ); 130 vec condi; 131 for ( int i = ( n - 1 );i >= 0;i-- ) { 132 if ( rvcinds ( i ).length() > 0 ) { 133 condi = zeros ( rvcinrv.length() + rvcinds.length() ); 134 // copy data in condition 135 set_subvector ( condi,rvcinds ( i ), cond ); 136 // copy data in already generated sample 137 set_subvector ( condi,rvcinrv ( i ), smp ); 138 139 mpdfs ( i )->condition ( condi ); 128 140 } 129 return res; 141 // copy contribution of this pdf into smp 142 set_subvector ( smp,rvinds ( i ), epdfs ( i )->sample() ); 130 143 } 131 vec sample () const{ 132 vec smp=zeros(rv.count()); 133 for (int i = (n - 1);i >= 0;i--) { 134 if (rvcinds(i).length() > 0) 135 {mpdfs(i)->condition(smp(rvcinds(i)));} 136 set_subvector(smp,rvinds(i), epdfs(i)->sample()); 137 } 138 return smp; 139 } 140 vec mean() const{ 141 vec tmp(rv.count()); 142 if (independent) { 143 for (int i=0;i<n;i++) { 144 vec pom = epdfs(i)->mean(); 145 set_subvector(tmp,rvinds(i), pom); 146 } 147 } 148 else { 149 int N=50*rv.count(); 150 it_warning("eprod.mean() computed by sampling"); 151 tmp = zeros(rv.count()); 152 for (int i=0;i<N;i++){ tmp += sample();} 153 tmp /=N; 154 } 155 return tmp; 156 } 157 ~eprod(){if (intermpdfs) {for (int i=0;i<n;i++){delete mpdfs(i);}}}; 144 return smp; 145 } 146 mat samplecond ( const vec &cond, vec &ll, int N ) { 147 mat Smp(rv.count(),N); 148 for(int i=0;i<N;i++){Smp.set_col(i,samplecond(cond,ll(i)));} 149 return Smp; 150 } 151 // vec mean() const { 152 // vec tmp ( rv.count() ); 153 // if ( independent ) { 154 // for ( int i=0;i<n;i++ ) { 155 // vec pom = epdfs ( i )->mean(); 156 // set_subvector ( tmp,rvinds ( i ), pom ); 157 // } 158 // } 159 // else { 160 // int N=50*rv.count(); 161 // it_warning ( "eprod.mean() computed by sampling" ); 162 // tmp = zeros ( rv.count() ); 163 // for ( int i=0;i<N;i++ ) { tmp += sample();} 164 // tmp /=N; 165 // } 166 // return tmp; 167 // } 168 169 ~mprod() {}; 158 170 }; 159 171 … … 162 174 */ 163 175 class mmix : public mpdf { 164 165 166 167 168 169 170 171 mmix(RV &rv, RV &rvc) : mpdf(rv, rvc), Epdf(rv) {ep = &Epdf;};172 173 void set_parameters(const vec &w, const Array<mpdf*> &Coms) {174 Array<epdf*> Eps(Coms.length());176 protected: 177 //! Component (epdfs) 178 Array<mpdf*> Coms; 179 //!Internal epdf 180 emix Epdf; 181 public: 182 //!Default constructor 183 mmix ( RV &rv, RV &rvc ) : mpdf ( rv, rvc ), Epdf ( rv ) {ep = &Epdf;}; 184 //! Set weights \c w and components \c R 185 void set_parameters ( const vec &w, const Array<mpdf*> &Coms ) { 186 Array<epdf*> Eps ( Coms.length() ); 175 187 176 for (int i = 0;i < Coms.length();i++) {177 Eps(i) = & (Coms(i)->_epdf());178 179 Epdf.set_parameters(w, Eps);180 188 for ( int i = 0;i < Coms.length();i++ ) { 189 Eps ( i ) = & ( Coms ( i )->_epdf() ); 190 } 191 Epdf.set_parameters ( w, Eps ); 192 }; 181 193 182 void condition(const vec &cond) {183 for (int i = 0;i < Coms.length();i++) {Coms(i)->condition(cond);}184 194 void condition ( const vec &cond ) { 195 for ( int i = 0;i < Coms.length();i++ ) {Coms ( i )->condition ( cond );} 196 }; 185 197 }; 186 198 #endif //MX_H -
bdm/stat/libBM.cpp
r145 r162 7 7 using std::cout; 8 8 9 static int RVcounter=0; 10 9 11 void RV::init ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times ) { 10 // 12 //Refer 11 13 int i; 12 14 len = in_ids.length(); 13 15 //PRUDENT_MODE 14 16 // All vetors should be of same length 15 if ( ( len != in_ids.length() ) || \ 16 ( len != in_names.length() ) || \ 17 if ( ( len != in_names.length() ) || \ 17 18 ( len != in_sizes.length() ) || \ 18 19 ( len != in_times.length() ) ) { … … 28 29 }; 29 30 30 RV::RV ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times ) { 31 init ( in_ids, in_names, in_sizes, in_times ); 31 RV::RV ( Array<std::string> in_names, ivec in_sizes, ivec in_times ) { 32 int len = in_names.length(); 33 init ( linspace ( RVcounter+1, RVcounter+len ), in_names, in_sizes, in_times ); 34 RVcounter+=len; 32 35 } 33 36 34 RV::RV() : tsize ( 0 ), len ( 0 ) {}; 37 RV::RV ( Array<std::string> in_names, ivec in_sizes ) { 38 int len = in_names.length(); 39 init ( linspace ( RVcounter+1, RVcounter+len ), in_names, in_sizes, zeros_i ( in_names.length() ) ); 40 RVcounter+=len; 41 } 42 43 RV::RV ( Array<std::string> in_names ) { 44 int len = in_names.length(); 45 init ( linspace ( RVcounter+1, RVcounter+len ), in_names, ones_i ( in_names.length() ), zeros_i ( in_names.length() ) ); 46 RVcounter+=len; 47 } 48 49 RV::RV() : tsize ( 0 ), len ( 0 ), ids ( 0 ), names ( 0 ), sizes ( 0 ), times ( 0 ) {}; 35 50 36 51 bool RV::add ( const RV &rv2 ) { 37 52 // TODO 38 ivec ind = rv2.findself ( *this ); //should be -1 all the time 39 ivec index = itpp::find(ind==-1); 40 41 if ( index.length() < rv2.len ) { //conflict 42 ids = concat ( ids, rv2.ids(index) ); 43 sizes = concat ( sizes, rv2.sizes(index) ); 44 times = concat ( times, rv2.times(index) ); 45 names = concat ( names, rv2.names(to_Arr(index)) ); 53 if ( rv2.len>0 ) { //rv2 is nonempty 54 ivec ind = rv2.findself ( *this ); //should be -1 all the time 55 ivec index = itpp::find ( ind==-1 ); 56 57 58 if ( index.length() < rv2.len ) { //conflict 59 ids = concat ( ids, rv2.ids ( index ) ); 60 sizes = concat ( sizes, rv2.sizes ( index ) ); 61 times = concat ( times, rv2.times ( index ) ); 62 names = concat ( names, rv2.names ( to_Arr ( index ) ) ); 63 } 64 else { 65 ids = concat ( ids, rv2.ids ); 66 sizes = concat ( sizes, rv2.sizes ); 67 times = concat ( times, rv2.times ); 68 names = concat ( names, rv2.names ); 69 } 70 tsize = sum ( sizes ); 71 len = ids.length(); 72 return ( index.length() <rv2.len ); 46 73 } 47 else { 48 ids = concat ( ids, rv2.ids ); 49 sizes = concat ( sizes, rv2.sizes ); 50 times = concat ( times, rv2.times ); 51 names = concat ( names, rv2.names ); 74 else { //rv2 is empty 75 return true; 52 76 } 53 tsize = sum(sizes);54 len = ids.length();55 return (index.length()<rv2.len);56 57 77 // return *this; 58 78 }; 59 79 60 RV::RV ( ivec in_ids ) {61 62 len = in_ids.length();63 Array<std::string> A ( len );64 std::string rvstr = "rv";65 66 for ( int i = 0; i < len;i++ ) {67 A ( i ) = rvstr + to_str ( i );68 }69 70 init ( in_ids, A, ones_i ( len ), zeros_i ( len ) );71 }80 // RV::RV ( ivec in_ids ) { 81 // 82 // len = in_ids.length(); 83 // Array<std::string> A ( len ); 84 // std::string rvstr = "rv"; 85 // 86 // for ( int i = 0; i < len;i++ ) { 87 // A ( i ) = rvstr + to_str ( i ); 88 // } 89 // 90 // init ( in_ids, A, ones_i ( len ), zeros_i ( len ) ); 91 // } 72 92 73 93 RV RV::subselect ( ivec ind ) const { 74 return RV ( ids ( ind ), names ( to_Arr ( ind ) ), sizes ( ind ), times ( ind ) ); 94 RV ret; 95 ret.init ( ids ( ind ), names ( to_Arr ( ind ) ), sizes ( ind ), times ( ind ) ); 96 return ret; 75 97 } 76 98 … … 78 100 79 101 RV RV::operator() ( ivec ind ) const { 80 return RV ( ids ( ind ), names ( to_Arr ( ind ) ), sizes ( ind ), times ( ind ) ); 102 RV ret; 103 if ( ind.length() >0 ) { 104 ret.init ( ids ( ind ), names ( to_Arr ( ind ) ), sizes ( ind ), times ( ind ) ); 105 } 106 return ret; 81 107 } 82 108 … … 127 153 128 154 RV RV::subt ( const RV rv2 ) const { 155 cout << *this <<endl; 156 cout << rv2 <<endl; 157 129 158 ivec res = this->findself ( rv2 ); // nonzeros 130 159 ivec valid = itpp::find ( res == -1 ); //-1 => value not found => it remains -
bdm/stat/libBM.h
r145 r162 52 52 private: 53 53 //! auxiliary function used in constructor 54 void init ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times ); 55 public: 56 //! Full constructor which is called by the others 57 RV ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times ); 58 //! default constructor 59 RV ( ivec ids ); 60 //! Empty constructor will be set later 54 void init (ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times ); 55 public: 56 //! Full constructor 57 RV ( Array<std::string> in_names, ivec in_sizes, ivec in_times ); 58 //! Constructor with times=0 59 RV ( Array<std::string> in_names, ivec in_sizes ); 60 //! Constructor with sizes=1, times=0 61 RV ( Array<std::string> in_names ); 62 //! Constructor of empty RV 61 63 RV (); 62 64 … … 137 139 public: 138 140 //!default constructor 139 epdf() :rv ( ivec ( 0 )) {};141 epdf() :rv ( ) {}; 140 142 141 143 //!default constructor … … 180 182 // virtual fnc moment ( const int order = 1 ); 181 183 //! Returns a sample from the density conditioned on \c cond, \f$x \sim epdf(rv|cond)\f$. \param cond is numeric value of \c rv \param ll is a return value of log-likelihood of the sample. 182 virtual vec samplecond ( vec &cond, double &ll ) {this->condition ( cond );184 virtual vec samplecond (const vec &cond, double &ll ) {this->condition ( cond ); 183 185 vec temp= ep->sample(); 184 186 ll=ep->evalpdflog ( temp );return temp;}; 185 187 //! Returns \param N samples from the density conditioned on \c cond, \f$x \sim epdf(rv|cond)\f$. \param cond is numeric value of \c rv \param ll is a return value of log-likelihood of the sample. 186 virtual mat samplecond ( vec &cond, vec &ll, int N ) {188 virtual mat samplecond (const vec &cond, vec &ll, int N ) { 187 189 this->condition ( cond ); 188 190 mat temp ( rv.count(),N ); vec smp ( rv.count() ); -
bdm/stat/libEF.cpp
r129 r162 112 112 }; 113 113 114 vec mgamma::samplecond ( vec &cond, double &ll ) {115 this->condition(cond );116 vec smp = epdf.sample();117 ll = epdf.evalpdflog ( smp );118 return smp;119 };120 121 //Fixme repetition of mlnorm.samplecond.122 mat mgamma::samplecond ( vec &cond, vec &lik, int n ) {123 int i;124 int dim = rv.count();125 mat Smp ( dim,n );126 vec smp ( dim );127 this->condition ( cond );128 129 for ( i=0; i<n; i++ ) {130 smp = epdf.sample();131 lik ( i ) = epdf.eval ( smp );132 Smp.set_col ( i ,smp );133 }134 135 return Smp;136 };137 138 114 ivec eEmp::resample ( RESAMPLING_METHOD method ) { 139 115 ivec ind=zeros_i ( n ); -
bdm/stat/libEF.h
r129 r162 270 270 //! Set value of \c k 271 271 void set_parameters ( double k ); 272 //!Generate one sample of the posterior273 vec samplecond ( vec &cond, double &lik );274 //!Generate matrix of samples of the posterior275 mat samplecond ( vec &cond, vec &lik, int n );276 272 void condition ( const vec &val ) {*_beta=k/val;}; 277 273 }; -
bdm/stat/loggers.cpp
r102 r162 8 8 #endif 9 9 10 void memlog::itsave (const char* fname){11 it_file itf (fname);10 void memlog::itsave ( const char* fname ) { 11 it_file itf ( fname ); 12 12 int i; 13 for (i=0; i<entries.length();i++){ 14 itf << Name(names(i)) << vectors(i); 13 for ( i=0; i<entries.length();i++ ) { 14 if ( names ( i ).length() <1 ) { 15 std::ostringstream o; 16 o<<"Variable"<<i; 17 itf << Name ( o.str() ) << vectors ( i ); 18 } 19 else { 20 itf << Name ( names ( i ) ) << vectors ( i ); 21 } 15 22 } 16 23 } … … 26 33 27 34 // Initialize directory 28 makedir (dirname); //35 makedir ( dirname ); // 29 36 30 37 // directory OK, or it can be overwritten … … 40 47 scalarnames ( ii ) = names ( i ) + "_" + entries ( i ).name ( j ); 41 48 ii++; 42 } else { 49 } 50 else { 43 51 for ( k=0;k<rvsize;k++ ) { //for all scalars in given RV 44 52 sprintf ( num,"%d",k ); … … 62 70 memlog::init(); 63 71 72 //Delete old data 64 73 write_buffers ( 0 ); 65 74 } … … 81 90 for ( i=0;i<nen;i++ ) { //for entries 82 91 Dt = vectors ( i )._data(); 83 DtRows = vectors (i).rows();84 92 DtRows = vectors ( i ).rows(); 93 85 94 jj=0; 86 95 for ( j=0;j<entries ( i ).length();j++ ) { //for RVs in entries … … 93 102 fp = open ( filename, O_CREAT | O_WRONLY | O_APPEND, 00644 ); 94 103 95 write ( fp,&Dt[jj* (DtRows)],(Len)*sizeof ( double ) );104 write ( fp,&Dt[jj* ( DtRows ) ], ( Len ) *sizeof ( double ) ); 96 105 close ( fp ); 97 106 … … 106 115 } 107 116 108 void dirfilelog::step ( bool final) {117 void dirfilelog::step ( ) { 109 118 110 if ( final ) { 111 if ( ind>0 ) 112 write_buffers ( ind ); //assuming here that i+1 was not filled 113 } else 114 if ( ind== ( maxlen -1 ) ) { 115 write_buffers ( ind+1 ); 116 ind = 0; 117 } else 118 ind++; 119 if ( ind== ( maxlen -1 ) ) { 120 write_buffers ( ind+1 ); 121 ind = 0; 122 } 123 else 124 ind++; 119 125 120 126 } 127 128 void dirfilelog::finalize ( ) { 129 if ( ind>0 ) 130 write_buffers ( ind ); //assuming here that i+1 was not filled 131 } -
bdm/stat/loggers.h
r145 r162 37 37 38 38 //! returns an identifier which will be later needed for calling the log() function 39 virtual int add ( RVrv, string name="" ) {39 virtual int add (const RV &rv, string name="" ) { 40 40 int id=entries.length(); 41 41 names=concat ( names, name ); // diff … … 48 48 virtual void logit ( int id, vec v ) =0; 49 49 50 //! consider this record to be complete 51 virtual void step(bool final=false) =0; 50 //! Shifts storage position for another time step. 51 virtual void step() =0; 52 53 //! Finalize storing information 54 virtual void finalize() {}; 52 55 53 56 //! for future use … … 82 85 ; 83 86 } 84 void step(bool final=false) {if ( ind<maxlen ) ind++; else it_error ( "memlog::ind is too high;" );} 85 void logit ( int id, vec v ) {vectors ( id ).set_row ( ind,v );} 87 void step() {if ( ind<maxlen ) ind++; else it_error ( "memlog::ind is too high;" );} 88 void logit ( int id, vec v ) { 89 it_assert_debug(id<vectors.length(),"Logger was not initialized, run init()."); 90 vectors ( id ).set_row ( ind,v );} 86 91 //! Save values into an itfile named after \c fname. 87 92 void itsave(const char* fname); … … 110 115 //! Initialize storage 111 116 void init(); 112 void step(bool final=false); 117 void step(); 118 void finalize(); 113 119 /*! \brief Write memory storage to disk. 114 120 @param Len length of buffer to be written, if 0 the file is truncated at 0.