Mathc matrices/c23z

Un livre de Wikilivres.


Application


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


c04c.c
/* ------------------------------------ */
/*  Save as :   c04c.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define    RA R2
#define    CA C4
#define CFREE C1+C2  // C1 -> b
/* ------------------------------------ */
int main(void)
{
double a_Tb[RA*(CA+C1)]={
  2,0,0,4,0,
  0,3,0,5,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));

double **A_Tb_free = i_Abr_Ac_bc_mR(csize_A_R(A_Tb),csize_A_R(A_Tb),CFREE);

double **B  = i_mR(rsize_R(A_Tb_free),csize_b_R(A_Tb_free)); 

int r;

  clrscrn();
  printf("Find a basis for the orthogonal complement of A :\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(" A_Tb :  gj_PP_mR(A_Tb,NO) :");
  gj_PP_mR(A_Tb,NO);
  p_mR(A_Tb,S7,P3,C10);
  
  put_zeroR_mR(A_Tb,A_Tb_free);  
  put_freeV_mR(A_Tb_free);
  
  r = rsize_R(A_Tb_free);
  while(r>R1)    
        zero_below_pivot_gj1Ab_mR(A_Tb_free,r--);
  stop();
  
  clrscrn();          
  printf(" A_Tb_free :");  
  p_mR(A_Tb_free,S7,P3,C10);  
  
  printf(" B is a basis for the orthogonal complement of A :"); 
  P_mR(c_Ab_b_mR(A_Tb_free,B),S10,P12,C7);
  stop();	
  
  f_mR(A_Tb);
  f_mR(A_Tb_free);
  f_mR(B);
  f_mR(b);
  f_mR(A_T);
  
  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 R4.
          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 A :

 A_T :
  +2.0   +0.0   +0.0   +4.0 
  +0.0   +3.0   +0.0   +5.0 

 b :
  +0.0 
  +0.0 

 A_Tb :
  +2.0   +0.0   +0.0   +4.0   +0.0 
  +0.0   +3.0   +0.0   +5.0   +0.0 

 Press return to continue. 


 ------------------------------------ 
 A_Tb :  gj_PP_mR(A_Tb,NO) :
 +1.000  +0.000  +0.000  +2.000  +0.000 
 +0.000  +1.000  +0.000  +1.667  +0.000 

 Press return to continue. 


 ------------------------------------ 
 A_Tb_free :
 +1.000  +0.000  +0.000  +0.000  +0.000  +0.000  -2.000 
 +0.000  +1.000  +0.000  +0.000  +0.000  +0.000  -1.667 
 +0.000  +0.000  +1.000  +0.000  +0.000  +1.000  +0.000 
 +0.000  +0.000  +0.000  +1.000  +0.000  +0.000  +1.000 

 B is a basis for the orthogonal complement of A :
+0.000000000000, +0.000000000000, -2.000000000000, 
+0.000000000000, +0.000000000000, -1.666666666667, 
+0.000000000000, +1.000000000000, +0.000000000000, 
+0.000000000000, +0.000000000000, +1.000000000000  

 Press return to continue.