Révision 538
Ajouté par Hamza MOUBTASSIME il y a presque 3 ans
branch/moubtassime/sp4a3/sp4a3_kalman.c | ||
---|---|---|
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
void Inverse_Mat_22(int n,int m,double A[n][m],double B[n][m]){
|
||
int i,j;
|
||
double I[2][2];
|
||
|
||
I[0][0] = A[1][1];
|
||
I[0][1] = -A[0][1];
|
||
I[1][0] = -A[1][0];
|
||
I[1][1] = A[0][0];
|
||
B[0][0] = A[1][1];
|
||
B[0][1] = -A[0][1];
|
||
B[1][0] = -A[1][0];
|
||
B[1][1] = A[0][0];
|
||
|
||
for(i= 0; i < n; i++){
|
||
for(j=0;j < m;j++){
|
||
I[i][j] = 1/(A[0][0]*A[1][1]-A[0][1]*A[1][0])*I[i][j];
|
||
B[i][j] = 1/(A[0][0]*A[1][1]-A[0][1]*A[1][0])*B[i][j];
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
|
||
void Mul_Mat_Mat(int na,int ma,double A[na][ma], int nb,int mb,double B[nb][mb], double R[na][mb]){
|
||
int i,j,k;
|
||
if (na==mb) {
|
||
for (i=0, i<na,i++){
|
||
for(j=0,j<mb,j++){
|
||
for (k=0,k<nb,k++){
|
||
R[i][j]=A[i][k]*B[k][j];
|
||
if (ma==nb) {
|
||
for (i=0; i<na;i++){
|
||
for(j=0;j<mb;j++){
|
||
R[i][j]=0;
|
||
for (k=0;k<nb;k++){
|
||
R[i][j] += A[i][k]*B[k][j];
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
double RMT44T44[4][4]={{816,412,192,304},{1155,583,379,687},{1146,668,466,758},{486,308,222,338}};
|
||
|
||
printf("Execution des tests unitaires.\n");
|
||
Transpose_Mat(2,4,T24,R42); if (!Equal_Mat_Mat(RTT24,R42)) error("Erreur calcul Transposition 2x4");
|
||
Transpose_Mat(4,4,T44a,R44); if (!Equal_Mat_Mat(RTT44,R44)) error("Erreur calcul Transposition 4x4");
|
||
Inverse_Mat_22(2,2,T22a,R22); if (!Equal_Mat_Mat(RInvT22,R22)) error("Erreur calcul Inversion 2x2");
|
||
Add_Mat_Mat(2,2,T22a,2,2,T22b,R22); if (!Equal_Mat_Mat(RAT22,R22)) error("Erreur calcul Addition 2x2");
|
||
Add_Mat_Mat(4,4,T44a,4,4,T44b,R44); if (!Equal_Mat_Mat(RAT44,R44)) error("Erreur calcul Addition 4x4");
|
||
Add_Mat_Mat(4,1,T41a,4,1,T41b,R41); if (!Equal_Mat_Mat(RAT41,R41)) error("Erreur calcul Addition 4x1");
|
||
Sub_Mat_Mat(2,1,T21a,2,1,T21b,R21); if (!Equal_Mat_Mat(RST21,R21)) error("Erreur calcul Soustraction 2x1");
|
||
Sub_Mat_Mat(4,4,T44a,4,4,T44b,R44); if (!Equal_Mat_Mat(RST44,R44)) error("Erreur calcul Soustraction 4x4");
|
||
Mul_Mat_Mat(4,4,T44a,4,4,T44b,R44); if (!Equal_Mat_Mat(RMT44T44,R44)) error("Erreur calcul Multiplication 4x4 4x4");
|
||
Mul_Mat_Mat(4,4,T44a,4,1,T41a,R41); if (!Equal_Mat_Mat(RMT44T41,R41)) error("Erreur calcul Multiplication 4x4 4x1");
|
||
Mul_Mat_Mat(4,4,T44a,4,2,T42a,R42); if (!Equal_Mat_Mat(RMT44T42,R42)) error("Erreur calcul Multiplication 4x4 4x2");
|
||
Mul_Mat_Mat(4,2,T42a,2,1,T21a,R41); if (!Equal_Mat_Mat(RMT42T21,R41)) error("Erreur calcul Multiplication 4x2 2x1");
|
||
Mul_Mat_Mat(4,2,T42a,2,2,T22a,R42); if (!Equal_Mat_Mat(RMT42T22,R42)) error("Erreur calcul Multiplication 4x2 2x2");
|
||
Mul_Mat_Mat(4,2,T42a,2,4,T24,R44); if (!Equal_Mat_Mat(RMT42T24,R44)) error("Erreur calcul Multiplication 4x2 2x4");
|
||
Mul_Mat_Mat(2,4,T24,4,1,T41a,R21); if (!Equal_Mat_Mat(RMT24T41,R21)) error("Erreur calcul Multiplication 2x4 4x1");
|
||
Mul_Mat_Mat(2,4,T24,4,2,T42a,R22); if (!Equal_Mat_Mat(RMT24T42,R22)) error("Erreur calcul Multiplication 2x4 4x2");
|
||
Mul_Mat_Mat(2,4,T24,4,4,T44a,R24); if (!Equal_Mat_Mat(RMT24T44,R24)) error("Erreur calcul Multiplication 2x4 4x4");
|
||
Transpose_Mat(2,4,T24,R42); if (!Equal_Mat_Mat(RTT24,R42)) error("Erreur calcul Transposition 2x4"); else { printf("calcul Transpo 2x4 est exact \n");}
|
||
Transpose_Mat(4,4,T44a,R44); if (!Equal_Mat_Mat(RTT44,R44)) error("Erreur calcul Transposition 4x4");else { printf("calcul Transpo 4x4 est exact \n");}
|
||
Inverse_Mat_22(2,2,T22a,R22); if (!Equal_Mat_Mat(RInvT22,R22)) error("Erreur calcul Inversion 2x2");else { printf("calcul inversion 2xE est exact \n");}
|
||
Add_Mat_Mat(2,2,T22a,2,2,T22b,R22); if (!Equal_Mat_Mat(RAT22,R22)) error("Erreur calcul Addition 2x2");else { printf("calcul Add 2x2 est exact \n");}
|
||
Add_Mat_Mat(4,4,T44a,4,4,T44b,R44); if (!Equal_Mat_Mat(RAT44,R44)) error("Erreur calcul Addition 4x4");else { printf("calcul Add 4x4 est exact \n");}
|
||
Add_Mat_Mat(4,1,T41a,4,1,T41b,R41); if (!Equal_Mat_Mat(RAT41,R41)) error("Erreur calcul Addition 4x1");else { printf("calcul Add 4x1 est exact \n");}
|
||
Sub_Mat_Mat(2,1,T21a,2,1,T21b,R21); if (!Equal_Mat_Mat(RST21,R21)) error("Erreur calcul Soustraction 2x1");else { printf("calcul soustraction 2x1 est exact \n");}
|
||
Sub_Mat_Mat(4,4,T44a,4,4,T44b,R44); if (!Equal_Mat_Mat(RST44,R44)) error("Erreur calcul Soustraction 4x4");else { printf("calcul soustraction 4x4 est exact \n");}
|
||
Mul_Mat_Mat(4,4,T44a,4,4,T44b,R44); if (!Equal_Mat_Mat(RMT44T44,R44)) error("Erreur calcul Multiplication 4x4 4x4");else { printf("calcul Multi 4x4 4x4 est exact \n");}
|
||
Mul_Mat_Mat(4,4,T44a,4,1,T41a,R41); if (!Equal_Mat_Mat(RMT44T41,R41)) error("Erreur calcul Multiplication 4x4 4x1");else { printf("calcul Multi 4x4 4x1 est exact \n");}
|
||
Mul_Mat_Mat(4,4,T44a,4,2,T42a,R42); if (!Equal_Mat_Mat(RMT44T42,R42)) error("Erreur calcul Multiplication 4x4 4x2");else { printf("calcul Multi 4x4 4x2 est exact \n");}
|
||
Mul_Mat_Mat(4,2,T42a,2,1,T21a,R41); if (!Equal_Mat_Mat(RMT42T21,R41)) error("Erreur calcul Multiplication 4x2 2x1");else { printf("calcul Multi 4x2 2x1 est exact \n");}
|
||
Mul_Mat_Mat(4,2,T42a,2,2,T22a,R42); if (!Equal_Mat_Mat(RMT42T22,R42)) error("Erreur calcul Multiplication 4x2 2x2");else { printf("calcul Multi 4x2 2x2 est exact \n");}
|
||
Mul_Mat_Mat(4,2,T42a,2,4,T24,R44); if (!Equal_Mat_Mat(RMT42T24,R44)) error("Erreur calcul Multiplication 4x2 2x4");else { printf("calcul Multi 4x2 2x4 est exact \n");}
|
||
Mul_Mat_Mat(2,4,T24,4,1,T41a,R21); if (!Equal_Mat_Mat(RMT24T41,R21)) error("Erreur calcul Multiplication 2x4 4x1");else { printf("calcul Multi 2x4 4x1 est exact \n");}
|
||
Mul_Mat_Mat(2,4,T24,4,2,T42a,R22); if (!Equal_Mat_Mat(RMT24T42,R22)) error("Erreur calcul Multiplication 2x4 4x2");else { printf("calcul Multi 2x4 4x2 est exact \n");}
|
||
Mul_Mat_Mat(2,4,T24,4,4,T44a,R24); if (!Equal_Mat_Mat(RMT24T44,R24)) error("Erreur calcul Multiplication 2x4 4x4");else { printf("calcul Multi 2x4 4x4 est exact \n");}
|
||
printf("Test unitaires OK.\n");
|
||
}
|
||
|
||
int main(int argc,char **argv){
|
||
|
||
tests_unitaires();
|
||
|
||
/*
|
||
FILE* fichier = fopen("pos_t_x_y.dat","r");
|
||
if (fichier == NULL)
|
||
error("Impossible d'ouvrir le fichier GPGGA_data.dat");
|
||
... | ... | |
|
||
while(fscanf(fichier, "%lf %lf %lf", &t, &xobs, &yobs)>0){
|
||
printf("-------------%04d--------------\n",cpt);
|
||
|
||
int i;
|
||
if (cpt ==0)
|
||
{
|
||
t0=t;x0=xobs;y0=yobs;
|
||
... | ... | |
|
||
// X = F*X
|
||
Mul_Mat_Mat(4,4,F,4,1,X,FX);
|
||
for (i=0,i<4,i++){
|
||
for (i=0;i<4;i++){
|
||
X[i][0]=FX[i][0];
|
||
}
|
||
|
||
... | ... | |
|
||
system ("gnuplot -p -e \"plot 'output.dat' u 5:6 w l, '' u 2:3 w l\";");
|
||
system ("gnuplot -p -e \"plot 'output.dat' u 1:9 w l, '' u 1:4 w l\";");
|
||
system ("gnuplot -p -e \"plot 'output.dat' u 9 w l , 'vitesse_reelle.dat' u 2 w l\";");
|
||
system ("gnuplot -p -e \"plot 'output.dat' u 9 w l , 'vitesse_reelle.dat' u 2 w l\";");
|
||
*/
|
||
return 0;
|
||
}
|
Formats disponibles : Unified diff
validation des fonctions.