Mathc complexes/043
Apparence
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+9
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r,int c)
{
double **A = rE_mZ( i_mZ(r,c), 999, 1E-12 );
double **A_T = ctranspose_mZ(A,i_mZ(c,r));
double **V = i_mZ(r,c);
double **V_T = i_mZ(c,r);
double **U = i_mZ(r,c);
double **U_T = i_mZ(c,r); // :c,r
double **U_TA = i_mZ(c,c); // c,r r,c :c,c
double **U_TAr = i_mZ(c,r); // c,r :c,r
double **X = i_mZ(c,c); // c,r r,c :c,c U_TArV
double **invX = i_mZ(c,c); // c,r r,c :c,c invX
double **VinvX = i_mZ(r,c);
double **Pinv = i_mZ(r,r);
double **PinvA = i_mZ(r,c); // r,c | r,r
clrscrn();
printf(" A :");
p_mZ(A, S18,P13, S17,P13, C2);
stop();
clrscrn();
printf(" A :");
pE_mZ(A, S12,P3, S11,P3, C3);
printf(" U :");
X_U_mZ(A_T,U,FACTOR_E);
p_mZ(U, S10,P4, S8,P4, C3);
printf(" V :");
X_V_mZ(A_T,V,FACTOR_E);
p_mZ(V, S10,P4, S8,P4, C3);
ctranspose_mZ(U,U_T);
ctranspose_mZ(V,V_T);
stop();
clrscrn();
printf(" X = U_T * A * V :");
mul_mZ(U_T, A, U_TA); // U_TA : c,c
c_mZ(U_TA, U_TAr); // U_TAr : c,r
mul_mZ(U_TAr, V, X); // V : r,c
pE_mZ(X, S11,P4, S9,P4, C3);
printf(" invX :");
X_inv_mZ(X, invX);
pE_mZ(invX, S10,P4, S8,P4, C3);
stop();
clrscrn();
printf(" Pinv = V * invX * U_T:");
mul_mZ(V,invX,VinvX);
mul_mZ(VinvX,U_T,Pinv);
pE_mZ(Pinv, S14,P4, S12,P4, C2);
stop();
clrscrn();
printf(" Ide = Pinv * A ");
mul_mZ(Pinv,A,PinvA);
p_mZ(PinvA, S8,P4, S8,P4, C3);
f_mZ(A);
f_mZ(A_T);
f_mZ(V);
f_mZ(V_T);
f_mZ(U);
f_mZ(U_T);
f_mZ(U_TA);
f_mZ(U_TAr);
f_mZ(X);
f_mZ(invX);
f_mZ(VinvX);
f_mZ(Pinv);
f_mZ(PinvA);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(R5,C3);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
A :
+0.0000000002350 -0.0000000007950i +0.0000000008070 +0.0000000009750i
+0.0000000005790 +0.0000000002210i -0.0000000002220 +0.0000000005890i
-0.0000000000890 -0.0000000004440i +0.0000000005120 -0.0000000007200i
-0.0000000006300 -0.0000000007230i +0.0000000000570 +0.0000000004380i
-0.0000000002330 -0.0000000000380i +0.0000000000920 +0.0000000000370i
+0.0000000001510 +0.0000000001240i
-0.0000000005980 +0.0000000007940i
+0.0000000009240 +0.0000000002980i
-0.0000000003870 -0.0000000009860i
-0.0000000006420 +0.0000000004490i
Press return to continue.
A :
+2.350e-10 -7.950e-10i +8.070e-10 +9.750e-10i +1.510e-10 +1.240e-10i
+5.790e-10 +2.210e-10i -2.220e-10 +5.890e-10i -5.980e-10 +7.940e-10i
-8.900e-11 -4.440e-10i +5.120e-10 -7.200e-10i +9.240e-10 +2.980e-10i
-6.300e-10 -7.230e-10i +5.700e-11 +4.380e-10i -3.870e-10 -9.860e-10i
-2.330e-10 -3.800e-11i +9.200e-11 +3.700e-11i -6.420e-10 +4.490e-10i
U :
-0.0041 -0.4676i +0.0868 +0.5738i -0.2779 -0.0783i
+0.5416 -0.1861i -0.0328 -0.0270i +0.3112 +0.1319i
-0.4701 -0.3002i +0.0443 -0.2663i +0.3505 +0.1304i
-0.1779 +0.2631i +0.1287 +0.6862i +0.3279 -0.2396i
+0.2035 +0.0000i +0.3179 -0.0000i +0.7054 +0.0000i
V :
-0.0606 +0.4590i +0.5079 -0.1891i -0.4958 -0.4961i
+0.4656 +0.2456i -0.6356 +0.1409i +0.0125 -0.5467i
+0.7131 +0.0000i +0.5314 -0.0000i +0.4573 +0.0000i
+0.0000 +0.0000i +0.0000 +0.0000i +0.0000 +0.0000i
+0.0000 +0.0000i +0.0000 +0.0000i +0.0000 +0.0000i
Press return to continue.
X = U_T * A * V :
-1.9286e-09+1.2547e-09i +1.1374e-24-3.3087e-24i -3.1019e-25-5.1699e-26i
-2.2747e-24-4.6529e-25i -1.6683e-09+7.9520e-10i -3.1019e-25+2.5849e-25i
+5.1699e-26-2.5849e-26i -4.3944e-25-2.5849e-25i -2.4883e-10+4.1097e-10i
invX :
-3.6432e+08-2.3702e+08i +0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i
+0.0000e+00+0.0000e+00i -4.8845e+08-2.3282e+08i +0.0000e+00+0.0000e+00i
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i -1.0781e+09-1.7805e+09i
Press return to continue.
Pinv = V * invX * U_T:
+1.6634e+07 -1.9398e+08i +1.8807e+08 +4.2159e+08i
+3.9894e+08 -4.7627e+08i -2.6885e+08 +1.8438e+08i
+1.8735e+08 +2.0506e+08i -3.5819e+08 -3.3115e+08i
+0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i
+4.0913e+07 +5.7453e+08i -5.7291e+08 +5.7115e+08i
-1.6547e+08 +4.8286e+08i -3.9379e+08 -2.1104e+08i
-8.4631e+07 -2.9421e+08i -8.3089e+07 -1.2453e+08i
+0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i
-3.1227e+08 +9.6057e+08i
-6.0974e+08 +3.8450e+08i
-4.8314e+08 -6.4807e+08i
+0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i
Press return to continue.
Ide = Pinv * A
+1.0000 -0.0000i +0.0000 +0.0000i +0.0000 -0.0000i
-0.0000 +0.0000i +1.0000 -0.0000i -0.0000 -0.0000i
-0.0000 +0.0000i +0.0000 -0.0000i +1.0000 +0.0000i
+0.0000 +0.0000i +0.0000 +0.0000i +0.0000 +0.0000i
+0.0000 +0.0000i +0.0000 +0.0000i +0.0000 +0.0000i
Press return to continue
Press X return to stop