Mathc matrices/c29a1
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00b.c |
|---|
/* ------------------------------------ */
/* Save as: c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define ARRAY A3
/* ------------------------------------ */
#define RC RC3
/* ------------------------------------ */
void fun(void)
{
double **A = rsymmetric_mR( i_mR(RC,RC),999);
double **AEVect = eigs_V_mR(A, i_mR(RC,RC));
double **InvAEVect = transpose_mR(AEVect, i_mR(RC,RC));
double **T = i_mR(RC,RC);
double **Ide = i_mR(RC,RC);
double **b [ARRAY];
double **r [ARRAY];
double **br[ARRAY];
int i;
for(i=A0; i<ARRAY; i++)
{
b[i] = c_c_mR( AEVect,i+C1, i_mR(RC,C1),C1);
r[i] = c_r_mR(InvAEVect,i+R1, i_mR(R1,RC),R1);
br[i] = mul_mR(b[i],r[i], i_mR(RC,RC));
}
clrscrn();
printf(" A:");
p_mR(A, S10,P4,C6);
printf(" AEVect: Eingvectors of A");
p_mR(AEVect, S10,P4,C6);
printf(" InvAEVect: Eingvectors of InvA");
p_mR(InvAEVect, S10,P4,C6);
stop();
clrscrn();
printf(" AEVect: Eingvectors of A");
p_mR(AEVect, S10,P4,C6);
for(i=A0; i<ARRAY; i++)
{
printf(" b%d:",i+C1);
p_mR(b[i], S10,P4,C6);
}
stop();
clrscrn();
printf(" InvAEVect: Eingvectors of InvA");
p_mR(InvAEVect, S10,P4,C6);
for(i=A0; i<ARRAY; i++)
{
printf(" r%d:",i+R1);
p_mR(r[i], S10,P4,C6);
}
stop();
clrscrn();
for(i=A0; i<ARRAY; i++)
{
printf(" b%dr%d:",i+C1,i+R1);
p_mR(br[i], S10,P4,C6);
}
stop();
clrscrn();
add_mR(br[0], br[1], T);
add_mR( T, br[2], Ide);
printf(" b1r1 + b2r2 + b3r3 = Ide");
p_mR(Ide, S10,P4,C6);
f_mR(A);
f_mR(AEVect);
f_mR(InvAEVect);
f_mR(T);
f_mR(Ide);
for(i=A0; i<ARRAY; i++)
{
f_mR( b[i]);
f_mR( r[i]);
f_mR(br[i]);
}
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Nous voyons une des propriètés de la décomposition spectral:
b1r1 + b2r2 + b3r3 = Ide
b1r1 est obtenue en multipliant la première colonne de la matrice des vecteurs propres par la première ligne de la matrice inverse des vecteurs propres.
Vp invVp
r1
b1 b2 b3 r2 -> b1*r1; b2*r2; b3*r3; Cela nous donne trois matrices [3x3]
r3
Exemple de sortie écran :
A:
+742.0000 +423.0000 +326.0000
+423.0000 -552.0000 +137.0000
+326.0000 +137.0000 +724.0000
AEVect: Eingvectors of A
+0.7384 -0.2791 -0.6139
+0.2337 +0.9598 -0.1552
+0.6326 -0.0289 +0.7740
InvAEVect: Eingvectors of InvA
+0.7384 +0.2337 +0.6326
-0.2791 +0.9598 -0.0289
-0.6139 -0.1552 +0.7740
Press return to continue.
AEVect: Eingvectors of A
+0.7384 -0.2791 -0.6139
+0.2337 +0.9598 -0.1552
+0.6326 -0.0289 +0.7740
b1:
+0.7384
+0.2337
+0.6326
b2:
-0.2791
+0.9598
-0.0289
b3:
-0.6139
-0.1552
+0.7740
Press return to continue.
InvAEVect: Eingvectors of InvA
+0.7384 +0.2337 +0.6326
-0.2791 +0.9598 -0.0289
-0.6139 -0.1552 +0.7740
r1:
+0.7384 +0.2337 +0.6326
r2:
-0.2791 +0.9598 -0.0289
r3:
-0.6139 -0.1552 +0.7740
Press return to continue.
b1r1:
+0.5452 +0.1726 +0.4671
+0.1726 +0.0546 +0.1478
+0.4671 +0.1478 +0.4001
b2r2:
+0.0779 -0.2679 +0.0081
-0.2679 +0.9213 -0.0277
+0.0081 -0.0277 +0.0008
b3r3:
+0.3769 +0.0953 -0.4751
+0.0953 +0.0241 -0.1201
-0.4751 -0.1201 +0.5990
Press return to continue.
b1r1 + b2r2 + b3r3 = Ide
+1.0000 -0.0000 +0.0000
-0.0000 +1.0000 +0.0000
+0.0000 +0.0000 +1.0000
Press return to continue
Press X return to stop