Mathc matrices/c23x
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : c04a.c */
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
double a[RA*(CA)]={
 2, 0,
 0, 3,
 0, 0,
 4, 5
double x[RA*(C1)]={
 -1, 
 2, 
 -3,
 -3,
double **A = ca_A_mR(a,i_mR(RA,CA));
double **AT = i_mR(CA,RA);
double **ATA = i_mR(CA,CA); // AT*A
double **invATA = i_mR(CA,CA); // inv(AT*A)
double **invATA_AT = i_mR(CA,RA); // inv(AT*A)*AT
double **V = i_mR(RA,RA); // inv(AT*A)*AT
double **X = ca_A_mR(x,i_mR(RA,C1));
double **VX = i_mR(RA,C1);
 clrscrn();
 printf(" A is subspace of R%d \n\n"
 " Find a transformation matrix for \n"
 " a projection onto R%d : \n\n"
 " Proj(x) = A * inv(AT*A) * AT * x \n\n",RA,RA);
 printf(" A :");
 p_mR(A,S5,P1,C7);
 stop();
 clrscrn();
 printf(" AT :");
 p_mR(transpose_mR(A,AT),S5,P1,C7);
 printf(" ATA :");
 p_mR(mul_mR(AT,A,ATA),S5,P1,C7);
 printf(" inv(AT*A) :");
 p_mR(inv_mR(ATA,invATA),S5,P4,C7); 
 printf(" inv(AT*A)*AT :");
 p_mR(mul_mR(invATA,AT,invATA_AT),S5,P4,C7); 
 printf(" V = A*inv(AT*A)*AT :");
 p_mR(mul_mR(A,invATA_AT,V),S5,P4,C7); 
 stop(); 
 clrscrn();
 printf(" V is transformation matrix for \n"
 " a projection onto a subspace R%d \n\n"
 " V : ",RA);
 p_mR(V,S5,P4,C7); 
 printf(" X :");
 p_mR(X,S5,P1,C7);
 printf(" Proj(x) = A * inv(AT*A) * AT * x \n\n"); 
 printf(" Proj(x) = V * x :"); 
 p_mR(mul_mR(V,X,VX),S5,P4,C7); 
 stop(); 
 f_mR(A);
 f_mR(AT);
 f_mR(ATA); // AT*A
 f_mR(invATA); // inv(AT*A)
 f_mR(invATA_AT); // inv(AT*A)*AT
 f_mR(V); // A*inv(AT*A)*AT 
 f_mR(X); 
 f_mR(VX); 
 return 0;
/* ------------------------------------ */
Trouver une projection sur un sous-espace vectoriel par une application linéaire :
 Proj(x) = V * x
 V = A * inv(AT*A) * AT

Exemple de sortie écran :
 A is subspace of R4 
 Find a transformation matrix for 
 a projection onto R4 : 
 Proj(x) = A * inv(AT*A) * AT * x 
 A :
 +2.0 +0.0 
 +0.0 +3.0 
 +0.0 +0.0 
 +4.0 +5.0 
 Press return to continue. 
 AT :
 +2.0 +0.0 +0.0 +4.0 
 +0.0 +3.0 +0.0 +5.0 
 ATA :
+20.0 +20.0 
+20.0 +34.0 
 inv(AT*A) :
+0.1214 -0.0714 
-0.0714 +0.0714 
 inv(AT*A)*AT :
+0.2429 -0.2143 +0.0000 +0.1286 
-0.1429 +0.2143 +0.0000 +0.0714 
 V = A*inv(AT*A)*AT :
+0.4857 -0.4286 +0.0000 +0.2571 
-0.4286 +0.6429 +0.0000 +0.2143 
+0.0000 +0.0000 +0.0000 +0.0000 
+0.2571 +0.2143 +0.0000 +0.8714 
 Press return to continue. 
 V is transformation matrix for 
 a projection onto a subspace R4 
 V : 
+0.4857 -0.4286 +0.0000 +0.2571 
-0.4286 +0.6429 +0.0000 +0.2143 
+0.0000 +0.0000 +0.0000 +0.0000 
+0.2571 +0.2143 +0.0000 +0.8714 
 X :
 -1.0 
 +2.0 
 -3.0 
 -3.0 
 Proj(x) = A * inv(AT*A) * AT * x 
 Proj(x) = V * x :
-2.1143 
+1.0714 
+0.0000 
-2.4429 
 Press return to continue.

Mathc matrices/c24b
Application 
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : c05a.c */
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
double a[RA*(CA)]={
 2, 0,
 0, 3,
 0, 0,
 4, 5,
 1, 0
double x[RA*(C1)]={
 -1, 
 2, 
 -3,
 -3,
 -1,
double **A = ca_A_mR(a,i_mR(RA,CA));
double **AT = i_mR(CA,RA);
double **ATA = i_mR(CA,CA); // AT*A
double **invATA = i_mR(CA,CA); // inv(AT*A)
double **invATA_AT = i_mR(CA,RA); // inv(AT*A)*AT
double **V = i_mR(RA,RA); // inv(AT*A)*AT
double **X = ca_A_mR(x,i_mR(RA,C1));
double **VX = i_mR(RA,C1);
 clrscrn();
 printf(" A is subspace of R%d \n\n"
 " Find a transformation matrix for \n"
 " a projection onto R%d : \n\n"
 " Proj(x) = A * inv(AT*A) * AT * x \n\n",RA,RA);
 printf(" A :");
 p_mR(A,S5,P1,C7);
 stop();
 clrscrn();
 printf(" AT :");
 p_mR(transpose_mR(A,AT),S5,P1,C7);
 printf(" ATA :");
 p_mR(mul_mR(AT,A,ATA),S5,P1,C7);
 printf(" inv(AT*A) :");
 p_mR(inv_mR(ATA,invATA),S5,P4,C7); 
 printf(" inv(AT*A)*AT :");
 p_mR(mul_mR(invATA,AT,invATA_AT),S5,P4,C7); 
 printf(" V = A*inv(AT*A)*AT :");
 p_mR(mul_mR(A,invATA_AT,V),S5,P4,C7); 
 stop(); 
 clrscrn();
 printf(" V is transformation matrix for \n"
 " a projection onto a subspace R%d :\n\n",RA);
 p_mR(V,S5,P4,C7); 
 printf(" Proj(x) = A * inv(AT*A) * AT * x \n\n"); 
 printf(" Proj(x) = V * x :"); 
 p_mR(mul_mR(V,X,VX),S5,P4,C7); 
 stop(); 
 f_mR(A);
 f_mR(AT);
 f_mR(ATA); // AT*A
 f_mR(invATA); // inv(AT*A)
 f_mR(invATA_AT); // inv(AT*A)*AT
 f_mR(V); // A*inv(AT*A)*AT 
 f_mR(X); 
 f_mR(VX); 
/* ------------------------------------ */
int main(void)

fun();
 return 0;
/* ------------------------------------ */
Trouver une projection sur un sous-espace vectoriel par une application linéaire :
 Proj(x) = V * x
 V = A * inv(AT*A) * AT

Exemple de sortie écran :
 A is subspace of R5 
 Find a transformation matrix for 
 a projection onto R5 : 
 Proj(x) = A * inv(AT*A) * AT * x 
 A :
 +2.0 +0.0 
 +0.0 +3.0 
 +0.0 +0.0 
 +4.0 +5.0 
 +1.0 +0.0 
 Press return to continue. 
 ------------------------------------ 
 AT :
 +2.0 +0.0 +0.0 +4.0 +1.0 
 +0.0 +3.0 +0.0 +5.0 +0.0 
 ATA :
+21.0 +20.0 
+20.0 +34.0 
 inv(AT*A) :
+0.1083 -0.0637 
-0.0637 +0.0669 
 inv(AT*A)*AT :
+0.2166 -0.1911 +0.0000 +0.1146 +0.1083 
-0.1274 +0.2006 +0.0000 +0.0796 -0.0637 
 V = A*inv(AT*A)*AT :
+0.4331 -0.3822 +0.0000 +0.2293 +0.2166 
-0.3822 +0.6019 +0.0000 +0.2389 -0.1911 
+0.0000 +0.0000 +0.0000 +0.0000 +0.0000 
+0.2293 +0.2389 +0.0000 +0.8567 +0.1146 
+0.2166 -0.1911 +0.0000 +0.1146 +0.1083 
 Press return to continue. 
 ------------------------------------ 
 V is transformation matrix for 
 a projection onto a subspace R5 :
+0.4331 -0.3822 +0.0000 +0.2293 +0.2166 
-0.3822 +0.6019 +0.0000 +0.2389 -0.1911 
+0.0000 +0.0000 +0.0000 +0.0000 +0.0000 
+0.2293 +0.2389 +0.0000 +0.8567 +0.1146 
+0.2166 -0.1911 +0.0000 +0.1146 +0.1083 
 Proj(x) = A * inv(AT*A) * AT * x 
 Proj(x) = V * x :
-2.1019 
+1.0605 
+0.0000 
-2.4363 
-1.0510 
 Press return to continue.

Mathc matrices/c23u
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : c03b.c */
int main(void)
double a_Tb[RA*(CA+C1)]={
 -2,1,0,0,
 -3,0,1,0

double **A_Tb = ca_A_mR(a_Tb,i_Abr_Ac_bc_mR(RA,CA,C1));
double **A_T = c_Ab_A_mR(A_Tb,i_mR(RA,CA));
double **b = c_Ab_b_mR(A_Tb,i_mR(RA,C1));
 clrscrn();
 printf(" Verify if A is Basis for a Row Space by Row Reduction :\n\n");
 printf(" A_T :");
 p_mR(A_T,S6,P1,C10);
 printf(" b :");
 p_mR(b,S6,P1,C10);
 printf(" A_Tb :");
 p_mR(A_Tb,S6,P1,C10);
 stop();
 clrscrn();
 printf(" The nonzero row vectors of A_Tb form a basis\n"
 " for the row space of A_Tb, and hence form a \n"
 " basis for the row space of A \n\n"
 " A_Tb :");
 p_mR(A_Tb,S7,P3,C10);
 printf(" A_Tb : gj_PP_mR(A_Tb,NO) :");
 gj_PP_mR(A_Tb,NO);
 p_mR(A_Tb,S7,P3,C10);
 stop();
 f_mR(A_Tb);
 f_mR(b);
 f_mR(A_T);
 return 0;
/* ------------------------------------ */
Trouver une projection sur un sous-espace vectoriel par une application linéaire :

Exemple de sortie écran :
 Verify if A is Basis for a Row Space by Row Reduction :
 A_T :
 -2.0 +1.0 +0.0 
 -3.0 +0.0 +1.0 
 b :
 +0.0 
 +0.0 
 A_Tb :
 -2.0 +1.0 +0.0 +0.0 
 -3.0 +0.0 +1.0 +0.0 
 Press return to continue. 
 ------------------------------------ 
 The nonzero row vectors of A_Tb form a basis
 for the row space of A_Tb, and hence form a 
 basis for the row space of A 
 A_Tb :
 -2.000 +1.000 +0.000 +0.000 
 -3.000 +0.000 +1.000 +0.000 
 A_Tb : gj_PP_mR(A_Tb,NO) :
 +1.000 -0.000 -0.333 -0.000 
 +0.000 +1.000 -0.667 +0.000 
 Press return to continue.

Mathc matrices/c23y
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : c04b.c */
int main(void)
double a_Tb[RA*(CA+C1)]={
 2,0,0,4,0,
 0,3,0,5,0