Mathc matrices/c23r
Application 
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : c00a.c */
int main(void)
double ab[R4*C7]={
 +1, 3, -2, 0, +2, +0, 0,
 +2, 6, -5, -2, +4, -3, 0,
 0, 0, +5, 10, 0, 15, 0, 
 2, 6, 0, 8, 4, 18, 0, 
double **Ab = ca_A_mR(ab,i_Abr_Ac_bc_mR(R4,C6,C1));
double **A = c_Ab_A_mR(Ab,i_mR(R4,C6));
double **b = c_Ab_b_mR(Ab,i_mR(R4,C1));
double **Ab_free = i_Abr_Ac_bc_mR(csize_A_R(Ab),csize_A_R(Ab),C1+C3);
double **b_free = i_mR(rsize_R(Ab_free),csize_b_R(Ab_free)); 
double **cFree1 = i_mR(R6,C1);
double **cFree2 = i_mR(R6,C1);
double **cFree1plscFree2 = i_mR(R6,C1);
double **A_cFree1plscFree2 = i_mR(rsize_R(A),csize_R(cFree1plscFree2)) ;
int r;
 clrscrn();
 printf(" Verify if the sum of two columns of b_free\n"
 " is orthogonal to A :\n\n");
 printf(" A :");
 p_mR(A,S6,P1,C10);
 printf(" b :");
 p_mR(b,S6,P1,C10);
 printf(" Ab :");
 p_mR(Ab,S6,P1,C10);
 stop();
 gj_PP_mR(Ab,NO); 
 put_var_mR(Ab,Ab_free); 
 put_freeV_mR(Ab_free);
 r = rsize_R(Ab_free);
 while(r>R1) 
 zero_below_pivot_gj1Ab_mR(Ab_free,r--);
 clrscrn();
 c_Ab_b_mR(Ab_free,b_free);
 printf(" b_free :"); 
 p_mR(b_free,S10,P3,C7);
 c_c_mR(b_free,C_FREE1,cFree1,C1);
 c_c_mR(b_free,C_FREE2,cFree2,C1);
 printf(" C%d + C%d :",C_FREE1,C_FREE2); 
 p_mR(add_mR(cFree1,cFree2,cFree1plscFree2),S10,P3,C7);
 printf(" A * (C%d+C%d) :",C_FREE1,C_FREE2); 
 p_mR(mul_mR(A,cFree1plscFree2,A_cFree1plscFree2),S10,P3,C7);
 stop(); 
 f_mR(Ab);
 f_mR(Ab_free);
 f_mR(b_free);
 f_mR(b);
 f_mR(A);
 f_mR(cFree1); 
 f_mR(cFree2);
 f_mR(cFree1plscFree2);
 f_mR(A_cFree1plscFree2);
 return 0;
/* ------------------------------------ */
J'ai éliminé tous les affichages intermédiaire. On peut sélectionner les colonnes de travail dans le code ci-dessous.

Exemple de sortie écran :
 Verify if the sum of two columns of b_free
 is orthogonal to A :
 A :
 +1.0 +3.0 -2.0 +0.0 +2.0 +0.0 
 +2.0 +6.0 -5.0 -2.0 +4.0 -3.0 
 +0.0 +0.0 +5.0 +10.0 +0.0 +15.0 
 +2.0 +6.0 +0.0 +8.0 +4.0 +18.0 
 b :
 +0.0 
 +0.0 
 +0.0 
 +0.0 
 Ab :
 +1.0 +3.0 -2.0 +0.0 +2.0 +0.0 +0.0 
 +2.0 +6.0 -5.0 -2.0 +4.0 -3.0 +0.0 
 +0.0 +0.0 +5.0 +10.0 +0.0 +15.0 +0.0 
 +2.0 +6.0 +0.0 +8.0 +4.0 +18.0 +0.0 
 Press return to continue. 
 ------------------------------------ 
 b_free :
 +0.000 -3.000 -4.000 -2.000 
 +0.000 +1.000 +0.000 +0.000 
 +0.000 +0.000 -2.000 +0.000 
 +0.000 +0.000 +1.000 +0.000 
 +0.000 +0.000 +0.000 +1.000 
 +0.000 +0.000 +0.000 +0.000 
 C3 + C4 :
 -6.000 
 +0.000 
 -2.000 
 +1.000 
 +1.000 
 +0.000 
 A * (C3+C4) :
 +0.000 
 +0.000 
 +0.000 
 +0.000 
 Press return to continue.

Mathc matrices/c23s
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : c00b.c */
int main(void)
double ab[R4*C7]={
 +1, 3, -2, 0, +2, +0, 0,
 +2, 6, -5, -2, +4, -3, 0,
 0, 0, +5, 10, 0, 15, 0, 
 2, 6, 0, 8, 4, 18, 0, 
double **Ab = ca_A_mR(ab,i_Abr_Ac_bc_mR(R4,C6,C1));
double **A = c_Ab_A_mR(Ab,i_mR(R4,C6));
double **b = c_Ab_b_mR(Ab,i_mR(R4,C1));
double **Ab_free = i_Abr_Ac_bc_mR(csize_A_R(Ab),csize_A_R(Ab),C1+C3);
double **b_free = i_mR(rsize_R(Ab_free),csize_b_R(Ab_free)); 
double **cFree = i_mR(R6,C1);
double **s_cFree = i_mR(R6,C1);
double **A_s_cFree = i_mR(rsize_R(A),csize_R(s_cFree)) ;
int r;
 clrscrn();
 printf(" Verify if the scalar multiplication of a column of b_free\n"
 " is orthogonal to A :\n\n");
 printf(" A :");
 p_mR(A,S6,P1,C10);
 printf(" b :");
 p_mR(b,S6,P1,C10);
 printf(" Ab :");
 p_mR(Ab,S6,P1,C10);
 stop();
 gj_PP_mR(Ab,NO); 
 put_var_mR(Ab,Ab_free); 
 put_freeV_mR(Ab_free);
 r = rsize_R(Ab_free);
 while(r>R1) 
 zero_below_pivot_gj1Ab_mR(Ab_free,r--);
 clrscrn();
 c_Ab_b_mR(Ab_free,b_free);
 printf(" b_free :"); 
 p_mR(b_free,S10,P3,C7);
 c_c_mR(b_free,C_FREE,cFree,C1);
 printf(" %.2f * C%d :",S_VALUE,C_FREE); 
 p_mR(smul_mR(S_VALUE,cFree,s_cFree),S10,P3,C7);
 printf(" A * (%.2f*C%d) :",S_VALUE,C_FREE); 
 p_mR(mul_mR(A,s_cFree,A_s_cFree),S10,P3,C7);
 stop(); 
 f_mR(Ab);
 f_mR(Ab_free);
 f_mR(b_free);
 f_mR(b);
 f_mR(A);
 f_mR(cFree); 
 f_mR(s_cFree);
 f_mR(A_s_cFree);
 return 0;
/* ------------------------------------ */
J'ai éliminé tous les affichages intermédiaire. On peut sélectionner la colonne de travail et la valeur du scalaire dans le code ci-dessous.

Exemple de sortie écran :
 Verify if the scalar multiplication of a column of b_free
 is orthogonal to A :
 A :
 +1.0 +3.0 -2.0 +0.0 +2.0 +0.0 
 +2.0 +6.0 -5.0 -2.0 +4.0 -3.0 
 +0.0 +0.0 +5.0 +10.0 +0.0 +15.0 
 +2.0 +6.0 +0.0 +8.0 +4.0 +18.0 
 b :
 +0.0 
 +0.0 
 +0.0 
 +0.0 
 Ab :
 +1.0 +3.0 -2.0 +0.0 +2.0 +0.0 +0.0 
 +2.0 +6.0 -5.0 -2.0 +4.0 -3.0 +0.0 
 +0.0 +0.0 +5.0 +10.0 +0.0 +15.0 +0.0 
 +2.0 +6.0 +0.0 +8.0 +4.0 +18.0 +0.0 
 Press return to continue. 
 ------------------------------------ 
 b_free :
 +0.000 -3.000 -4.000 -2.000 
 +0.000 +1.000 +0.000 +0.000 
 +0.000 +0.000 -2.000 +0.000 
 +0.000 +0.000 +1.000 +0.000 
 +0.000 +0.000 +0.000 +1.000 
 +0.000 +0.000 +0.000 +0.000 
 4.00 * C3 :
 -16.000 
 +0.000 
 -8.000 
 +4.000 
 +0.000 
 +0.000 
 A * (4.00*C3) :
 +0.000 
 +0.000 
 +0.000 
 +0.000 
 Press return to continue.

Mathc matrices/c23t
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : c03a.c */
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
double a[RA*(CA)]={
 -2, -3,
 1, 0,
 0, 1
double x[RA*C1]={
 -1, 
 2, 
 -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",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 R3 
 Find a transformation matrix for 
 a projection onto R3 : 
 Proj(x) = A * inv(AT*A) * AT * x 
 A :
 -2.0 -3.0 
 +1.0 +0.0 
 +0.0 +1.0 
 Press return to continue. 
 AT :
 -2.0 +1.0 +0.0 
 -3.0 +0.0 +1.0 
 ATA :
 +5.0 +6.0 
 +6.0 +10.0 
 inv(AT*A) :
+0.7143 -0.4286 
-0.4286 +0.3571 
 inv(AT*A)*AT :
-0.1429 +0.7143 -0.4286 
-0.2143 -0.4286 +0.3571 
 V = A*inv(AT*A)*AT :
+0.9286 -0.1429 -0.2143 
-0.1429 +0.7143 -0.4286 
-0.2143 -0.4286 +0.3571 
 Press return to continue. 
 V is transformation matrix for 
 a projection onto a subspace R3 :
+0.9286 -0.1429 -0.2143 
-0.1429 +0.7143 -0.4286 
-0.2143 -0.4286 +0.3571 
 X :
 -1.0 
 +2.0 
 -3.0 
 Proj(x) = A * inv(AT*A) * AT * x 
 Proj(x) = V * x :
-0.5714 
+2.8571 
-1.7143 
 Press return to continue.