Mathc complexes/048
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-1
/* ------------------------------------ */
#define RA R3
#define CA C2
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double a[RA*(CA*C2)] ={
1,5, -1,5,
3,5, 2,5,
-2,5, 4,5};
double **A = ca_A_mZ(a, i_mZ(RA,CA));
double **A_T = ctranspose_mZ(A,i_mZ(CA,RA));
double **V = i_mZ(RA,CA);
double **V_T = i_mZ(CA,RA);
double **U = i_mZ(RA,CA);
double **U_T = i_mZ(CA,RA);
double **U_TA = i_mZ(CA,CA);
double **U_TAr = i_mZ(CA,RA);
double **X = i_mZ(CA,CA); /* U_TArV */
double **invX = i_mZ(CA,CA);
double **VinvX = i_mZ(RA,CA);
double **Pinv = i_mZ(RA,RA);
double **PinvA = i_mZ(RA,CA);
clrscrn();
printf(" A :");
p_mZ(A, S10,P2, S8,P2, 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);
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");
printf(" Pinv = V * invX * U_T:");
mul_mZ(V,invX,VinvX);
mul_mZ(VinvX,U_T,Pinv);
pE_mZ(Pinv, S10,P4, S8,P4, C3);
printf(" Ide = Pinv * A ");
mul_mZ(Pinv,A,PinvA);
p_mZ(PinvA, S10,P4, S8,P4, C3);
stop();
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);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
A :
+1.00 +5.00i -1.00 +5.00i
+3.00 +5.00i +2.00 +5.00i
-2.00 +5.00i +4.00 +5.00i
U :
+0.5232 +0.1083i -0.4902 -0.0423i
+0.5830 -0.1592i -0.3484 +0.0420i
+0.5910 +0.0000i +0.7967 +0.0000i
V :
+0.6756 -0.1407i -0.7085 +0.1476i
+0.7237 +0.0000i +0.6901 +0.0000i
+0.0000 +0.0000i +0.0000 +0.0000i
X = U_T * A * V :
+3.8029 +12.3153i +0.0000 +0.0000i
-0.0000 +0.0000i +4.3168 -0.4861i
invX :
+2.2891e-02-7.4131e-02i +0.0000e+00+0.0000e+00i
+0.0000e+00+0.0000e+00i +2.2875e-01+2.5757e-02i
Press return to continue.
Copy/Past into the octave window.
A=[
+1+5*i,-1+5*i;
+3+5*i,+2+5*i;
-2+5*i,+4+5*i]
format short e
pinv(A)
Pinv = V * invX * U_T:
+7.7512e-02-4.3062e-02i +6.9856e-02-2.8708e-02i -1.2919e-01-1.9139e-02i
-7.5279e-02-3.1898e-02i -3.6045e-02-4.1467e-02i +1.3557e-01-1.7544e-02i
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i
Ide = Pinv * A
+1.0000 -0.0000i +0.0000 -0.0000i
-0.0000 +0.0000i +1.0000 +0.0000i
+0.0000 +0.0000i +0.0000 +0.0000i
Press return to continue.