Mathc complexes/a324
Décomposition d'une matrice en éléments propres
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* save as : c00a.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define FACTOR_E +1.E-4
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int rc)
{
double **A = rcsymmetric_mZ( i_mZ(rc,rc),99);
double **A_T = ctranspose_mZ(A, i_mZ(rc,rc));
double **U = X_U_mZ(A_T, i_mZ(rc,rc),FACTOR_E);
double **U_T = ctranspose_mZ(U, i_mZ(rc,rc));
double **U_TA = mul_mZ(U_T, A, i_mZ(rc,rc));
double **X = mul_mZ(U_TA, U, i_mZ(rc,rc));
double **sqrtX = f_eigs_mZ(sqrt,X, i_mZ(rc,rc));
double **UsqrtX = mul_mZ(U,sqrtX, i_mZ(rc,rc));
double **SqrtA = mul_mZ(UsqrtX,U_T, i_mZ(rc,rc));
double **SqrtA2 = mul_mZ(SqrtA,SqrtA, i_mZ(rc,rc));
clrscrn();
printf(" A :");
p_mZ(A, S9,P1, S8,P1, C4);
printf(" U :");
p_mZ(U, S9,P4, S8,P4, C4);
printf(" X = U_T * A * U :");
p_mZ(X, S11,P3, S7,P3, C4);
stop();
clrscrn();
printf(" sqrt(A) = U sqrt(X) T_U :");
p_mZ(SqrtA, S11,P3, S7,P3, C4);
printf(" A = sqrt(A)**2 :");
p_mZ(SqrtA2, S9,P1, S8,P1, C4);
printf(" A :");
p_mZ(A, S9,P1, S8,P1, C4);
f_mZ(A);
f_mZ(A_T);
f_mZ(U);
f_mZ(U_T);
f_mZ(U_TA);
f_mZ(X);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(R4);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
A :
+26035.0 +0.0i -2789.0+21781.0i -1864.0 -6386.0i -17854.0+11523.0i
-2789.0-21781.0i +27603.0 +0.0i -10095.0 -3424.0i +11680.0+24952.0i
-1864.0 +6386.0i -10095.0 +3424.0i +13126.0 +0.0i -10273.0-12623.0i
-17854.0-11523.0i +11680.0-24952.0i -10273.0+12623.0i +33315.0 +0.0i
U :
-0.4216 +0.2322i +0.6462 -0.0623i +0.3975 +0.2531i -0.1294 -0.3288i
+0.2647 +0.4918i -0.3083 +0.0061i -0.2429 +0.3239i +0.0280 -0.6544i
-0.1657 -0.2178i -0.4528 -0.4172i +0.4104 +0.5769i +0.1750 +0.1193i
+0.6177 +0.0000i +0.3232 +0.0000i +0.3359 -0.0000i +0.6334 +0.0000i
X = U_T * A * U :
+81915.193 +0.000i +0.000 +0.000i -0.000 -0.000i +0.000 +0.000i
-0.000 +0.000i +15413.166 +0.000i -0.000 -0.000i +0.000 -0.000i
-0.000 +0.000i -0.000 +0.000i +2248.915 -0.000i -0.000 +0.000i
+0.000 -0.000i +0.000 +0.000i -0.000 -0.000i +501.727 +0.000i
Press return to continue.
sqrt(A) = U sqrt(X) T_U :
+131.953 -0.000i -19.983+67.711i -14.298 -7.210i -44.110+37.908i
-19.983-67.711i +118.470 +0.000i -23.703-12.827i +30.944+83.065i
-14.298 +7.210i -23.703+12.827i +93.265 -0.000i -38.438-44.356i
-44.110-37.908i +30.944-83.065i -38.438+44.356i +136.492 -0.000i
A = sqrt(A)**2 :
+26035.0 -0.0i -2789.0+21781.0i -1864.0 -6386.0i -17854.0+11523.0i
-2789.0-21781.0i +27603.0 +0.0i -10095.0 -3424.0i +11680.0+24952.0i
-1864.0 +6386.0i -10095.0 +3424.0i +13126.0 -0.0i -10273.0-12623.0i
-17854.0-11523.0i +11680.0-24952.0i -10273.0+12623.0i +33315.0 -0.0i
A :
+26035.0 +0.0i -2789.0+21781.0i -1864.0 -6386.0i -17854.0+11523.0i
-2789.0-21781.0i +27603.0 +0.0i -10095.0 -3424.0i +11680.0+24952.0i
-1864.0 +6386.0i -10095.0 +3424.0i +13126.0 +0.0i -10273.0-12623.0i
-17854.0-11523.0i +11680.0-24952.0i -10273.0+12623.0i +33315.0 +0.0i
Press return to continue
Press X return to stop