Mathc complexes/a249

Un livre de Wikilivres.


Application


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


c03d.c
/* ------------------------------------ */
/*  Save as :   c03d.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define    RB R3
#define    CB C1
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double b[RB*(CB*C2)]={
  +0.072961373391,-0.506437768240, 
  -1.373390557940,-0.231759656652,
             +1.0,+0.0
};

double x[RB*(CB*C2)]={
 -1,-3, 
  2,-4, 
 -3,-5,
};

nb_Z a;

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

double **Id          = eye_mZ(i_mZ(RB,RB));
double **V           = i_mZ(RB,RB); //     V = Id - (B_inv(BT*B)*BT)

double **X           = ca_A_mZ(x,i_mZ(RB,C1));
double **VX          =           i_mZ(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_mZ(B,S5,P4,S5,P4,C7);
  stop();
  
  clrscrn();
  printf(" BT :");
  p_mZ(ctranspose_mZ(B,BT),S5,P4,S5,P4,C7);
  printf(" BTB :");
  p_mZ(mul_mZ(BT,B,BTB),S5,P4,S5,P4,C7);
  
  printf(" inv(BT*B) :");
  
  a = i_Z(BTB[R1][C1],BTB[R1][C2]);
   
  invBTB[R1][C1] = inv_Z(a).r;
  invBTB[R1][C2] = inv_Z(a).i;
  
  p_mZ(invBTB,S5,P4,S5,P4,C7);  
  
  printf(" inv(BT*B)*BT :");
  p_mZ(mul_mZ(invBTB,BT,invBTB_BT),S5,P4,S5,P4,C7); 
  printf(" B*inv(BT*B)*BT :");
  p_mZ(mul_mZ(B,invBTB_BT,B_invBTB_BT),S5,P4,S5,P4,C7);  
  printf(" V = Id - (B*inv(BT*B)*BT) :");
  p_mZ(sub_mZ(Id,B_invBTB_BT,V),S5,P4,S5,P4,C7);    
  stop();  
  
  clrscrn();
  printf(" V is transformation matrix for     \n"
         " a projection onto a subspace R%d :\n\n",RB);
  p_mZ(V,S5,P4,S5,P4,C7); 
  
  printf(" X :");
  p_mZ(X,S5,P1,S5,P1,C7);
  
  printf(" Proj(x) = [Id-(B*inv(BT*B)*BT)] * x \n\n"); 
  printf(" Proj(x) =  V                    * x :");  
  p_mZ(mul_mZ(V,X,VX),S5,P4,S5,P4,C7); 
  stop();    
  
  
  f_mZ(B);
  f_mZ(BT);
  f_mZ(BTB);       //         BT*B
  f_mZ(invBTB);    //     inv(BT*B)
  f_mZ(invBTB_BT); //     inv(BT*B)*BT
  f_mZ(V);         //   B*inv(BT*B)*BT  
  
  f_mZ(X); 
  f_mZ(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 R3.
          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 R3  :          

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

 B :
+0.0730-0.5064i 
-1.3734-0.2318i 
+1.0000+0.0000i 

 Press return to continue. 


 ------------------------------------ 
 BT :
+0.0730+0.5064i -1.3734+0.2318i +1.0000-0.0000i 

 BTB :
+3.2017+0.0000i 

 inv(BT*B) :
+0.3123-0.0000i 

 inv(BT*B)*BT :
+0.0228+0.1582i -0.4290+0.0724i +0.3123+0.0000i 

 B*inv(BT*B)*BT :
+0.0818+0.0000i +0.0054+0.2225i +0.0228-0.1582i 
+0.0054-0.2225i +0.6059+0.0000i -0.4290-0.0724i 
+0.0228+0.1582i -0.4290+0.0724i +0.3123+0.0000i 

 V = Id - (B*inv(BT*B)*BT) :
+0.9182+0.0000i -0.0054-0.2225i -0.0228+0.1582i 
-0.0054+0.2225i +0.3941+0.0000i +0.4290+0.0724i 
-0.0228-0.1582i +0.4290-0.0724i +0.6877+0.0000i 

 Press return to continue. 


 ------------------------------------ 
 V is transformation matrix for     
 a projection onto a subspace R3 :


+0.9182+0.0000i -0.0054-0.2225i -0.0228+0.1582i 
-0.0054+0.2225i +0.3941+0.0000i +0.4290+0.0724i 
-0.0228-0.1582i +0.4290-0.0724i +0.6877+0.0000i 

 X :
 -1.0 -3.0i 
 +2.0 -4.0i 
 -3.0 -5.0i 

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

 Proj(x) =  V                    * x :
-0.9598-3.5389i 
+0.5362-4.1448i 
-1.9464-5.0724i 

 Press return to continue.