Mathc matrices/01w
Sommaire ◀ Utilise la commande "Retour en Arrière" de ton navigateur.
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = r_mR( i_mR(r,r), 9);
double **AT = transpose_mR(A, i_mR(r,r));
double **AplsAT = add_mR(A,AT, i_mR(r,r));
double **AmnsAT = sub_mR(A,AT, i_mR(r,r));
double **AplsAT2 = smul_mR(1./2., AplsAT, i_mR(r,r));
double **AmnsAT2 = smul_mR(1./2., AmnsAT, i_mR(r,r));
double **A2 = add_mR(AplsAT2,AmnsAT2, i_mR(r,r));
clrscrn();
printf(" A ");
p_mR(A, S7,P3, C6);
printf(" Symmetric matrix : A + AT ");
p_mR(AplsAT, S7,P3, C6);
printf(" Skew matrix : A - AT ");
p_mR(AmnsAT, S7,P3, C6);
stop();
clrscrn();
printf(" A ");
p_mR(A, S7,P3, C6);
printf(" A = (A + AT)/2 + (A - AT)/2");
p_mR(A2, S7,P3, C6);
f_mR(A);
f_mR(A2);
f_mR(AT);
f_mR(AplsAT);
f_mR(AmnsAT);
f_mR(AplsAT2);
f_mR(AmnsAT2);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R4)+R1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Soit une matrice carré A : A = (A+AT)/2 + (A-AT)/2
Exemple de sortie écran :
A
-9.000 -5.000 +5.000
-6.000 -2.000 -4.000
+4.000 -3.000 -4.000
Symmetric matrix : A + AT
-18.000 -11.000 +9.000
-11.000 -4.000 -7.000
+9.000 -7.000 -8.000
Skew matrix : A - AT
+0.000 +1.000 +1.000
-1.000 +0.000 -1.000
-1.000 +1.000 +0.000
Press return to continue.
A
-9.000 -5.000 +5.000
-6.000 -2.000 -4.000
+4.000 -3.000 -4.000
A = (A + AT)/2 + (A - AT)/2
-9.000 -5.000 +5.000
-6.000 -2.000 -4.000
+4.000 -3.000 -4.000
Press return to continue
Press X return to stop