Changeset 1466 for applications/pmsm/simulator_zdenek/test_Ch.cpp
- Timestamp:
- 08/02/12 22:43:00 (12 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/simulator_zdenek/test_Ch.cpp
r1321 r1466 24 24 mat Ch = U*diag(sqrt(D)); 25 25 26 int PSI[25];27 int PSICh[25]={0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};28 int Chf[25]={0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};29 int Cf[10]={0,0,0,0,0, 0,0,0,0,0};30 int multip=1<<15;26 int16 PSI[25]; 27 int16 PSICh[25]={0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0}; 28 int16 Chf[25]={0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0}; 29 int16 Cf[10]={0,0,0,0,0, 0,0,0,0,0}; 30 int16 multip=(1<<15)-1; 31 31 32 32 /////////// COPY … … 34 34 mat_to_int16(Af, PSI); 35 35 mat_to_int16(round_i(Ch*multip),Chf); 36 int Qf[25];36 int16 Qf[25]; 37 37 mat_to_int16(round_i(sqrt(Q)*multip), Qf); 38 int Rf[2];38 int16 Rf[2]; 39 39 vec_to_int16(round_i(R*multip), Rf); 40 40 … … 43 43 mmultACh(PSI,Chf,PSICh,5,5); 44 44 45 mat PhiCh =round(A*32768)*round(Ch*32768)/32768/32768; 46 /* cout << "A*U" << round_i(PhiU*multip) <<endl;47 cout << "PSIU: "; for (i=0; i<25;i++) cout << PSIU[i] << ","; cout <<endl;*/48 49 imat PChcmp(PSICh,5,5);45 mat PhiCh =round(A*32768)*round(Ch*32768)/32768/32768; 46 imat PChcmp; 47 int16_to_mat(PSICh,PChcmp,5,5); 48 cout << "Psi: " << round_i(PhiCh*multip) <<endl; 49 cout << "PSI fix: " << PChcmp <<endl; 50 50 cout << "Delta PSI: " << round_i(PhiCh*multip-PChcmp) <<endl; 51 51 … … 83 83 } 84 84 85 cout << "PSICh: " << imat(PSICh,5,5) << endl; 86 cout << "Qf: " << imat(Qf,5,5) << endl; 85 imat M55(5,5); 86 int16_to_mat(PSICh,M55,5,5); 87 cout << "PSICh: " << M55 << endl; 88 int16_to_mat(Qf,M55,5,5); 89 cout << "Qf: " << M55 << endl; 87 90 88 91 Ch = U*diag(sqrt(D)); … … 96 99 cout << endl<<"after householder " <<endl; 97 100 98 imat Chcmp(PSICh,5,5); 101 imat Chcmp; 102 int16_to_mat(PSICh,Chcmp,5,5); 99 103 cout << "Ch(UD): " << round_i(Ch*multip) << endl; 100 104 cout << "Ch: " << (Chcmp) << endl; … … 113 117 vec xp = 2*randu(5)-1; 114 118 115 int difz[2];119 int16 difz[2]; 116 120 vec_to_int16(round_i(ydif*multip), difz); 117 int xf[5];121 int16 xf[5]; 118 122 vec_to_int16(round_i(xp*multip), xf); 119 123 … … 122 126 123 127 124 int xf_old[5];125 vec_to_int16(ivec(xf,5),xf_old);128 int16 xf_old[5]; 129 for (int i=0; i<5;i++) xf_old[i]=xf[i]; 126 130 127 131 /////// Test bierman … … 164 168 mat_to_int16(round_i(C*multip),Cf); 165 169 166 cout << "bef Carlson: " << imat(Chf,5,5) << endl; 170 int16_to_mat(Chf,M55,5,5); 171 cout << "bef Carlson: " << M55 << endl; 167 172 168 carlson_fastC(difz,xf, Chf, Cf,Rf, 2, 5); 173 int16 detS, rem; 174 carlson_fastC(difz,xf, Chf, Cf,Rf, 2, 5, &detS, &rem); 169 175 170 176 cout << endl<<"after Carlson" <<endl; … … 173 179 174 180 { 175 imat Chcmp(Chf,5,5); 181 imat Chcmp; 182 int16_to_mat(Chf,Chcmp,5,5); 183 cout << "Ch: " << round_i(Ch*multip) << endl; 184 cout << "Ch fix: " << Chcmp << endl; 176 185 cout << "Delta Ch: " << round_i(Ch*multip-Chcmp) << endl; 177 cout << "Delta Ch: " << Chcmp << endl;178 186 } 179 187