Projet

Général

Profil

« Précédent | Suivant » 

Révision 416

Ajouté par anclaud il y a presque 4 ans

Implémentation des fonctions +, -, *, Inverse et Transposée

Voir les différences:

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 out[na][ma]){
// Fonction qui effectue l'operation out = A + B (matrice)
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]){
// Fonction qui effectue l'operation B = A^-1
void Inverse_Mat_22(int n,int m,double A[n][m],double B[n][m])
{
double determinant = A[0][0]*A[1][1]-A[0][1]*A[1][0];
B[0][0]=A[1][1]/determinant;
B[0][1]=-A[0][1]/determinant;
B[1][0]=-A[1][0]/determinant;
B[1][1]=A[0][0]/determinant;
}
// Fonction qui effectue l'operation R = A^T
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 out[na][ma]){
// Fonction qui effectue l'operation out = A - B (matrice)
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];
}
}
}
void Mul_Mat_Mat(int na,int ma,double A[na][ma], int nb,int mb,double B[nb][mb], double out[na][mb]){
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++) // ou for(k=0;k<nb;k++)
{
out[i][j] = out[i][j] + A[i][k]*B[k][j];
}
}
}
}

Formats disponibles : Unified diff