Show
Ignore:
Timestamp:
09/10/10 11:11:24 (14 years ago)
Author:
smidl
Message:

bug in sigma += Q(i) found

Files:
1 modified

Legend:

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

    r1180 r1182  
    4646}; 
    4747 
    48 void UDprt(int *U, int *D) { 
    49     return; 
    50     for (int i=0;i<5;i++) { 
    51         for (int j=0;j<5;j++) { 
    52             printf("%d,",U[i*5+j]); 
    53         } 
    54         printf("\n"); 
    55     } 
    56     for (int i=0;i<5;i++) { 
    57         printf("%d,",D[i]); 
    58     } 
     48bool DBG=true; 
     49 
     50void show(const char name[10], int *I, int n) { 
     51        if (!DBG) return; 
     52         
     53        printf("%s: ",name); 
     54    for (int i=0;i<n;i++) { 
     55                printf("%d ",*(I+i)); 
     56        } 
    5957    printf("\n"); 
    6058} 
     
    8280    // eye created 
    8381 
    84     long sigma; // in q15 
    85     for (i=rows-1; i>=0;i--) { // check i==0 at the END! 
     82    long sigma; // in q30!!!!!! 
     83    for (i=rows-1; true;i--) { // check i==0 at the END! 
    8684        sigma = 0; 
    8785                 
    8886        for (j=0;j<rows; j++) { 
    89             sigma += (((long)PSIU[i*rows+j]*PSIU[i*rows+j])>>15)*(Dold[i]); 
     87                        //long s1=(((long)PSIU[i+j*rows]*PSIU[i+j*rows])>>15)*(Dold[i]); 
     88                        long s2=(((long)PSIU[i*rows+j]*PSIU[i*rows+j])>>15)*(Dold[j]); 
     89//                      printf("%d - %d\n",s1,s2); 
     90                        sigma += s2; 
    9091                } 
    91                 sigma += Q[i*rows+i]; 
     92                sigma += Q[i*rows+i]<<15; 
    9293        for (j=i+1;j<rows; j++) { 
    9394            sigma += (((long)G[i*rows+j]*G[i*rows+j])>>13)*Q[j*rows+j]; 
     95//                      sigma += (((long)G[i+j*rows]*G[i+j*rows])>>13)*Q[j+j*rows]; 
    9496                } 
    9597                 
    9698        *(D+i)=sigma>>15; 
    9799        if (D[i]==0) D[i]=1; 
    98  
    99         /*              printf("d=sig\n"); 
    100                         UDprt(U,D); 
    101                         UDprt(G,Dold);*/ 
     100//show("D",D,5); 
    102101 
    103102        for (j=0;j<i;j++) { 
     
    116115            U[j*rows+i] = (int)z; 
    117116 
    118             /*                  printf("U=sig/D\n"); 
    119                                 UDprt(U,D); 
    120                                 UDprt(G,Dold);*/ 
    121117 
    122118            for (k=0;k<rows;k++) { 
     
    128124            } 
    129125                         
    130             /*                  printf("end\n"); 
    131                                 UDprt(U,D); 
    132                                 UDprt(G,Dold); 
    133                                 printf("\n");   */ 
    134         } 
    135         if (i==0) return; 
     126        } 
     127        //show("U",U,25); 
     128                //show("G",G,25); 
     129                if (i==0) return; 
    136130    } 
    137131}