Show
Ignore:
Timestamp:
08/02/12 22:43:00 (12 years ago)
Author:
smidl
Message:

opraven test Ch

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/pmsm/simulator_zdenek/test_Ch.cpp

    r1321 r1466  
    2424                mat Ch = U*diag(sqrt(D)); 
    2525                 
    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; 
    3131                 
    3232        /////////// COPY 
     
    3434        mat_to_int16(Af, PSI); 
    3535        mat_to_int16(round_i(Ch*multip),Chf);            
    36         int Qf[25]; 
     36        int16 Qf[25]; 
    3737        mat_to_int16(round_i(sqrt(Q)*multip), Qf); 
    38         int Rf[2]; 
     38        int16 Rf[2]; 
    3939        vec_to_int16(round_i(R*multip), Rf); 
    4040         
     
    4343        mmultACh(PSI,Chf,PSICh,5,5);     
    4444         
    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; 
    5050        cout << "Delta PSI: " << round_i(PhiCh*multip-PChcmp) <<endl; 
    5151         
     
    8383        } 
    8484 
    85 cout << "PSICh: " << imat(PSICh,5,5) << endl; 
    86 cout << "Qf: " << imat(Qf,5,5) << endl; 
     85imat M55(5,5); 
     86int16_to_mat(PSICh,M55,5,5); 
     87cout << "PSICh: " << M55 << endl; 
     88int16_to_mat(Qf,M55,5,5); 
     89cout << "Qf: " << M55 << endl; 
    8790 
    8891Ch = U*diag(sqrt(D)); 
     
    9699        cout << endl<<"after householder " <<endl; 
    97100 
    98         imat Chcmp(PSICh,5,5); 
     101        imat Chcmp; 
     102        int16_to_mat(PSICh,Chcmp,5,5); 
    99103        cout << "Ch(UD): " << round_i(Ch*multip) << endl; 
    100104        cout << "Ch: " << (Chcmp) << endl; 
     
    113117        vec     xp = 2*randu(5)-1; 
    114118         
    115         int difz[2]; 
     119        int16 difz[2]; 
    116120        vec_to_int16(round_i(ydif*multip), difz); 
    117         int xf[5]; 
     121        int16 xf[5]; 
    118122        vec_to_int16(round_i(xp*multip), xf); 
    119123 
     
    122126         
    123127         
    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]; 
    126130         
    127131        /////// Test bierman 
     
    164168        mat_to_int16(round_i(C*multip),Cf);              
    165169 
    166         cout << "bef Carlson: " << imat(Chf,5,5) << endl; 
     170        int16_to_mat(Chf,M55,5,5); 
     171        cout << "bef Carlson: " << M55 << endl; 
    167172 
    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); 
    169175         
    170176        cout << endl<<"after Carlson" <<endl; 
     
    173179 
    174180        { 
    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; 
    176185                cout << "Delta Ch: " << round_i(Ch*multip-Chcmp) << endl; 
    177                 cout << "Delta Ch: " << Chcmp << endl; 
    178186        } 
    179187