Mathc complexes/047
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* save as : c00a.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#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 = i_mZ(CA,RA);
double **A_TA = i_mZ(CA,CA); // A_T*A
double **invA_TA = i_mZ(CA,CA); // inv(A_T*A)
double **Pinv = i_mZ(CA,RA); // inv(A_T*A)*A_T
double **PinvA = i_mZ(CA,CA); // inv(A_T*A)*A_T
clrscrn();
printf(" A :");
p_mZ(A,S5,P2,S5,P2,C7);
printf(" A_T :");
p_mZ(ctranspose_mZ(A,A_T),S5,P4,S5,P4,C7);
printf(" A_TA :");
p_mZ(mul_mZ(A_T,A,A_TA),S5,P4,S5,P4,C7);
printf(" inv(A_TA) :");
p_mZ(inv_mZ(A_TA,invA_TA),S5,P4,S5,P4,C7);
printf(" Pinv = inv(A_TA)*A_T :");
pE_mZ(mul_mZ(invA_TA,A_T,Pinv),S5,P4,S5,P4,C7);
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 = inv(A_TA)*A_T :");
pE_mZ(mul_mZ(invA_TA,A_T,Pinv),S5,P4,S5,P4,C7);
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(A_TA);
f_mZ(invA_TA);
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
A_T :
+1.0000-5.0000i +3.0000-5.0000i -2.0000-5.0000i
-1.0000-5.0000i +2.0000-5.0000i +4.0000-5.0000i
A_TA :
+89.0000+0.0000i +72.0000-15.0000i
+72.0000+15.0000i +96.0000+0.0000i
inv(A_TA) :
+0.0306+0.0000i -0.0230+0.0048i
-0.0230-0.0048i +0.0284+0.0000i
Pinv = inv(A_TA)*A_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
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 = inv(A_TA)*A_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
Ide = Pinv * A
+1.0000 -0.0000i -0.0000 -0.0000i
+0.0000 -0.0000i +1.0000 +0.0000i
Press return to continue.