Révision 464
Ajouté par Hatim EL MAADI il y a presque 3 ans
branch/ELMAADI/sp4a3/sp4a3_kalman.c | ||
---|---|---|
|
||
#include "sp4a3_kalman_extra.h"
|
||
|
||
void init(int n, int m, double R22 [n][m]) //Fonction qui initialise le résultat
|
||
{
|
||
int i,j;
|
||
for (i=0;i<n;i++)
|
||
{
|
||
for (j=0;j<m;j++)
|
||
{
|
||
R22[i][j]=0;
|
||
}
|
||
}
|
||
}
|
||
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=0,j=0;
|
||
init(na,ma,R);
|
||
for (i=0;i<na;i++)
|
||
{
|
||
for (j=0;j<ma;j++)
|
||
{
|
||
R[i][j]=A[i][j]+B[i][j];
|
||
}
|
||
}
|
||
|
||
|
||
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 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;
|
||
init (n,m,B);
|
||
if ((A[0][0]*A[1][1]-A[0][1]*A[1][0])==0)
|
||
{
|
||
printf ("Erreur d'inversion : determinant de la matrice nul");
|
||
exit (-1);
|
||
}
|
||
else
|
||
{
|
||
for (i=0;i<n;i++)
|
||
{
|
||
for (j=0;j<m;j++)
|
||
{
|
||
if (i!=j)
|
||
{
|
||
B[i][j]= -(1/(A[0][0]*A[1][1]-A[0][1]*A[1][0]) * A[i][j]);
|
||
B[i][i]= (1/(A[0][0]*A[1][1]-A[0][1]*A[1][0]) * A[j][j]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
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 Transpose_Mat(int n,int m,double A[n][m],double R[m][n])
|
||
{
|
||
int i,j;
|
||
init (m,n,R);
|
||
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;
|
||
init (na,ma,R);
|
||
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]){
|
||
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;
|
||
init (na,mb,R);
|
||
if (ma!=nb)
|
||
{
|
||
printf ("Erreur dimension matrice multiplication.");
|
||
exit (-1);
|
||
}
|
||
else
|
||
{
|
||
for (i=0;i<na;i++)
|
||
{
|
||
for (j=0;j<mb;j++)
|
||
{
|
||
for (k=0;k<ma;k++)
|
||
{
|
||
R[i][j]= R[i][j] + (A[i][k]*B[k][j]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
Formats disponibles : Unified diff
Implantation des fonction : Addition, Inverse, Transposée, Soustraction, et multiplication.