Mathc matrices/07j
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
|---|
/* ------------------------------------ */
/* Xave as : c00a.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.00, +0.00, +0.00, +0.00, +0.00,
+1.00, +0.00, +1.00, +0.00, +1.00,
+4.00, +9.00, +2.00, +3.00, +1.00,
+9.00, +16.00, +3.00, +4.00, +1.00,
+16.00, +0.00, +4.00, +0.00, +1.00
};
double tb[RA*C1]={
/* = 0 */
+1.00,
+0.00,
+0.00,
+0.00,
+0.00,
};
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 +0.00 +1.00 +0.00 +1.00
+4.00 +9.00 +2.00 +3.00 +1.00
+9.00 +16.00 +3.00 +4.00 +1.00
+16.00 +0.00 +4.00 +0.00 +1.00
b :
+1.00
+0.00
+0.00
+0.00
+0.00
U :
+0.0289 +0.0512 +0.1442 +0.0542 -0.9863
+0.0408 +0.0620 -0.8159 -0.5547 -0.1454
+0.4075 -0.2938 -0.4829 +0.7164 -0.0345
+0.7618 -0.4126 +0.2828 -0.4111 +0.0196
+0.5010 +0.8584 +0.0209 +0.0844 +0.0669
V :
+0.6919 +0.6772 -0.1999 -0.0297 +0.1477
+0.6620 -0.6990 -0.1291 +0.2366 -0.0235
+0.2148 +0.1262 +0.6129 +0.0319 -0.7492
+0.1783 -0.1914 +0.2290 -0.9226 +0.1670
+0.0714 +0.0162 +0.7179 +0.3014 +0.6233
Press return to continue.
U_TAV :
+23.9529 +0.0000 +0.0000 -0.0000 +0.0000
+0.0000 +13.2294 +0.0000 +0.0000 +0.0000
-0.0000 -0.0000 -1.3860 +0.0000 -0.0000
-0.0000 -0.0000 -0.0000 -0.5473 +0.0000
+0.0000 +0.0000 +0.0000 -0.0000 -0.1498
inv(U_TAV) :
+4.1749e-02 +0.0000e+00 +0.0000e+00 +0.0000e+00 +0.0000e+00
+0.0000e+00 +7.5589e-02 +0.0000e+00 +0.0000e+00 +0.0000e+00
+0.0000e+00 +0.0000e+00 -7.2148e-01 +0.0000e+00 +0.0000e+00
+0.0000e+00 +0.0000e+00 +0.0000e+00 -1.8273e+00 +0.0000e+00
+0.0000e+00 +0.0000e+00 +0.0000e+00 +0.0000e+00 -6.6769e+00
Pinv = V * inv(U_TAV) * U_T:
+1.0000e+00 +1.4938e-13 -3.3216e-13 +1.9117e-13 -3.2904e-14
-1.6667e-01 +1.3889e-01 -3.3333e-01 +2.5000e-01 -5.5556e-02
-5.0000e+00 -3.3333e-01 +1.3764e-12 -7.9101e-13 +3.3333e-01
+1.1667e+00 -6.3889e-01 +1.3333e+00 -7.5000e-01 +5.5556e-02
+4.0000e+00 +1.3333e+00 -2.5177e-13 +1.4093e-13 -3.3333e-01
Press return to continue.
A x = b
Pinv A x = Pinv b
Ide x = Pinv b
x = Pinv b
+1.0000
-0.1667
-5.0000
+1.1667
+4.0000
The coefficients a, b, c, d, e, of the curve are :
+1.00x**2 -0.17y**2 -5.00x +1.17y +4.00 = 0
Press return to continue.