Application


Installer et compiler ces fichiers dans votre répertoire de travail.


c04a.c
/* ------------------------------------ */
/*  Save as :   c04a.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   RA R4
#define   CA C2
/* ------------------------------------ */
/* ------------------------------------ */
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 :

  • A est un sous espace de R4. Trouver une matrice V qui projette un vecteur x sur R4.
          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.