Changeset 1228
- Timestamp:
- 10/22/10 22:06:23 (14 years ago)
- Location:
- applications/pmsm/simulator_zdenek
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/simulator_zdenek/ekf_example/matrix_vs.cpp
r1225 r1228 19 19 void mmultAU(int *m1, int *up, int *result, unsigned int rows, unsigned int columns) { 20 20 unsigned int i, j, k; 21 long tmp_sum=0L; 21 long tmp_sum=0L; //in 15+qAU 22 22 int *m2pom; 23 23 int *m1pom=m1; … … 32 32 for (k=0; k<j; k++) //inner loop up to "j" - U(j,j)==1; 33 33 { 34 tmp_sum+=( long)(*(m1pom++))**m2pom;34 tmp_sum+=((long)(*(m1pom++))**m2pom)>>(15-qAU); 35 35 m2pom+=columns; 36 36 } 37 37 // add the missing A(i,j) 38 tmp_sum +=(long)(*m1pom)<< 15; // no need to shift38 tmp_sum +=(long)(*m1pom)<<qAU; // no need to shift 39 39 m1pom-=(j); // shift back to first element 40 40 41 41 // saturation effect 42 tmp_sum=tmp_sum>> (30-qAU);42 tmp_sum=tmp_sum>>15; 43 43 if (tmp_sum>32767) { 44 44 //tmp_sum=32767; … … 136 136 for (j=0;j<rows; j++) { 137 137 //long s1=(((long)PSIU[i+j*rows]*PSIU[i+j*rows])>>15)*(Dold[i]); 138 long s2=((((long)PSIU[i*rows+j]* Dold[j])>>qAU)*PSIU[i*rows+j])<<(15-qAU);138 long s2=((((long)PSIU[i*rows+j]*PSIU[i*rows+j]))>>(2*qAU-15))*Dold[j]; 139 139 // printf("%d - %d\n",s1,s2); 140 140 sigma += s2; … … 146 146 } 147 147 148 //if (sigma>16384<<15) sigma = 16384<<15;148 // if (sigma>16384<<15) sigma = 16384<<15; 149 149 *(D+i)=sigma>>15; 150 150 if (D[i]==0) D[i]=1; … … 155 155 sigma =0; 156 156 for (k=0;k<rows;k++) { 157 sigma += (((long(PSIU[i*rows+k])*Dold[k])>>qAU)*PSIU[j*rows+k])<<(15-qAU);157 sigma += (((long(PSIU[i*rows+k])*PSIU[j*rows+k]))>>(2*qAU-15))*Dold[k]; 158 158 } 159 159 for (k=0;k<rows;k++) { … … 266 266 for (k=0, PSIU_ik=PSIU+irows,Dold_k=Dold; 267 267 k<rows; k++, PSIU_ik++,Dold_k++) {//Dold_i= 268 sigma += (((long)(*PSIU_ik)**PSIU_ik)>> (qAU*qAU-15))*(*Dold_k);268 sigma += (((long)(*PSIU_ik)**PSIU_ik)>>15)*(*Dold_k); 269 269 } 270 270 sigma += *(Q+i+irows)<<15; … … 285 285 k<rows; k++, PSIU_ik++, PSIU_jk++, Dold_k++) { 286 286 287 sigma += ((((long)*PSIU_ik)**PSIU_jk)>> (qAU*qAU-15))**Dold_k;287 sigma += ((((long)*PSIU_ik)**PSIU_jk)>>15)**Dold_k; 288 288 } 289 289 -
applications/pmsm/simulator_zdenek/ekf_example/matrix_vs.h
r1225 r1228 11 11 *************************************/ 12 12 13 #define qAU 1 513 #define qAU 14 14 14 15 15 /* Matrix multiply Full matrix by upper diagonal matrix with unit diagonal; */ -
applications/pmsm/simulator_zdenek/test_UD.cpp
r1225 r1228 50 50 51 51 imat PUcmp(PSIU,5,5); 52 cout << "Delta PSI: " << round_i(PhiU*multip- 2*PUcmp) <<endl;52 cout << "Delta PSI: " << round_i(PhiU*multip-(1<<(15-qAU))*PUcmp) <<endl; 53 53 54 mat_to_int(round_i(PhiU*multip/ 2),PSIU); //<< make is same54 mat_to_int(round_i(PhiU*multip/(1<<(15-qAU))),PSIU); //<< make is same 55 55 56 56 /////////// Test Thorton: