Mathc complexes/a312
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c02d.c |
---|
/* ------------------------------------ */
/* Xave as : c02d.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define FACTOR_E +1.E-2
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r,int c)
{
double **A = r_mZ(i_mZ(r,c ),99);
double **b = r_mZ(i_mZ(r,C1),99);
double **x = i_mZ(r,C1) ;
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, S10,P2, S8,P2, C3);
printf(" b :");
p_mZ(b, S10,P2, S8,P2, C3);
stop();
clrscrn();
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
p_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(" Copy/Past into the octave window.\n\n");
p_Octave_mZ(A,"A",P0, P0);
printf(" format short e\n");
printf(" pinv(A)\n\n");
stop();
clrscrn();
printf(" Pinv = V * invX * U_T:");
mul_mZ(V, invX, VinvX);
mul_mZ(VinvX, U_T, Pinv);
pE_mZ(Pinv, S13,P4, S13,P4, C2);
stop();
clrscrn();
printf(" Ide = Pinv * A ");
mul_mZ(Pinv, A, PinvA);
p_mZ(PinvA, S10,P4, S8,P4, C3);
stop();
clrscrn();
printf(" A x = b \n"
" Pinv A x = Pinv b \n"
" Ide x = Pinv b \n\n"
" x = Pinv b ");
mul_mZ(Pinv, b, x);
pE_mZ(x, S12,P4, S12,P4, C3);
f_mZ(A);
f_mZ(A_T);
f_mZ(b);
f_mZ(x);
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);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(R4,C3);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
A :
-88.00 +4.00i -11.00 +69.00i +64.00 -12.00i
+63.00 -45.00i -47.00 +67.00i -51.00 -77.00i
-39.00 -59.00i +29.00 -52.00i -6.00 +76.00i
+95.00 +80.00i +61.00 -61.00i +64.00 +40.00i
b :
+63.00 +95.00i
-77.00 +12.00i
-68.00 +40.00i
-41.00 +13.00i
Press return to continue.
U :
-0.1260 +0.2579i -0.5969 +0.0121i +0.5910 -0.4069i
-0.3421 -0.4810i -0.0237 +0.3911i +0.2397 +0.2072i
-0.1121 +0.2303i +0.2881 -0.5269i -0.1360 -0.2271i
+0.7096 +0.0000i +0.3598 +0.0000i +0.5610 +0.0000i
V :
+0.3756 -0.6260i -0.5192 +0.1337i +0.2028 +0.3722i
+0.1108 +0.4539i -0.5826 +0.0929i +0.4767 -0.4542i
+0.4987 +0.0000i +0.6037 +0.0000i +0.6219 +0.0000i
+0.0000 +0.0000i +0.0000 +0.0000i +0.0000 +0.0000i
Press return to continue.
X = U_T * A * V :
+214.3770 +16.1542i +0.0000 +0.0000i +0.0000 +0.0000i
-0.0000 +0.0000i -142.4364+101.5046i +0.0000 -0.0000i
+0.0000 +0.0000i -0.0000 -0.0000i +54.6533 +35.0607i
invX :
+4.6383e-03-3.4952e-04i +0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i
+0.0000e+00+0.0000e+00i -4.6561e-03-3.3181e-03i +0.0000e+00+0.0000e+00i
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i +1.2963e-02-8.3156e-03i
Press return to continue.
Copy/Past into the octave window.
A=[
-88+4*i,-11+69*i,+64-12*i;
+63-45*i,-47+67*i,-51-77*i;
-39-59*i,+29-52*i,-6+76*i;
+95+80*i,+61-61*i,+64+40*i]
format short e
pinv(A)
Press return to continue.
Pinv = V * invX * U_T:
-5.6338e-04 +3.4819e-03i +3.3234e-03 +1.9222e-04i
+4.0918e-03 -6.2113e-03i -2.1749e-03 -4.4595e-03i
+8.1857e-03 +8.7853e-04i -5.6404e-04 -5.9091e-04i
+0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i
-2.1162e-03 +2.6865e-03i +5.3215e-03 +3.1725e-06i
+2.3905e-03 +3.5229e-03i +2.9123e-03 -3.5204e-03i
+2.4077e-05 -3.7649e-05i +5.1525e-03 -3.7457e-03i
+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
Press return to continue.
A x = b
Pinv A x = Pinv b
Ide x = Pinv b
x = Pinv b
-8.0626e-01 -7.3683e-03i
+6.9173e-01 +3.5295e-01i
+3.2007e-01 +1.0958e+00i
+0.0000e+00 +0.0000e+00i
Press return to continue
Press X return to stop