- Timestamp:
- 09/06/09 22:53:06 (15 years ago)
- Location:
- library
- Files:
-
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r600 r604 18 18 NAMES = Array<string> ( BUFFER_STEP ); 19 19 } 20 21 string RV::show_all(){ 22 ostringstream os; 23 for(str2int_map::const_iterator iter=MAP.begin(); iter!=MAP.end(); iter++){ 24 os << "key: " << iter->first << " val: " << iter->second <<endl; 25 } 26 return os.str(); 27 }; 20 28 21 29 int RV::init ( const string &name, int size ) { … … 127 135 } 128 136 129 void RV::t ( int delta ) {137 void RV::t_plus ( int delta ) { 130 138 times += delta; 131 139 } -
library/bdm/base/bdmbase.h
r603 r604 149 149 friend std::ostream &operator<< ( std::ostream &os, const RV &rv ); 150 150 151 string to_string() {ostringstream o; o << this; return o.str();} 152 153 //! total size of a random variable 151 154 int _dsize() const { 152 155 return dsize; … … 160 163 //! Recount size of the corresponding data vector 161 164 int countsize() const; 165 //! Vector of cumulative sizes of RV 162 166 ivec cumsizes() const; 167 //! Number of named parts 163 168 int length() const { 164 169 return len; … … 206 211 207 212 //! Shift \c time by delta. 208 void t ( int delta );209 //!@} 210 211 //! @{ \name Auxiliaryfunctions213 void t_plus ( int delta ); 214 //!@} 215 216 //! @{ \name Time manipulation functions 212 217 //! returns rvs with time set to 0 and removed duplicates 213 218 RV remove_time() const { 214 219 return RV ( unique ( ids ), dummy ); 220 } 221 //! create new RV from the current one with time shifted by given value 222 RV copy_t(int dt) const { 223 RV tmp=*this; 224 tmp.t_plus(dt); 225 return tmp; 215 226 } 216 227 //! return rvs with expanded delayes and sorted in the order of: \f$ [ rv_{0}, rv_{-1}, rv_{ … … 220 231 int td = mint(); 221 232 for ( int i = -1; i >= td; i-- ) { 222 rvt.t ( -1 );233 rvt.t_plus ( -1 ); 223 234 tmp.add ( rvt ); //shift u1 224 235 } … … 266 277 //! Invalidate all named RVs. Use before initializing any RV instances, with care... 267 278 static void clear_all(); 279 //! function for debugging RV related stuff 280 string show_all(); 281 268 282 }; 269 283 UIREGISTER ( RV ); … … 497 511 return ep->_rv(); 498 512 } 499 const RV& _rvc() {513 const RV& _rvc() const { 500 514 return rvc; 501 515 } -
library/bdm/base/datasources.cpp
r565 r604 105 105 int mint = rrv0.mint(); 106 106 for ( int i = 0; i > mint; i-- ) { 107 pom.t ( -1 );107 pom.t_plus ( -1 ); 108 108 T.add ( pom ); 109 109 } -
library/bdm/base/datasources.h
r603 r604 291 291 U.set_size ( Urv._dsize() ); 292 292 for ( int i = -1; i >= td; i-- ) { 293 drv.t ( -1 );293 drv.t_plus ( -1 ); 294 294 Drv.add ( drv ); //shift u1 295 295 } … … 308 308 L_ut = L.add ( Urv, "" ); 309 309 310 mat &A = model._A();311 mat R = model._R();310 const mat &A = model._A(); 311 const mat R = model._R(); 312 312 if ( opt_L_theta ) { 313 313 L_theta = L.add ( RV ( "{th }", vec_1 ( A.rows() * A.cols() ) ), "t" ); … … 322 322 L.logit ( L_ut, U ); 323 323 324 mat &A = model._A();325 mat R = model._R();324 const mat &A = model._A(); 325 const mat R = model._R(); 326 326 if ( opt_L_theta ) { 327 327 L.logit ( L_theta, vec ( A._data(), A.rows() *A.cols() ) ); -
library/bdm/stat/exp_family.h
r583 r604 569 569 570 570 //!access function 571 vec& _mu_const(){return mu_const;}571 const vec& _mu_const() const {return mu_const;} 572 572 //!access function 573 mat& _A(){return A;}573 const mat& _A() const {return A;} 574 574 //!access function 575 mat _R() { return this->iepdf._R().to_mat(); }575 mat _R() const { return this->iepdf._R().to_mat(); } 576 576 577 577 //! Debug stream -
library/tests/datalink_test.cpp
r598 r604 93 93 RV ab=concat(a,b); 94 94 RV aa = a; 95 a.t (-1);95 a.t_plus(-1); 96 96 aa.add(a); 97 97 -
library/tests/rv_test.cpp
r586 r604 8 8 TEST ( test_rv ) { 9 9 RV::clear_all(); 10 10 11 11 RV a = RV ( "{a_in_test_rv }", "3" ); 12 12 CHECK ( a.equal ( a ) ); … … 137 137 RV join=a; 138 138 join.add(b); 139 RV tmp=a; tmp.t (1);139 RV tmp=a; tmp.t_plus(1); 140 140 join.add(tmp); 141 tmp=b; tmp.t (-1);141 tmp=b; tmp.t_plus(-1); 142 142 join.add(tmp); 143 143 144 144 CHECK_EQUAL(unique(join._ids()), vec_2(a.id(0), b.id(0))); // find only ids of a and b 145 145 CHECK_EQUAL(unique_complement(join._ids(), vec_1(a.id(0))), vec_1(b.id(0))); // complemnet of a in previous is b 146 147 //test if unique names work 148 RV uniq1("y",1); 149 RV uniq2("y",1); 150 151 CHECK_EQUAL(uniq1.id(0), uniq2.id(0)); 146 152 } -
library/tests/testResample.cpp
r488 r604 14 14 RV x ( "1" ); 15 15 RV xm = x; 16 xm.t ( -1 );16 xm.t_plus ( -1 ); 17 17 const 18 18 RV y ( "2" ); -
library/tests/test_particle.cpp
r488 r604 14 14 RV x ( "1" ); 15 15 RV xm = x; 16 xm.t ( -1 );16 xm.t_plus ( -1 ); 17 17 const 18 18 RV y ( "2" );