Mathc matrices/Fichiers c : trace2
Apparence
Installer et compiler ce fichier dans votre répertoire de travail.
trace2.c |
---|
/* ------------------------------------ */
/* Save as : trace2.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = r_mR(i_mR(r,r),9);
double **B = r_mR(i_mR(r,r),9);
double **AB = i_mR(r,r);
double **BA = i_mR(r,r);
clrscrn();
printf(" A : ");
p_mR(A,5,0,6);
printf(" B : ");
p_mR(B,5,0,6);
printf(" Trace(AB) = %+.0f \n",
trace_R(mul_mR(A,B,AB)));
printf(" Trace(BA) = %+.0f \n\n",
trace_R(mul_mR(B,A,BA)));
f_mR(A);
f_mR(B);
f_mR(AB);
f_mR(BA);
}
/* ------------------------------------ */
void hello(void)
{
printf("\n ");
printf("\n ");
printf("\n Trace(AB) = Trace(BA): ");
printf("\n ********************* ");
printf("\n ");
printf("\n ");
printf("\n \n");
stop();
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
hello();
do{
fun(rp_I(RC4)+RC2);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
La fonction trace se contente d'additionner tous les coefficients sur la diagonale.
Exemple de sortie écran :
A :
-2 -9 +8 +8 +7
-1 -6 +8 -1 +1
+7 +4 +5 +8 +5
-2 +1 -1 -6 -9
-9 -4 -3 +8 +4
B :
-8 -3 +2 -9 +3
+9 +8 +9 -3 +5
-5 +9 +7 +8 -3
-1 +6 +1 +8 +5
+2 +9 +1 -6 +9
Trace(AB) = +80
Trace(BA) = +80
Press return to continue
Press X to stop