Changeset 604

Show
Ignore:
Timestamp:
09/06/09 22:53:06 (15 years ago)
Author:
smidl
Message:

change of syntax of RV

Location:
library
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/bdmbase.cpp

    r600 r604  
    1818        NAMES = Array<string> ( BUFFER_STEP ); 
    1919} 
     20 
     21string 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}; 
    2028 
    2129int RV::init ( const string &name, int size ) { 
     
    127135} 
    128136 
    129 void RV::t ( int delta ) { 
     137void RV::t_plus ( int delta ) { 
    130138        times += delta; 
    131139} 
  • library/bdm/base/bdmbase.h

    r603 r604  
    149149        friend std::ostream &operator<< ( std::ostream &os, const RV &rv ); 
    150150 
     151        string to_string() {ostringstream o; o << this; return o.str();} 
     152         
     153        //! total size of a random variable 
    151154        int _dsize() const { 
    152155                return dsize; 
     
    160163        //! Recount size of the corresponding data vector 
    161164        int countsize() const; 
     165        //! Vector of cumulative sizes of RV 
    162166        ivec cumsizes() const; 
     167        //! Number of named parts 
    163168        int length() const { 
    164169                return len; 
     
    206211 
    207212        //! Shift \c time by delta. 
    208         void t ( int delta ); 
    209         //!@} 
    210  
    211         //! @{ \name Auxiliary functions 
     213        void t_plus ( int delta ); 
     214        //!@} 
     215 
     216        //! @{ \name Time manipulation functions 
    212217        //! returns rvs with time set to 0 and removed duplicates 
    213218        RV remove_time() const { 
    214219                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; 
    215226        } 
    216227        //! return rvs with expanded delayes and sorted in the order of: \f$ [ rv_{0}, rv_{-1}, rv_{ 
     
    220231                int td = mint(); 
    221232                for ( int i = -1; i >= td; i-- ) { 
    222                         rvt.t ( -1 ); 
     233                        rvt.t_plus ( -1 ); 
    223234                        tmp.add ( rvt ); //shift u1 
    224235                } 
     
    266277        //! Invalidate all named RVs. Use before initializing any RV instances, with care... 
    267278        static void clear_all(); 
     279        //! function for debugging RV related stuff 
     280        string show_all(); 
     281 
    268282}; 
    269283UIREGISTER ( RV ); 
     
    497511                return ep->_rv(); 
    498512        } 
    499         const RV& _rvc() { 
     513        const RV& _rvc() const { 
    500514                return rvc; 
    501515        } 
  • library/bdm/base/datasources.cpp

    r565 r604  
    105105        int mint = rrv0.mint(); 
    106106        for ( int i = 0; i > mint; i-- ) { 
    107                 pom.t ( -1 ); 
     107                pom.t_plus ( -1 ); 
    108108                T.add ( pom ); 
    109109        } 
  • library/bdm/base/datasources.h

    r603 r604  
    291291                        U.set_size ( Urv._dsize() ); 
    292292                        for ( int i = -1; i >= td; i-- ) { 
    293                                 drv.t ( -1 ); 
     293                                drv.t_plus ( -1 ); 
    294294                                Drv.add ( drv ); //shift u1 
    295295                        } 
     
    308308                        L_ut = L.add ( Urv, "" ); 
    309309 
    310                         mat &A = model._A(); 
    311                         mat R = model._R(); 
     310                        const mat &A = model._A(); 
     311                        const mat R = model._R(); 
    312312                        if ( opt_L_theta ) { 
    313313                                L_theta = L.add ( RV ( "{th }", vec_1 ( A.rows() * A.cols() ) ), "t" ); 
     
    322322                        L.logit ( L_ut, U ); 
    323323 
    324                         mat &A = model._A(); 
    325                         mat R = model._R(); 
     324                        const mat &A = model._A(); 
     325                        const mat R = model._R(); 
    326326                        if ( opt_L_theta ) { 
    327327                                L.logit ( L_theta, vec ( A._data(), A.rows() *A.cols() ) ); 
  • library/bdm/stat/exp_family.h

    r583 r604  
    569569 
    570570                //!access function 
    571                 vec& _mu_const() {return mu_const;} 
     571                const vec& _mu_const() const {return mu_const;} 
    572572                //!access function 
    573                 mat& _A() {return A;} 
     573                const mat& _A() const {return A;} 
    574574                //!access function 
    575                 mat _R() { return this->iepdf._R().to_mat(); } 
     575                mat _R() const { return this->iepdf._R().to_mat(); } 
    576576 
    577577                //! Debug stream 
  • library/tests/datalink_test.cpp

    r598 r604  
    9393        RV ab=concat(a,b); 
    9494        RV aa = a; 
    95         a.t(-1); 
     95        a.t_plus(-1); 
    9696        aa.add(a);  
    9797 
  • library/tests/rv_test.cpp

    r586 r604  
    88TEST ( test_rv ) { 
    99        RV::clear_all(); 
    10  
     10         
    1111        RV a = RV ( "{a_in_test_rv }", "3" ); 
    1212        CHECK ( a.equal ( a ) ); 
     
    137137        RV join=a; 
    138138        join.add(b); 
    139         RV tmp=a; tmp.t(1); 
     139        RV tmp=a; tmp.t_plus(1); 
    140140        join.add(tmp); 
    141         tmp=b; tmp.t(-1); 
     141        tmp=b; tmp.t_plus(-1); 
    142142        join.add(tmp); 
    143143         
    144144        CHECK_EQUAL(unique(join._ids()), vec_2(a.id(0), b.id(0))); // find only ids of a and b 
    145145        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)); 
    146152} 
  • library/tests/testResample.cpp

    r488 r604  
    1414        RV x ( "1" ); 
    1515        RV xm = x; 
    16         xm.t ( -1 ); 
     16        xm.t_plus ( -1 ); 
    1717        const 
    1818        RV y ( "2" ); 
  • library/tests/test_particle.cpp

    r488 r604  
    1414        RV x ( "1" ); 
    1515        RV xm = x; 
    16         xm.t ( -1 ); 
     16        xm.t_plus ( -1 ); 
    1717        const 
    1818        RV y ( "2" );