Révision 450
Ajouté par Rayan REZKI il y a presque 3 ans
sp4a3_kalman.c | ||
---|---|---|
#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 R[na][ma]){
|
||
|
||
void Add_Mat_Mat(int na,int ma,double A[na][ma],int nb,int mb,double B[nb][mb], double R[na][ma])
|
||
{
|
||
int i,j;
|
||
for (i=0;i<na;i++)
|
||
for (j=0;j<ma;j++)
|
||
R[i][j]=A[i][j]+B[i][j];
|
||
}
|
||
|
||
void Inverse_Mat_22(int n,int m,double A[n][m],double B[n][m]){
|
||
|
||
void Inverse_Mat_22(int n,int m,double A[n][m],double B[n][m])
|
||
{
|
||
int i,j;
|
||
char M[n][m];
|
||
float det;
|
||
M[0][0] = A[1][1];
|
||
M[1][1] = A[0][0];
|
||
M[0][1] = -A[0][1];
|
||
M[1][0] = -A[1][0];
|
||
det = (1/(A[0][0]*A[1][1]-A[1][0]*A[0][1]));
|
||
for (i=0;i<n;i++)
|
||
for (j=0;j<m;j++)
|
||
B[i][j]= det*M[i][j];
|
||
}
|
||
|
||
void Transpose_Mat(int n,int m,double A[n][m],double R[m][n]){
|
||
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];
|
||
}
|
||
|
||
void Sub_Mat_Mat(int na,int ma,double A[na][ma],int nb,int mb,double B[nb][mb], double R[na][ma]){
|
||
void Sub_Mat_Mat(int na,int ma,double A[na][ma],int nb,int mb,double B[nb][mb], double R[na][ma])
|
||
{
|
||
int i,j;
|
||
for (i=0;i<na;i++)
|
||
for (j=0;j<ma;j++)
|
||
R[i][j]=A[i][j]-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])
|
||
{
|
||
if (ma != nb)
|
||
{
|
||
printf("Produit matriciel impossible.\n");
|
||
exit(-1);
|
||
}
|
||
int i,j,k;
|
||
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];
|
||
}
|
||
}
|
||
}
|
||
|
||
void Mul_Mat_Mat(int na,int ma,double A[na][ma], int nb,int mb,double B[nb][mb], double R[na][mb]){
|
||
|
||
}
|
||
|
||
|
||
|
||
void tests_unitaires(void){
|
||
//Matrices d'entrée
|
||
double T21a[2][1]={{7},{-5}};
|
||
... | ... | |
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,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");
|
Formats disponibles : Unified diff
TP séance n°3 : Q5 terminée