- Timestamp:
- 09/10/10 11:11:24 (14 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/simulator_zdenek/ekf_example/matrix_vs.cpp
r1180 r1182 46 46 }; 47 47 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 } 48 bool DBG=true; 49 50 void 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 } 59 57 printf("\n"); 60 58 } … … 82 80 // eye created 83 81 84 long sigma; // in q 1585 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! 86 84 sigma = 0; 87 85 88 86 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; 90 91 } 91 sigma += Q[i*rows+i] ;92 sigma += Q[i*rows+i]<<15; 92 93 for (j=i+1;j<rows; j++) { 93 94 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]; 94 96 } 95 97 96 98 *(D+i)=sigma>>15; 97 99 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); 102 101 103 102 for (j=0;j<i;j++) { … … 116 115 U[j*rows+i] = (int)z; 117 116 118 /* printf("U=sig/D\n");119 UDprt(U,D);120 UDprt(G,Dold);*/121 117 122 118 for (k=0;k<rows;k++) { … … 128 124 } 129 125 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; 136 130 } 137 131 }