Mathc matrices/07n
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00e.c |
|---|
/* ------------------------------------ */
/* Xave as : c00e.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define RA R5
#define CA C5
#define Cb C1
/* ------------------------------------ */
#define FACTOR_E +1.E-2
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double ta[RA*CA]={
/* x**2 y**2 x y e */
+1, +0, +0, +0, +0,
+1, +4, +1, +2, +1,
+4, +64, +2, -8, +1,
+9, +64, +3, -8, +1,
+16, +9, +4, -3, +1,
};
double tb[RA*C1]={
/* = 0 */
+1,
+0,
+0,
+0,
+0
};
double **A = ca_A_mRZ(ta,i_mZ(RA,CA));
double **A_T = ctranspose_mZ(A, i_mZ(CA,RA));
double **b = ca_A_mRZ(tb, i_mZ(RA,C1));
double **x = i_mZ(CA,C1);
double **V = i_mZ(CA,CA);
double **V_T = i_mZ(CA,CA);
double **U = i_mZ(RA,CA);
double **U_T = i_mZ(CA,RA);
double **U_TA = i_mZ(CA,CA); // CA,RA RA,CA :CA,CA
double **U_TAV = i_mZ(CA,CA); // CA,CA CA,CA :CA,CA
double **invU_TAV = i_mZ(CA,CA); // :CA,CA
double **V_invU_TAV = i_mZ(CA,CA); // CA,CA CA,CA :CA,CA
double **Pinv = i_mZ(CA,RA);
// Pinv = V_invU_TAV * U_T // CA,CA CA,RA :CA,RA
clrscrn();
printf(" A :");
p_mRZ(A, S10,P2, C6);
printf(" b :");
p_mRZ(b, S10,P2, C6);
stop();
clrscrn();
printf(" U :");
X_U_mZ(A_T,U,FACTOR_E);
p_mRZ(U, S10,P4, C6);
printf(" V :");
X_V_mZ(A_T,V,FACTOR_E);
p_mRZ(V, S10,P4, C6);
ctranspose_mZ(U,U_T);
ctranspose_mZ(V,V_T);
stop();
clrscrn();
printf(" U_TAV :");
mul_mZ(U_T, A, U_TA); // U_TA CA,RA RA,CA :CA,CA
mul_mZ(U_TA, V, U_TAV ); // V :CA,CA
p_mRZ(U_TAV, S11,P4, C6); // U_TAV CA,CA CA,CA :CA,CA
printf(" inv(U_TAV) :");
X_inv_mZ(U_TAV, invU_TAV);
pE_mRZ(invU_TAV, S10,P4, C6);
printf(" Pinv = V * inv(U_TAV) * U_T:");
mul_mZ(V, invU_TAV, V_invU_TAV);
mul_mZ(V_invU_TAV, U_T, Pinv);
pE_mRZ(Pinv, S13,P4, C6);
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);
p_mRZ(x, S12,P4, C6);
printf(" The coefficients a, b, c, d, e, of the curve are : \n\n"
" %+.2fx**2 %+.2fy**2 %+.2fx %+.2fy %+.2f = 0\n\n"
,x[R1][C1],x[R2][C1],x[R3][C1],x[R4][C1],x[R5][C1]);
stop();
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(invU_TAV);
f_mZ(V_invU_TAV);
f_mZ(Pinv);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
A :
+1.00 +0.00 +0.00 +0.00 +0.00
+1.00 +4.00 +1.00 +2.00 +1.00
+4.00 +64.00 +2.00 -8.00 +1.00
+9.00 +64.00 +3.00 -8.00 +1.00
+16.00 +9.00 +4.00 -3.00 +1.00
b :
+1.00
+0.00
+0.00
+0.00
+0.00
Press return to continue.
U :
+0.0013 +0.0604 -0.0088 -0.5238 +0.8497
+0.0418 +0.0312 -0.9932 +0.0937 +0.0452
+0.6976 -0.2442 +0.0911 +0.5602 +0.3626
+0.7046 +0.0720 -0.0415 -0.5969 -0.3746
+0.1226 +0.9647 +0.0588 +0.2161 +0.0651
V :
+0.1204 +0.9578 +0.0247 -0.2325 +0.1160
+0.9838 -0.1398 +0.0956 -0.0587 -0.0047
+0.0437 +0.2280 +0.2490 +0.6489 -0.6805
-0.1243 -0.0916 +0.9106 -0.3777 -0.0656
+0.0169 +0.0519 +0.3147 +0.6155 +0.7205
Press return to continue.
U_TAV :
+92.5156 -0.0000 -0.0000 +0.0000 -0.0000
-0.0000 +15.8663 -0.0000 +0.0000 -0.0000
-0.0000 -0.0000 -2.8111 -0.0000 +0.0000
-0.0000 -0.0000 -0.0000 +0.4439 -0.0000
-0.0000 -0.0000 +0.0000 +0.0000 +0.1365
inv(U_TAV) :
+1.0809e-02 +0.0000e+00 +0.0000e+00 +0.0000e+00 +0.0000e+00
+0.0000e+00 +6.3027e-02 +0.0000e+00 +0.0000e+00 +0.0000e+00
+0.0000e+00 +0.0000e+00 -3.5573e-01 +0.0000e+00 +0.0000e+00
+0.0000e+00 +0.0000e+00 +0.0000e+00 +2.2529e+00 +0.0000e+00
+0.0000e+00 +0.0000e+00 +0.0000e+00 +0.0000e+00 +7.3262e+00
Pinv = V * inv(U_TAV) * U_T:
+1.0000e+00 +7.2584e-11 +4.9046e-10 -5.1492e-10 +1.4048e-10
+4.0000e-02 +2.0000e-02 -8.0000e-02 +1.0000e-01 -4.0000e-02
-5.0000e+00 -3.3214e-10 -1.0000e+00 +1.0000e+00 -6.9036e-10
+4.0000e-02 +2.2000e-01 -6.8000e-01 +7.0000e-01 -2.4000e-01
+3.7600e+00 +4.8000e-01 +2.6800e+00 -2.8000e+00 +6.4000e-01
Press return to continue.
A x = b
Pinv A x = Pinv b
Ide x = Pinv b
x = Pinv b
+1.0000
+0.0400
-5.0000
+0.0400
+3.7600
The coefficients a, b, c, d, e, of the curve are :
+1.00x**2 +0.04y**2 -5.00x +0.04y +3.76 = 0
Press return to continue.