Projet

Général

Profil

« Précédent | Suivant » 

Révision 283

Ajouté par abseck1 il y a presque 4 ans

tp3 bloquee sur la prediction

Voir les différences:

branch/smseck/sp4a3/sp4a3_kalman.c
#include <math.h>
#include "sp4a3_kalman_extra.h"
void Add_Mat_Mat(int na,int ma,double A[na][ma],int nb,int mb,double b[nb][mb], double out[na][ma]){
//ADDITION DE MATRICES ET TEST UNITAIRE
void Add_Mat_Mat(int na,int ma,double A[na][ma],int nb,int mb,double b[nb][mb], double out[na][ma])
{
int i,j;
for (i=0; i<na; i++)
{
for (j=0; j<ma; j++)
{
out[i][j] = A[i][j]+b[i][j];
}
}
}
void Inverse_Mat_22(int n,int m,double A[n][m],double B[n][m]){
}
//INVERSE DE MATRICES ET TEST UNITAIRE
void Inverse_Mat_22(int n,int m,double A[n][m],double B[n][m]){
float d;
d=1/((A[0][0]*A[1][1])-(A[0][1]*A[1][0]));
B[0][0]=d*A[1][1];
B[1][1]=d*A[0][0];
B[0][1]=-d*(A[0][1]);
B[1][0]=-d*(A[1][0]);
}
//TRQNSPOSEE DE MATRICES ET TEST UNITAIRE
void Transpose_Mat(int n,int m,double A[n][m],double R[m][n]){
int i,j;
for (i=0;i<n;i++)
for (j=0;j<m;j++)
R[j][i]=A[i][j];
}
//SOUSTRACTION DE MATRICES ET TEST UNITAIRE
void Sub_Mat_Mat(int na,int ma,double A[na][ma],int nb,int mb,double b[nb][mb], double out[na][ma]){
}
int i,j;
for (i=0; i<na; i++)
{
for (j=0; j<ma;j++){
out[i][j] = A[i][j]-b[i][j];
}
}}
//MULTIPLICATION DE MATRICES ET TEST UNITAIRE
void Mul_Mat_Mat(int na,int ma,double A[na][ma], int nb,int mb,double B[nb][mb], double out[na][mb]){
int i,j,k;
for(i = 0; i < na; i++)
{
for(j = 0; j < mb; j++)
{
out[i][j]=0;
for(k = 0; k < ma; k++)
{
out[i][j] += A[i][k] * B[k][j];
}
}
}
}
......
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");
printf("Test unitaires OK.\n");
}
}
int main(int argc,char **argv){
......
///Ajouter votre code ci-dessous///
// Kalman
// X = F*X
Plot_Mat(X," X(k+1|k) = ");
// prediction
/* // Xk+1/k = F*Xk/k
Mul_Mat_Mat(4,4,F,4,1,X); // F*Xk/k
Mul_Mat_Mat(4,4,F,4,1,P); //F*Pk/k*FT
Add_Mat_Mat(4,4,F,4,4,Q,P); // F*Pk/k*FT
Plot_Mat(P,"P(k+1|k) = F.P(k|k).FT + Q = ");*/
//P = F*P*F'+Q;
Plot_Mat(P,"P(k+1|k) = F.P(k|k).FT + Q = ");

Formats disponibles : Unified diff