Show
Ignore:
Timestamp:
11/02/10 21:20:26 (14 years ago)
Author:
smidl
Message:

fixes in UD + Chol

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/pmsm/simulator_zdenek/ekf_example/matrix_vs.cpp

    r1241 r1245  
    114114} 
    115115 
    116  
     116// Thorton procedure - Kalman predictive variance in UD 
     117void thorton(int16 *U, int16 *D, int16 *PSIU, int16 *Q, int16 *G, int16 *Dold, unsigned int16 rows) { 
     118        thorton_fast(U, D, PSIU, Q, G, Dold, rows); 
     119} 
     120         
    117121// Thorton procedure - Kalman predictive variance in UD 
    118122void thorton_fast(int16 *U, int16 *D, int16 *PSIU, int16 *Q, int16 *G, int16 *Dold, unsigned int16 rows) { 
     
    284288 
    285289            sigma = sigma >> 15;               // navrat do Q15 
    286             if (sigma>32767)sigma=32767; 
     290          //  if (sigma>32767)sigma=32767; 
    287291                         
    288292            for (j=0;j<dimx;j++)  
     
    393397                        } 
    394398                } 
    395         } 
    396         for (j=0; j<i; j++){ 
    397                 tmp_long=(long(Ch[i*dimx+i])*Ch[i*dimx+i]+long(Ch[i*dimx+j])*Ch[i*dimx+j]); 
    398                 if (tmp_long>0){ 
    399                         rho=sqrt((double)(tmp_long)); 
    400                         s=(long(Ch[i*dimx+j])<<15)/rho; 
    401                         c=(long(Ch[i*dimx+i])<<15)/rho; 
    402                         for (k=0; k<=i; k++){ 
    403                                 tau=(long(c)*Ch[k*dimx+j]-long(s)*Ch[k*dimx+i])>>15; 
    404                                 Ch[k*dimx+i]=(long(s)*Ch[k*dimx+j]+long(c)*Ch[k*dimx+i])>>15; 
    405                                 Ch[k*dimx+j]=tau; 
     399 
     400                for (j=0; j<i; j++){ 
     401                        tmp_long=(long(Ch[i*dimx+i])*Ch[i*dimx+i]+long(Ch[i*dimx+j])*Ch[i*dimx+j]); 
     402                        if (tmp_long>0){ 
     403                                rho=sqrt((double)(tmp_long)); 
     404                                s=(long(Ch[i*dimx+j])<<15)/rho; 
     405                                c=(long(Ch[i*dimx+i])<<15)/rho; 
     406                                for (k=0; k<=i; k++){ 
     407                                        tau=(long(c)*Ch[k*dimx+j]-long(s)*Ch[k*dimx+i])>>15; 
     408                                        Ch[k*dimx+i]=(long(s)*Ch[k*dimx+j]+long(c)*Ch[k*dimx+i])>>15; 
     409                                        Ch[k*dimx+j]=tau; 
     410                                } 
    406411                        } 
    407412                } 
     413 
    408414        } 
    409415}