Show
Ignore:
Timestamp:
03/16/12 16:46:40 (12 years ago)
Author:
smidl
Message:

Funkcni 1D Kalman

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/pmsm/simulator_zdenek/ekf_example/ekf_obj.h

    r1381 r1439  
    578578                }; 
    579579        void bayes ( const vec &val, const vec &cond ) { 
    580                 const double &isa = val(0); 
     580/*              const double &isa = val(0); 
    581581                const double &isb = val(1); 
    582582                const double &usa = cond(0); 
    583                 const double &usb = cond(1); 
    584                 mpf_bayes(isa,isb,usa,usb); 
     583                const double &usb = cond(1);*/ 
     584                mpf_bayes((floatx)val(0),(floatx)val(1),(floatx)cond(0), (floatx)cond(1));//isa,isb,usa,usb); 
    585585        } 
    586586         
    587587        class mp:public epdf{ 
     588                LOG_LEVEL(mp,logth); 
    588589        public: 
    589                 mp():epdf(){set_dim(3);} 
     590                mp():epdf(){set_dim(3);         log_level[logth]=true; 
     591} 
    590592                vec sample() const {return zeros(3);} 
    591593                double evallog(const vec &v) const {return 0.0;} 
    592                 vec mean() const {vec tmp(3); mpf_mean(tmp._data(), tmp._data()+1, tmp._data()+2); return tmp;} 
     594                vec mean() const {vec tmp(3);  
     595                        floatx es,ec,eo; 
     596                        mpf_mean(&es, &ec, &eo);  
     597                        tmp(0)=es;tmp(1)=ec;tmp(2)=eo; 
     598                        return tmp; 
     599                } 
    593600                vec variance() const {return zeros(3);} 
     601                void log_register ( bdm::logger& L, const string& prefix ) { 
     602                        epdf::log_register ( L, prefix ); 
     603                        if ( log_level[logth] ) { 
     604                                int th_dim = N; // dimension - dimension of cov 
     605                                L.add_vector( log_level, logth, RV ( th_dim ), prefix ); 
     606                        } 
     607                } 
     608                void log_write() const { 
     609                        epdf::log_write(); 
     610                        if ( log_level[logth] ) { 
     611                                floatx Th[N]; 
     612                                mpf_th(Th); 
     613                                vec th(N);  
     614                                for(int i=0;i<N;i++){th(i)=Th[i];} 
     615                                log_level.store( logth, th ); 
     616                        } 
     617                } 
    594618        }; 
    595619         
     
    598622         
    599623        void from_setting(const Setting &set){ 
    600                 BM::from_setting(set); 
     624            BM::from_setting(set); 
     625                UI::get ( log_level, set, "log_level", UI::optional ); 
     626 
    601627                UI::get(qom,set,"qom",UI::optional); 
    602628                UI::get(qth,set,"qth",UI::optional); 
     
    604630        } 
    605631        void validate(){ 
    606                 mpf_init(qom,qth,r); 
     632                mpf_init((floatx)qom,(floatx)qth,(floatx)r); 
    607633                 
    608634        }