Application


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


c05d.c
/* ------------------------------------ */
/*  Save as :   c05d.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   RB R5
#define   CB C3
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double b[RB*(CB)]={
 +0.000000000000, -2.000000000000, -0.500000000000, 
 +0.000000000000, -1.666666666667, +0.000000000000, 
 +1.000000000000, +0.000000000000, +0.000000000000, 
 +0.000000000000, +1.000000000000, +0.000000000000, 
 +0.000000000000, +0.000000000000, +1.000000000000 
};

double x[RB*(C1)]={
 -1, 
  2, 
 -3,
 -3,
 -1,
};

double **B           = ca_A_mR(b,i_mR(RB,CB));
double **BT          = i_mR(CB,RB);
double **BTB         = i_mR(CB,CB); //         BT*B
double **invBTB      = i_mR(CB,CB); //     inv(BT*B)
double **invBTB_BT   = i_mR(CB,RB); //     inv(BT*B)*BT
double **B_invBTB_BT = i_mR(RB,RB); //     B_inv(BT*B)*BT

double **Id          = eye_mR(i_mR(RB,RB));
double **V           = i_mR(RB,RB); //     V = Id - (B_inv(BT*B)*BT)

double **X           = ca_A_mR(x,     i_mR(RB,C1));
double **X_T         = transpose_mR(X,i_mR(C1,RB));
double **VX          =                i_mR(RB,C1);

  clrscrn();
  printf(" B is a basis for the orthogonal complement of A : \n\n"
         " Find a transformation matrix for    \n"
         " a projection onto R%d  :          \n\n"
         " Proj(x) = [Id-(B*inv(BT*B)*BT)] * x \n\n",RB);
  printf(" B :");
  p_mR(B,S5,P4,C7);
  stop();
  
  clrscrn();
  printf(" BT :");
  p_mR(transpose_mR(B,BT),S5,P4,C7);
  printf(" BTB :");
  p_mR(mul_mR(BT,B,BTB),S5,P4,C7);
  
  printf(" inv(BT*B) :");
  p_mR(inv_mR(BTB,invBTB),S5,P4,C7);   
  stop();
  
  clrscrn();  
  printf(" inv(BT*B)*BT :");
  p_mR(mul_mR(invBTB,BT,invBTB_BT),S5,P4,C7); 
  printf(" B*inv(BT*B)*BT :");
  p_mR(mul_mR(B,invBTB_BT,B_invBTB_BT),S5,P4,C7);  
  printf(" V = Id - (B*inv(BT*B)*BT) :");
  p_mR(sub_mR(Id,B_invBTB_BT,V),S5,P4,C7);    
  stop();  
  
  clrscrn();
  printf(" V is transformation matrix for     \n"
         " a projection onto a subspace R%d :\n\n",RB);
  p_mR(V,S5,P4,C7); 
  
  printf(" X_T :");
  p_mR(X_T,S5,P4,C7);
  
  printf(" Proj(x) = [Id-(B*inv(BT*B)*BT)] * x \n\n"); 
  printf(" Proj(x) =  V                    * x :");  
  p_mR(mul_mR(V,X,VX),S5,P4,C7); 
  stop();    
  
  f_mR(B);
  f_mR(BT);
  f_mR(BTB);       //         BT*B
  f_mR(invBTB);    //     inv(BT*B)
  f_mR(invBTB_BT); //     inv(BT*B)*BT
  f_mR(V);         //   B*inv(BT*B)*BT  
  
  f_mR(X); 
  f_mR(VX);         
 
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Trouver une projection sur un sous-espace vectoriel par une application linéaire :


  • B est une base pour le complément orthogonal de A. Trouver une matrice V qui projette un vecteur x sur R5.
          Proj(x) =  V * x
                V =  Id - (B * inv(BT*B) * BT)  .
                


Exemple de sortie écran :
 ------------------------------------ 
 B is a basis for the orthogonal complement of A : 

 Find a transformation matrix for    
 a projection onto R5  :          

 Proj(x) = [Id-(B*inv(BT*B)*BT)] * x 

 B :
+0.0000 -2.0000 -0.5000 
+0.0000 -1.6667 +0.0000 
+1.0000 +0.0000 +0.0000 
+0.0000 +1.0000 +0.0000 
+0.0000 +0.0000 +1.0000 

 Press return to continue. 

 ------------------------------------ 
 BT :
+0.0000 +0.0000 +1.0000 +0.0000 +0.0000 
-2.0000 -1.6667 +0.0000 +1.0000 +0.0000 
-0.5000 +0.0000 +0.0000 +0.0000 +1.0000 

 BTB :
+1.0000 +0.0000 +0.0000 
+0.0000 +7.7778 +1.0000 
+0.0000 +1.0000 +1.2500 

 inv(BT*B) :
+1.0000 -0.0000 -0.0000 
-0.0000 +0.1433 -0.1146 
-0.0000 -0.1146 +0.8917 

 Press return to continue. 

 ------------------------------------ 
 inv(BT*B)*BT :
+0.0000 +0.0000 +1.0000 +0.0000 +0.0000 
-0.2293 -0.2389 +0.0000 +0.1433 -0.1146 
-0.2166 +0.1911 +0.0000 -0.1146 +0.8917 

 B*inv(BT*B)*BT :
+0.5669 +0.3822 +0.0000 -0.2293 -0.2166 
+0.3822 +0.3981 +0.0000 -0.2389 +0.1911 
+0.0000 +0.0000 +1.0000 +0.0000 +0.0000 
-0.2293 -0.2389 +0.0000 +0.1433 -0.1146 
-0.2166 +0.1911 +0.0000 -0.1146 +0.8917 

 V = Id - (B*inv(BT*B)*BT) :
+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 

 X_T :
-1.0000 +2.0000 -3.0000 -3.0000 -1.0000 

 Proj(x) = [Id-(B*inv(BT*B)*BT)] * x 

 Proj(x) =  V                    * x :
-2.1019 
+1.0605 
+0.0000 
-2.4363 
-1.0510 

 Press return to continue.