Aller au contenu

Mathc matrices/c23v

Un livre de Wikilivres.


Application


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


c03c.c
/* ------------------------------------ */
/*  Save as :   c03c.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define       RAT R2
#define       CAT C3
#define       Cb C1
/* ------------------------------------ */
#define CFREE Cb+C1   
/* ------------------------------------ */
int main(void)
{
double a_Tb[RAT*(CAT+Cb)]={
 -2,1,0,0,
 -3,0,1,0
};

double **ATb = ca_A_mR(a_Tb,  i_Abr_Ac_bc_mR(RAT,CAT,Cb));
double **AT  = c_Ab_A_mR(ATb, i_mR(RAT,CAT));
double **b   = c_Ab_b_mR(ATb, i_mR(RAT,Cb));

double **ATb_free =           i_Abr_Ac_bc_mR(CAT,CAT,CFREE);

double **B   =                i_mR(CAT,CFREE); 
double **ATB =                i_mR(RAT,CFREE); 

int r;

  clrscrn();
  printf("Find a basis for the orthogonal complement of AT :\n\n");
  printf(" AT :");
  p_mR(AT,S6,P1,C10);
  printf(" b :");
  p_mR(b,S6,P1,C10);
  printf(" ATb :");
  p_mR(ATb,S6,P1,C10);
  stop();

  clrscrn();
  printf(" ATb :  gj_PP_mR(ATb,NO) :");
  gj_PP_mR(ATb,NO);
  p_mR(ATb,S7,P3,C10);
  
  put_zeroR_mR(ATb,ATb_free);  
  put_freeV_mR(ATb_free);
  
  r = rsize_R(ATb_free);
  while(r>R1)    
        zero_below_pivot_gj1Ab_mR(ATb_free,r--);
         
  printf(" ATb_free :");  
  p_mR(ATb_free,S7,P3,C10);  
  
  printf(" B is a basis for the orthogonal complement of AT :"); 
  P_mR(c_Ab_b_mR(ATb_free,B),S10,P12,C7);
  stop();	
  
  clrscrn();
  printf(" AT :");
  p_mR(AT, S7,P3,C10); 
  printf(" B :"); 
  p_mR(B, S7,P3,C10); 
  printf(" AT * B :"); 
  p_mR(mul_mR(AT,B,ATB), S7,P6,C10); 
  stop();  
  
  f_mR(ATb);
  f_mR(AT);
  f_mR(b);
  
  f_mR(ATb_free);
  
  f_mR(B);
  f_mR(ATB);
    
  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 AT. Trouver une matrice V qui projette un vecteur x sur R3.
          Proj(x) =  V * x
                V =  Id - (B * inv(BT*B) * BT)  .
                
  • Dans cet exemple nous calculons B. Nous l'utiliserons dans le prochain exemple.


Exemple de sortie écran :
Find a basis for the orthogonal complement of AT :

 AT :
  -2.0   +1.0   +0.0 
  -3.0   +0.0   +1.0 

 b :
  +0.0 
  +0.0 

 ATb :
  -2.0   +1.0   +0.0   +0.0 
  -3.0   +0.0   +1.0   +0.0 

 Press return to continue. 


 ATb :  gj_PP_mR(ATb,NO) :
 +1.000  -0.000  -0.333  -0.000 
 +0.000  +1.000  -0.667  +0.000 

 ATb_free :
 +1.000  +0.000  +0.000  +0.000  +0.333 
 +0.000  +1.000  +0.000  +0.000  +0.667 
 +0.000  +0.000  +1.000  +0.000  +1.000 

 B is a basis for the orthogonal complement of AT :
+0.000000000000, +0.333333333333, 
+0.000000000000, +0.666666666667, 
+0.000000000000, +1.000000000000  

 Press return to continue. 


 AT :
 -2.000  +1.000  +0.000 
 -3.000  +0.000  +1.000 

 B :
 +0.000  +0.333 
 +0.000  +0.667 
 +0.000  +1.000 

 AT * B :
+0.000000 +0.000000 
+0.000000 +0.000000 

 Press return to continue.