Show
Ignore:
Timestamp:
11/25/09 12:14:38 (15 years ago)
Author:
mido
Message:

ASTYLER RUN OVER THE WHOLE LIBRARY, JUPEE

Files:
1 modified

Legend:

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

    r733 r737  
    149149        friend std::ostream &operator<< ( std::ostream &os, const RV &rv ); 
    150150 
    151         string to_string() const {ostringstream o; o << *this; return o.str();} 
    152          
     151        string to_string() const { 
     152                ostringstream o; 
     153                o << *this; 
     154                return o.str(); 
     155        } 
     156 
    153157        //! total size of a random variable 
    154158        int _dsize() const { 
     
    183187        //! returns name of a scalar at position scalat, i.e. it can be in the middle of vector name, in that case it adds "_%d" to it 
    184188        std::string scalarname ( int scalat ) const { 
    185                 bdm_assert(scalat<dsize,"Wrong input index"); 
    186                 int id=0; 
    187                 int scalid=0; 
    188                 while (scalid+SIZES(ids(id))<=scalat)  { scalid+=SIZES(ids(id)); id++;}; 
     189                bdm_assert ( scalat < dsize, "Wrong input index" ); 
     190                int id = 0; 
     191                int scalid = 0; 
     192                while ( scalid + SIZES ( ids ( id ) ) <= scalat )  { 
     193                        scalid += SIZES ( ids ( id ) ); 
     194                        id++; 
     195                }; 
    189196                //now id is the id of variable of interest 
    190                 if (size(id)==1) 
     197                if ( size ( id ) == 1 ) 
    191198                        return  NAMES ( ids ( id ) ); 
    192199                else 
    193                         return  NAMES ( ids ( id ) )+ "_" + num2str(scalat-scalid); 
     200                        return  NAMES ( ids ( id ) ) + "_" + num2str ( scalat - scalid ); 
    194201 
    195202        } 
     
    233240        } 
    234241        //! create new RV from the current one with time shifted by given value 
    235         RV copy_t(int dt) const { 
    236                 RV tmp=*this; 
    237                 tmp.t_plus(dt); 
     242        RV copy_t ( int dt ) const { 
     243                RV tmp = *this; 
     244                tmp.t_plus ( dt ); 
    238245                return tmp; 
    239246        } 
     
    266273        //! Minimum time-offset 
    267274        int mint() const { 
    268                 return times.length()>0 ? min (times) : 0; 
     275                return times.length() > 0 ? min ( times ) : 0; 
    269276        } 
    270277        //! Minimum time-offset of ids of given RVs 
    271         int mint(const RV &rv) const { 
    272                 bvec belong=zeros_b(len); 
    273                 for (int r=0; r<rv.length(); r++){ 
    274                         belong = belong | (ids == rv.id(r)); 
    275                 } 
    276                 return times.length()>0 ? min (get_from_bvec(times,belong)) : 0; 
     278        int mint ( const RV &rv ) const { 
     279                bvec belong = zeros_b ( len ); 
     280                for ( int r = 0; r < rv.length(); r++ ) { 
     281                        belong = belong | ( ids == rv.id ( r ) ); 
     282                } 
     283                return times.length() > 0 ? min ( get_from_bvec ( times, belong ) ) : 0; 
    277284        } 
    278285        //!@} 
     
    281288 
    282289        \code 
    283         class = 'RV';                    
     290        class = 'RV'; 
    284291        names = {'a', 'b', 'c', ...};   // UNIQUE IDENTIFIER same names = same variable 
    285                                                                         // names are also used when storing results  
     292                                                                        // names are also used when storing results 
    286293        --- optional --- 
    287294        sizes = [1, 2, 3, ...];         // size of each name. default = ones() 
     
    292299        void from_setting ( const Setting &set ); 
    293300 
    294         void to_setting( Setting &set ) const; 
     301        void to_setting ( Setting &set ) const; 
    295302 
    296303        //! Invalidate all named RVs. Use before initializing any RV instances, with care... 
     
    312319*/ 
    313320class logger : public root { 
    314         protected: 
    315                 //! RVs of all logged variables. 
    316                 Array<RV> entries; 
    317                 //! Names of logged quantities, e.g. names of algorithm variants 
    318                 Array<string> names; 
    319                 //!separator of prefixes of entries 
    320                 const string separator; 
    321                 //! Root Setting for storing Settings 
    322                 Config setting_conf; 
    323                 //! list of Settings for specific ids 
    324                 Array<Setting*> settings; 
    325         public: 
    326                 //!Default constructor 
    327                 logger(const string separator0) : entries ( 0 ), names ( 0 ), separator(separator0) {} 
    328                  
    329                 //! returns an identifier which will be later needed for calling the \c logit() function 
    330                 //! For empty RV it returns -1, this entry will be ignored by \c logit(). 
    331                 virtual int add_vector ( const RV &rv, string prefix = "" ) { 
    332                         int id; 
    333                         if ( rv._dsize() > 0 ) { 
    334                                 id = entries.length(); 
    335                                 names = concat ( names, prefix ); // diff 
    336                                 entries.set_length ( id + 1, true ); 
    337                                 entries ( id ) = rv; 
    338                         } else { 
    339                                 id = -1; 
    340                         } 
    341                         return id; // identifier of the last entry 
    342                 } 
    343                 virtual int add_setting(const string &prefix){ 
    344                         Setting &root=setting_conf.getRoot(); 
    345                         int id=root.getLength(); //root must be group!! 
    346                         if (prefix.length()>0){ 
    347                                 settings.set_length(id+1,true); 
    348                                 settings(id) = &root.add(prefix, Setting::TypeList); 
    349                         } else {id=-1;} 
    350                         return id; 
    351                 } 
    352                  
    353                 //! log this vector 
    354                 virtual void log_vector ( int id, const vec &v ) { 
    355                         bdm_error ( "Not implemented" ); 
    356                 }; 
    357                  
    358                 virtual Setting & log_to_setting (int id){ 
    359                         return settings(id)->add(Setting::TypeGroup); 
    360                 } 
    361                  
    362                 //! log this double 
    363                 virtual void logit ( int id, const double &d ) { 
    364                         bdm_error ( "Not implemented" ); 
    365                 }; 
    366                  
    367                 //! Shifts storage position for another time step. 
    368                 virtual void step() { 
    369                         bdm_error ( "Not implemneted" ); 
    370                 }; 
    371                  
    372                 //! Finalize storing information 
    373                 virtual void finalize() {}; 
    374                  
    375                 //! Initialize the storage 
    376                 virtual void init() {}; 
    377                  
    378                 //!separator of prefixes for this logger 
    379                 const string& prefix_sep() {return separator;} 
     321protected: 
     322        //! RVs of all logged variables. 
     323        Array<RV> entries; 
     324        //! Names of logged quantities, e.g. names of algorithm variants 
     325        Array<string> names; 
     326        //!separator of prefixes of entries 
     327        const string separator; 
     328        //! Root Setting for storing Settings 
     329        Config setting_conf; 
     330        //! list of Settings for specific ids 
     331        Array<Setting*> settings; 
     332public: 
     333        //!Default constructor 
     334        logger ( const string separator0 ) : entries ( 0 ), names ( 0 ), separator ( separator0 ) {} 
     335 
     336        //! returns an identifier which will be later needed for calling the \c logit() function 
     337        //! For empty RV it returns -1, this entry will be ignored by \c logit(). 
     338        virtual int add_vector ( const RV &rv, string prefix = "" ) { 
     339                int id; 
     340                if ( rv._dsize() > 0 ) { 
     341                        id = entries.length(); 
     342                        names = concat ( names, prefix ); // diff 
     343                        entries.set_length ( id + 1, true ); 
     344                        entries ( id ) = rv; 
     345                } else { 
     346                        id = -1; 
     347                } 
     348                return id; // identifier of the last entry 
     349        } 
     350        virtual int add_setting ( const string &prefix ) { 
     351                Setting &root = setting_conf.getRoot(); 
     352                int id = root.getLength(); //root must be group!! 
     353                if ( prefix.length() > 0 ) { 
     354                        settings.set_length ( id + 1, true ); 
     355                        settings ( id ) = &root.add ( prefix, Setting::TypeList ); 
     356                } else { 
     357                        id = -1; 
     358                } 
     359                return id; 
     360        } 
     361 
     362        //! log this vector 
     363        virtual void log_vector ( int id, const vec &v ) { 
     364                bdm_error ( "Not implemented" ); 
     365        }; 
     366 
     367        virtual Setting & log_to_setting ( int id ) { 
     368                return settings ( id )->add ( Setting::TypeGroup ); 
     369        } 
     370 
     371        //! log this double 
     372        virtual void logit ( int id, const double &d ) { 
     373                bdm_error ( "Not implemented" ); 
     374        }; 
     375 
     376        //! Shifts storage position for another time step. 
     377        virtual void step() { 
     378                bdm_error ( "Not implemneted" ); 
     379        }; 
     380 
     381        //! Finalize storing information 
     382        virtual void finalize() {}; 
     383 
     384        //! Initialize the storage 
     385        virtual void init() {}; 
     386 
     387        //!separator of prefixes for this logger 
     388        const string& prefix_sep() { 
     389                return separator; 
     390        } 
    380391}; 
    381392 
     
    429440        //! @{ 
    430441 
    431         pdf() : dimc ( 0 ), rvc(), dim(0), rv() { } 
    432  
    433         pdf ( const pdf &m ) : dimc ( m.dimc ), rvc ( m.rvc ), dim( m.dim), rv( m.rv ) { } 
    434          
     442        pdf() : dimc ( 0 ), rvc(), dim ( 0 ), rv() { } 
     443 
     444        pdf ( const pdf &m ) : dimc ( m.dimc ), rvc ( m.rvc ), dim ( m.dim ), rv ( m.rv ) { } 
     445 
    435446        //! copy of the current object - make sure to implement 
    436         virtual pdf* _copy_() const {return new pdf(*this);} 
     447        virtual pdf* _copy_() const { 
     448                return new pdf ( *this ); 
     449        } 
    437450        //!@} 
    438451 
     
    488501 
    489502        //! access function 
    490         void set_dim(int d) {dim=d;} 
     503        void set_dim ( int d ) { 
     504                dim = d; 
     505        } 
    491506        //! access function 
    492         void set_dimc(int d) {dimc=d;} 
     507        void set_dimc ( int d ) { 
     508                dimc = d; 
     509        } 
    493510        //! Load from structure with elements: 
    494511        //!  \code 
     
    535552        @{*/ 
    536553        epdf() {}; 
    537         epdf ( const epdf &e ) : pdf(e) {}; 
     554        epdf ( const epdf &e ) : pdf ( e ) {}; 
    538555        void set_parameters ( int dim0 ) { 
    539556                dim = dim0; 
    540557        } 
    541         epdf* _copy_() const {return new epdf(*this);} 
     558        epdf* _copy_() const { 
     559                return new epdf ( *this ); 
     560        } 
    542561        //!@} 
    543562 
     
    603622        //!  #1 mean 
    604623        //!  #2 mean + lower & upper bound 
    605         void log_register(logger &L, const string &prefix){ 
     624        void log_register ( logger &L, const string &prefix ) { 
    606625                RV r; 
    607626                if ( isnamed() ) { 
     
    610629                        r = RV ( "", dimension() ); 
    611630                }; 
    612                 root::log_register(L,prefix); 
    613                  
     631                root::log_register ( L, prefix ); 
     632 
    614633                // log full data 
    615                 if (log_level==10) { 
    616                         logrec->ids.set_size(1); 
    617                         logrec->ids(0) = logrec->L.add_setting(prefix); 
     634                if ( log_level == 10 ) { 
     635                        logrec->ids.set_size ( 1 ); 
     636                        logrec->ids ( 0 ) = logrec->L.add_setting ( prefix ); 
    618637                } else { 
    619                         // log only  
    620                         logrec->ids.set_size(3); 
    621                         if (log_level >0){ 
    622                                 logrec->ids(0) = logrec->L.add_vector ( r, prefix + logrec->L.prefix_sep()+ "mean" ); 
     638                        // log only 
     639                        logrec->ids.set_size ( 3 ); 
     640                        if ( log_level > 0 ) { 
     641                                logrec->ids ( 0 ) = logrec->L.add_vector ( r, prefix + logrec->L.prefix_sep() + "mean" ); 
    623642                        } 
    624                         if (log_level >1){ 
    625                                 logrec->ids(1) = logrec->L.add_vector ( r, prefix + logrec->L.prefix_sep()+ "lb" ); 
    626                                 logrec->ids(2) = logrec->L.add_vector ( r, prefix + logrec->L.prefix_sep()+ "ub" ); 
     643                        if ( log_level > 1 ) { 
     644                                logrec->ids ( 1 ) = logrec->L.add_vector ( r, prefix + logrec->L.prefix_sep() + "lb" ); 
     645                                logrec->ids ( 2 ) = logrec->L.add_vector ( r, prefix + logrec->L.prefix_sep() + "ub" ); 
    627646                        } 
    628647                } 
    629648        } 
    630649        void log_write() const { 
    631                 if (log_level==10){ 
    632                         to_setting(logrec->L.log_to_setting(logrec->ids(0))); 
     650                if ( log_level == 10 ) { 
     651                        to_setting ( logrec->L.log_to_setting ( logrec->ids ( 0 ) ) ); 
    633652                } else { 
    634                         if (log_level>0) { 
    635                                 logrec->L.log_vector( logrec->ids(0), mean() ); 
     653                        if ( log_level > 0 ) { 
     654                                logrec->L.log_vector ( logrec->ids ( 0 ), mean() ); 
    636655                        } 
    637                         if (log_level>1) { 
    638                                 vec lb; vec ub; 
    639                                 qbounds(lb,ub); 
    640                                 logrec->L.log_vector( logrec->ids(1), lb ); 
    641                                 logrec->L.log_vector( logrec->ids(2), ub ); 
     656                        if ( log_level > 1 ) { 
     657                                vec lb; 
     658                                vec ub; 
     659                                qbounds ( lb, ub ); 
     660                                logrec->L.log_vector ( logrec->ids ( 1 ), lb ); 
     661                                logrec->L.log_vector ( logrec->ids ( 2 ), ub ); 
    642662                        } 
    643663                } 
     
    704724        //! Efficient version of samplecond 
    705725        virtual mat samplecond_mat ( const vec &cond, int N ); 
    706          
     726 
    707727        void validate() { 
    708728                iepdf.validate(); 
    709                 if (rv._dsize()< iepdf._rv()._dsize()) {rv=iepdf._rv();}; 
     729                if ( rv._dsize() < iepdf._rv()._dsize() ) { 
     730                        rv = iepdf._rv(); 
     731                }; 
    710732                dim = iepdf.dimension(); 
    711733        } 
     
    789811        } 
    790812        //! for future use 
    791         virtual ~datalink(){} 
     813        virtual ~datalink() {} 
    792814}; 
    793815 
     
    829851                if ( v2h_up.length() > 0 ) { 
    830852                        history.shift_right ( 0, v2h_up.length() ); 
    831                   history.set_subvector ( 0, val_up(v2h_up) );  
     853                        history.set_subvector ( 0, val_up ( v2h_up ) ); 
    832854                } 
    833855        } 
     
    854876                ivec valid_ids = rv.findself_ids ( rv_up ); 
    855877                RV rv_hist = rv.subselect ( find ( valid_ids >= 0 ) ); // select only rvs that are in rv_up 
    856                 RV rv_hist0 =rv_hist.remove_time(); // these RVs will form history at time =0 
     878                RV rv_hist0 = rv_hist.remove_time(); // these RVs will form history at time =0 
    857879                // now we need to know what is needed from Up 
    858880                rv_hist = rv_hist.expand_delayes(); // full regressor - including time 0 
    859                 Hrv=rv_hist.subt(rv_hist0);   // remove time 0 
     881                Hrv = rv_hist.subt ( rv_hist0 );   // remove time 0 
    860882                history = zeros ( Hrv._dsize() ); 
    861883 
    862884                // decide if we need to copy val to history 
    863                 if (Hrv._dsize() >0) { 
    864                         v2h_up = rv_hist0.dataind(rv_up); // indeces of elements of rv_up to be copied 
     885                if ( Hrv._dsize() > 0 ) { 
     886                        v2h_up = rv_hist0.dataind ( rv_up ); // indeces of elements of rv_up to be copied 
    865887                } // else v2h_up is empty 
    866                  
     888 
    867889                Hrv.dataind ( rv, h2v_hist, h2v_down ); 
    868890 
     
    871893        } 
    872894        //! set history of variable given by \c rv1 to values of \c hist. 
    873         void set_history(const RV& rv1, const vec &hist0){ 
    874                 bdm_assert(rv1._dsize()==hist0.length(),"hist is not compatible with given rv1"); 
     895        void set_history ( const RV& rv1, const vec &hist0 ) { 
     896                bdm_assert ( rv1._dsize() == hist0.length(), "hist is not compatible with given rv1" ); 
    875897                ivec ind_H; 
    876898                ivec ind_h0; 
    877                 Hrv.dataind(rv1, ind_H, ind_h0); // find indeces of rv in  
    878                 set_subvector(history, ind_H, hist0(ind_h0)); // copy given hist to appropriate places 
     899                Hrv.dataind ( rv1, ind_H, ind_h0 ); // find indeces of rv in 
     900                set_subvector ( history, ind_H, hist0 ( ind_h0 ) ); // copy given hist to appropriate places 
    879901        } 
    880902}; 
     
    957979        vec get_cond ( const vec &val_up, const vec &cond_up ) { 
    958980                vec tmp ( condsize ); 
    959                 fill_cond (val_up, cond_up, tmp ); 
     981                fill_cond ( val_up, cond_up, tmp ); 
    960982                return tmp; 
    961983        } 
    962         //! fill condition  
    963         void fill_cond ( const vec &val_up, const vec &cond_up, vec& cond_out){ 
    964                 bdm_assert_debug(cond_out.length()>=condsize,"dl.fill_cond: cond_out is too small"); 
     984        //! fill condition 
     985        void fill_cond ( const vec &val_up, const vec &cond_up, vec& cond_out ) { 
     986                bdm_assert_debug ( cond_out.length() >= condsize, "dl.fill_cond: cond_out is too small" ); 
    965987                set_subvector ( cond_out, v2c_lo, val_up ( v2c_up ) ); 
    966988                set_subvector ( cond_out, c2c_lo, cond_up ( c2c_up ) ); 
     
    976998/*! \brief Abstract class for discrete-time sources of data. 
    977999 
    978 The class abstracts operations of:  
    979 \li  data aquisition,  
    980 \li  data-preprocessing, such as  scaling of data,  
     1000The class abstracts operations of: 
     1001\li  data aquisition, 
     1002\li  data-preprocessing, such as  scaling of data, 
    9811003\li  data resampling from the task of estimation and control. 
    9821004Moreover, for controlled systems, it is able to receive the desired control action and perform it in the next step. (Or as soon as possible). 
    9831005 
    9841006The DataSource has three main data interaction structures: 
    985 \li input, \f$ u_t \f$,  
     1007\li input, \f$ u_t \f$, 
    9861008\li output \f$ y_t \f$, 
    9871009\li data, \f$ d_t=[y_t,u_t, \ldots ]\f$ a collection of all inputs and outputs and possibly some internal variables too. 
     
    9911013class DS : public root { 
    9921014protected: 
    993                 //! size of data returned by \c getdata() 
     1015        //! size of data returned by \c getdata() 
    9941016        int dtsize; 
    995                 //! size of data 
     1017        //! size of data 
    9961018        int utsize; 
    997                 //!size of output 
    998                 int ytsize; 
     1019        //!size of output 
     1020        int ytsize; 
    9991021        //!Description of data returned by \c getdata(). 
    10001022        RV Drv; 
    10011023        //!Description of data witten by by \c write(). 
    10021024        RV Urv; // 
    1003                 //!Description of output data 
    1004                 RV Yrv; // 
     1025        //!Description of output data 
     1026        RV Yrv; // 
    10051027public: 
    10061028        //! default constructors 
    1007         DS() : dtsize(0),utsize(0),ytsize(0),Drv(), Urv(),Yrv() {log_level=1;}; 
     1029        DS() : dtsize ( 0 ), utsize ( 0 ), ytsize ( 0 ), Drv(), Urv(), Yrv() { 
     1030                log_level = 1; 
     1031        }; 
    10081032 
    10091033        //! Returns maximum number of provided data, by default it is set to maximum allowed length, shorter DS should overload this method! See, MemDS.max_length(). 
    1010         virtual int max_length() {return std::numeric_limits< int >::max();} 
     1034        virtual int max_length() { 
     1035                return std::numeric_limits< int >::max(); 
     1036        } 
    10111037        //! Returns full vector of observed data=[output, input] 
    10121038        virtual void getdata ( vec &dt ) const { 
     
    10191045 
    10201046        //! Accepts action variable and schedule it for application. 
    1021         virtual void write (const vec &ut ) { 
     1047        virtual void write ( const vec &ut ) { 
    10221048                bdm_error ( "abstract class" ); 
    10231049        } 
    10241050 
    10251051        //! Accepts action variables at specific indeces 
    1026         virtual void write (const vec &ut, const ivec &indeces ) { 
     1052        virtual void write ( const vec &ut, const ivec &indeces ) { 
    10271053                bdm_error ( "abstract class" ); 
    10281054        } 
    10291055 
    10301056        //! Moves from \f$ t \f$ to \f$ t+1 \f$, i.e. perfroms the actions and reads response of the system. 
    1031         virtual void step()  
    1032         { 
     1057        virtual void step() { 
    10331058                bdm_error ( "abstract class" ); 
    10341059        } 
    10351060 
    10361061        //! Register DS for logging into logger L 
    1037         virtual void log_register (logger &L,  const string &prefix ) { 
     1062        virtual void log_register ( logger &L,  const string &prefix ) { 
    10381063                bdm_assert ( ytsize == Yrv._dsize(), "invalid DS: ytsize (" + num2str ( ytsize ) + ") different from Drv " + num2str ( Yrv._dsize() ) ); 
    10391064                bdm_assert ( utsize == Urv._dsize(), "invalid DS: utsize (" + num2str ( utsize ) + ") different from Urv " + num2str ( Urv._dsize() ) ); 
    10401065 
    1041                 root::log_register(L,prefix); 
    1042                 //we know that  
    1043                 if (log_level >0){ 
    1044                         logrec->ids.set_size(2); 
    1045                         logrec->ids(0) = logrec->L.add_vector ( Yrv, prefix ); 
    1046                         logrec->ids(1) = logrec->L.add_vector ( Urv, prefix ); 
     1066                root::log_register ( L, prefix ); 
     1067                //we know that 
     1068                if ( log_level > 0 ) { 
     1069                        logrec->ids.set_size ( 2 ); 
     1070                        logrec->ids ( 0 ) = logrec->L.add_vector ( Yrv, prefix ); 
     1071                        logrec->ids ( 1 ) = logrec->L.add_vector ( Urv, prefix ); 
    10471072                } 
    10481073        } 
    10491074        //! Register DS for logging into logger L 
    10501075        virtual void log_write ( ) const { 
    1051                 if (log_level >0) { 
    1052                         vec tmp ( Yrv._dsize() + Urv._dsize()); 
     1076                if ( log_level > 0 ) { 
     1077                        vec tmp ( Yrv._dsize() + Urv._dsize() ); 
    10531078                        getdata ( tmp ); 
    10541079                        // d is first in getdata 
    1055                         logrec->L.log_vector ( logrec->ids(0), tmp.left ( Yrv._dsize() ) ); 
     1080                        logrec->L.log_vector ( logrec->ids ( 0 ), tmp.left ( Yrv._dsize() ) ); 
    10561081                        // u follows after d in getdata 
    1057                         logrec->L.log_vector ( logrec->ids(1), tmp.mid ( Yrv._dsize(), Urv._dsize() ) ); 
     1082                        logrec->L.log_vector ( logrec->ids ( 1 ), tmp.mid ( Yrv._dsize(), Urv._dsize() ) ); 
    10581083                } 
    10591084        } 
     
    10711096        } 
    10721097        //! set random variables 
    1073         virtual void set_drv (const  RV &yrv, const RV &urv) { 
     1098        virtual void set_drv ( const  RV &yrv, const RV &urv ) { 
    10741099                Yrv = yrv; 
    1075                 Drv = concat(yrv,urv); 
     1100                Drv = concat ( yrv, urv ); 
    10761101                Urv = urv; 
    10771102        } 
     
    10851110\f] 
    10861111where: 
    1087  * \f$ y_t \f$ is the variable  
     1112 * \f$ y_t \f$ is the variable 
    10881113Access to the resulting posterior density is via function \c posterior(). 
    10891114 
     
    11091134        //! size of the conditioning vector 
    11101135        int dimc; 
    1111          
     1136 
    11121137        //!Logarithm of marginalized data likelihood. 
    11131138        double ll; 
     
    11191144        //! @{ 
    11201145 
    1121         BM() : yrv(),dimy(0),rvc(),dimc(0), ll ( 0 ), evalll ( true ) { }; 
     1146        BM() : yrv(), dimy ( 0 ), rvc(), dimc ( 0 ), ll ( 0 ), evalll ( true ) { }; 
    11221147//      BM ( const BM &B ) :  yrv ( B.yrv ), dimy(B.dimy), rvc ( B.rvc ),dimc(B.dimc), ll ( B.ll ), evalll ( B.evalll ) {} 
    11231148        //! \brief Copy function required in vectors, Arrays of BM etc. Have to be DELETED manually! 
    11241149        //! Prototype: \code BM* _copy_() const {return new BM(*this);} \endcode 
    1125         virtual BM* _copy_() const { return NULL; }; 
     1150        virtual BM* _copy_() const { 
     1151                return NULL; 
     1152        }; 
    11261153        //!@} 
    11271154 
     
    11321159        @param dt vector of input data 
    11331160        */ 
    1134         virtual void bayes ( const vec &yt, const vec &cond=empty_vec ) = 0; 
     1161        virtual void bayes ( const vec &yt, const vec &cond = empty_vec ) = 0; 
    11351162        //! Batch Bayes rule (columns of Dt are observations) 
    1136         virtual void bayes_batch ( const mat &Dt, const vec &cond=empty_vec ); 
     1163        virtual void bayes_batch ( const mat &Dt, const vec &cond = empty_vec ); 
    11371164        //! Batch Bayes rule (columns of Dt are observations, columns of Cond are conditions) 
    11381165        virtual void bayes_batch ( const mat &Dt, const mat &Cond ); 
    11391166        //! Evaluates predictive log-likelihood of the given data record 
    1140         //! I.e. marginal likelihood of the data with the posterior integrated out.  
    1141         //! This function evaluates only \f$ y_t \f$, condition is assumed to be the last used in bayes().  
     1167        //! I.e. marginal likelihood of the data with the posterior integrated out. 
     1168        //! This function evaluates only \f$ y_t \f$, condition is assumed to be the last used in bayes(). 
    11421169        //! See bdm::BM::predictor for conditional version. 
    11431170        virtual double logpred ( const vec &yt ) const { 
     
    11701197        //! \name Access to attributes 
    11711198        //!@{ 
    1172                 //! access function 
    1173                 const RV& _rvc() const { 
    1174                         return rvc; 
    1175                 } 
    1176                 //! access function 
    1177                 int dimensionc() const { 
    1178                         return dimc; 
    1179                 } 
    1180                 //! access function 
    1181                 int dimensiony() const { 
    1182                         return dimy; 
    1183                 } 
    1184                 //! access function 
    1185                 int dimension() const { 
    1186                         return posterior().dimension(); 
    1187                 } 
    1188                 //! access function 
     1199        //! access function 
     1200        const RV& _rvc() const { 
     1201                return rvc; 
     1202        } 
     1203        //! access function 
     1204        int dimensionc() const { 
     1205                return dimc; 
     1206        } 
     1207        //! access function 
     1208        int dimensiony() const { 
     1209                return dimy; 
     1210        } 
     1211        //! access function 
     1212        int dimension() const { 
     1213                return posterior().dimension(); 
     1214        } 
     1215        //! access function 
    11891216        const RV& _yrv() const { 
    11901217                return yrv; 
     
    11961223        //! access to rv of the posterior 
    11971224        void set_rv ( const RV &rv ) { 
    1198                 const_cast<epdf&>(posterior()).set_rv ( rv ); 
     1225                const_cast<epdf&> ( posterior() ).set_rv ( rv ); 
    11991226        } 
    12001227        //! access function 
    12011228        void set_dim ( int dim ) { 
    1202                 const_cast<epdf&>(posterior()).set_dim ( dim ); 
     1229                const_cast<epdf&> ( posterior() ).set_dim ( dim ); 
    12031230        } 
    12041231        //! return internal log-likelihood of the last data vector 
     
    12201247        virtual void set_options ( const string &opt ) { 
    12211248                if ( opt.find ( "logfull" ) != string::npos ) { 
    1222                         const_cast<epdf&>(posterior()).set_log_level(10) ; 
     1249                        const_cast<epdf&> ( posterior() ).set_log_level ( 10 ) ; 
    12231250                } else { 
    12241251                        if ( opt.find ( "logbounds" ) != string::npos ) { 
    1225                                 const_cast<epdf&>(posterior()).set_log_level(2) ; 
     1252                                const_cast<epdf&> ( posterior() ).set_log_level ( 2 ) ; 
    12261253                        } else { 
    1227                                 const_cast<epdf&>(posterior()).set_log_level(1) ; 
     1254                                const_cast<epdf&> ( posterior() ).set_log_level ( 1 ) ; 
    12281255                        } 
    12291256                        if ( opt.find ( "logll" ) != string::npos ) { 
     
    12381265        //!  * x = level of the posterior (typically 0/1/2 for nothing/mean/bounds) 
    12391266        virtual void log_register ( logger &L, const string &prefix = "" ) { 
    1240                 root::log_register(L,prefix);            
    1241  
    1242                 const_cast<epdf&>(posterior()).log_register(L, prefix+L.prefix_sep()+"apost");  
    1243                  
    1244                 if ((log_level) > 0){ 
    1245                         logrec->ids.set_size(1); 
    1246                         logrec->ids(0) = L.add_vector(RV("",1), prefix+L.prefix_sep()+"ll"); 
     1267                root::log_register ( L, prefix ); 
     1268 
     1269                const_cast<epdf&> ( posterior() ).log_register ( L, prefix + L.prefix_sep() + "apost" ); 
     1270 
     1271                if ( ( log_level ) > 0 ) { 
     1272                        logrec->ids.set_size ( 1 ); 
     1273                        logrec->ids ( 0 ) = L.add_vector ( RV ( "", 1 ), prefix + L.prefix_sep() + "ll" ); 
    12471274                } 
    12481275        } 
     
    12501277        virtual void log_write ( ) const { 
    12511278                posterior().log_write(); 
    1252                 if (log_level >0) { logrec->L.logit ( logrec->ids ( 0 ), ll );} 
     1279                if ( log_level > 0 ) { 
     1280                        logrec->L.logit ( logrec->ids ( 0 ), ll ); 
     1281                } 
    12531282        } 
    12541283        //!@} 
     
    12641293                shared_ptr<RV> r3 = UI::build<RV> ( set, "rv", UI::optional ); 
    12651294                if ( r3 ) { 
    1266                         set_rv(*r3); 
    1267                 } 
    1268                  
     1295                        set_rv ( *r3 ); 
     1296                } 
     1297 
    12691298                string opt; 
    12701299                if ( UI::get ( opt, set, "options", UI::optional ) ) {