Mathc complexes/a66
Installer et compiler ces fichiers dans votre répertoire de travail.
c02c.c |
---|
/* ------------------------------------ */
/* Xave as : c02c.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 **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(" 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, S10,P4, S8,P4, C2);
stop();
clrscrn();
printf(" Ide = Pinv * A ");
mul_mZ(Pinv,A,PinvA);
p_mZ(PinvA, S10,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 :
+24.00 +33.00i -93.00 +24.00i -98.00 -75.00i
+8.00 +78.00i +87.00 +65.00i +37.00 +52.00i
-64.00 +49.00i +71.00 +98.00i +90.00 +8.00i
+21.00 -13.00i -44.00 -53.00i +83.00 -36.00i
-74.00 -41.00i -41.00 -29.00i +36.00 -76.00i
U :
+0.2954 -0.4462i -0.2083 -0.3424i -0.3996 +0.1691i
-0.4839 +0.1848i -0.0146 -0.3006i -0.3088 -0.0158i
-0.4278 +0.1724i +0.5602 -0.3394i -0.0533 +0.2841i
+0.2793 +0.2196i +0.2064 +0.1526i -0.6654 +0.1069i
+0.3260 -0.0000i +0.5038 +0.0000i +0.4222 -0.0000i
V :
+0.1857 -0.0826i -0.6450 +0.2900i +0.6172 -0.2787i
+0.6097 +0.4056i -0.2904 -0.1941i -0.4873 -0.3229i
+0.6500 -0.0000i +0.6147 -0.0000i +0.4469 +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 :
-21.3676-261.3863i -0.0000 +0.0000i -0.0000 +0.0000i
+0.0000 -0.0000i +174.7168 -50.3110i +0.0000 -0.0000i
-0.0000 -0.0000i +0.0000 +0.0000i -71.9844 -26.6970i
invX :
-3.1067e-04+3.8004e-03i +0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i
+0.0000e+00+0.0000e+00i +5.2853e-03+1.5219e-03i +0.0000e+00+0.0000e+00i
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i -1.2212e-02+4.5291e-03i
Press return to continue.
Copy/Past into the octave window.
A=[
+24+33*i,-93+24*i,-98-75*i;
+8+78*i,+87+65*i,+37+52*i;
-64+49*i,+71+98*i,+90+8*i;
+21-13*i,-44-53*i,+83-36*i;
-74-41*i,-41-29*i,+36-76*i]
format short e
pinv(A)
Press return to continue.
Pinv = V * invX * U_T:
+3.9187e-03-2.5191e-03i +1.7414e-03-3.5800e-03i
-3.3974e-03-2.1912e-03i -6.1438e-04-1.5106e-03i
+3.6432e-04+1.6712e-03i +1.8786e-03-9.0599e-04i
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i
-2.3163e-04+9.6834e-05i +4.3597e-03-2.6050e-03i
+1.0200e-03-4.0810e-03i -5.2297e-03-1.0695e-03i
+2.8808e-03+2.0477e-03i +5.1473e-03-3.3190e-04i
+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.5058e-03+3.1332e-03i
+1.9415e-03+7.0787e-04i
-7.3326e-04+2.1311e-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
+0.0000 +0.0000i +0.0000 +0.0000i +0.0000 +0.0000i
Press return to continue
Press X return to stop