Mathc matrices/c29a6
Installer et compiler ces fichiers dans votre répertoire de travail.
c06.c |
---|
/* ------------------------------------ */
/* Save as : c06.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = rsymmetric_mR(i_mR(r,r),999.);
double **EigsVector= i_mR(r,r);
double **EigsVector_T= i_mR(r,r);
double **EigsValue = i_mR(r,C1);
double **b1= i_mR(r,C1);
double **b2= i_mR(r,C1);
double **b3= i_mR(r,C1);
double **r1= i_mR(R1,r);
double **r2= i_mR(R1,r);
double **r3= i_mR(R1,r);
double **b1r1= i_mR(r,r);
double **b2r2= i_mR(r,r);
double **b3r3= i_mR(r,r);
double **E1b1r1= i_mR(r,r);
double **E2b2r2= i_mR(r,r);
double **E3b3r3= i_mR(r,r);
double **T = i_mR(r,r);
double **a = i_mR(r,r);
clrscrn();
printf(" Copy/Past into the octave windows \n\n");
p_Octave_mR(A,"a", P0);
printf(" [V, E] = eigs (a,%d) \n\n",r);
eigs_V_mR(A,EigsVector);
printf(" EigsVector:");
p_mR(EigsVector, S5, P6, C6);
transpose_mR(EigsVector,EigsVector_T);
eigs_mR(A, EigsValue);
printf(" EigsValue :");
p_mR(EigsValue, S13, P6, C1);
stop();
clrscrn();
c_c_mR(EigsVector, C1, b1, C1 );
c_c_mR(EigsVector, C2, b2, C1 );
c_c_mR(EigsVector, C3, b3, C1 );
c_r_mR(EigsVector_T, R1, r1, C1 );
c_r_mR(EigsVector_T, R2, r2, C1 );
c_r_mR(EigsVector_T, R3, r3, C1 );
mul_mR(b1, r1, b1r1);
mul_mR(b2, r2, b2r2);
mul_mR(b3, r3, b3r3);
smul_mR(1./EigsValue[R1][C1], b1r1, E1b1r1);
smul_mR(1./EigsValue[R2][C1], b2r2, E2b2r2);
smul_mR(1./EigsValue[R3][C1], b3r3, E3b3r3);
printf(" inv(A) :");
inv_mR(A, T);
pE_mR(T, S12, P4, C6);
add_mR(E1b1r1, E2b2r2, T);
add_mR( T, E3b3r3, a);
printf(" 1/E1 * b1r1 + 1/E2 * b2r2 + 1/E3 * b3r3 = inv(A)");
pE_mR(a, S12, P4, C6);
f_mR(A);
f_mR(EigsVector);
f_mR(EigsVector_T);
f_mR(EigsValue);
f_mR(b1);
f_mR(b2);
f_mR(b3);
f_mR(r1);
f_mR(r2);
f_mR(r3);
f_mR(b1r1);
f_mR(b2r2);
f_mR(b3r3);
f_mR(E1b1r1);
f_mR(E2b2r2);
f_mR(E3b3r3);
f_mR(T);
f_mR(a);
}
/* ------------------------------------ */
int main(void)
{
do
{
fun(R3);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Nous voyons une des propriétés de la décomposition spectral:
- 1/E1 * b1r1 + 1/E2 * b2r2 + 1/E3 * b3r3 = inv(A)
On peux calculer l'inverse de A en simplement prenant l'inverse de chacune des valeurs propres.
Exemple de sortie écran :
------------------------------------
Copy/Past into the octave windows
a=[
-479,-269,+992;
-269,-501,+904;
+992,+904,-763]
[V, E] = eigs (a,3)
EigsVector:
-0.512981 +0.544352 -0.663726
-0.485715 +0.453457 +0.747300
+0.707765 +0.705732 +0.031785
EigsValue :
-2102.375181
+583.009012
-223.633832
Press return to continue.
inv(A) :
-1.5868e-03 +2.5228e-03 +9.2597e-04
+2.5228e-03 -2.2567e-03 +6.0621e-04
+9.2597e-04 +6.0621e-04 +6.1150e-04
1/E1 * b1r1 + 1/E2 * b2r2 + 1/E3 * b3r3 = inv(A)
-1.5868e-03 +2.5228e-03 +9.2597e-04
+2.5228e-03 -2.2567e-03 +6.0621e-04
+9.2597e-04 +6.0621e-04 +6.1150e-04
Press return to continue
Press X to stop