Aller au contenu

Mathc complexes/a254

Un livre de Wikilivres.


Application


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


c05a.c
/* ------------------------------------ */
/*  Save as :   c05a.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   RA R5
#define   CA C2
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double a[RA*(CA*C2)]={
 -2,-3, -4,-2,
  1, 0, -3,-5,
  0, 1, -6,-4,
  3, 5, -1,-0, 
  5, 4, -3,-2 
};

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

double **A           = ca_A_mZ(a,i_mZ(RA,CA));
double **AT          = i_mZ(CA,RA);
double **ATA         = i_mZ(CA,CA); //         AT*A
double **invATA      = i_mZ(CA,CA); //     inv(AT*A)
double **invATA_AT   = i_mZ(CA,RA); //     inv(AT*A)*AT
double **V           = i_mZ(RA,RA); //     inv(AT*A)*AT

double **X           = ca_A_mZ(x,i_mZ(RA,C1));
double **VX          = i_mZ(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_mZ(A,S5,P1,S5,P1,C7);
  stop();
  
  clrscrn();
  printf(" AT :");
  p_mZ(ctranspose_mZ(A,AT),S5,P1,S5,P1,C7);
  printf(" ATA :");
  p_mZ(mul_mZ(AT,A,ATA),S5,P1,S5,P1,C7);
  printf(" inv(AT*A) :");
  p_mZ(invgj_mZ(ATA,invATA),S5,P4,S5,P4,C7);  
  printf(" inv(AT*A)*AT :");
  p_mZ(mul_mZ(invATA,AT,invATA_AT),S5,P4,S5,P4,C7); 
  printf(" V = A*inv(AT*A)*AT :");
  p_mZ(mul_mZ(A,invATA_AT,V),S5,P4,S5,P4,C7);    
  stop();  
  
  clrscrn();
  printf(" V is transformation matrix for      \n"
         " a projection onto a subspace R%d :\n\n",RA);
  p_mZ(V,S5,P4,S5,P4,C7); 
  
  printf(" X :");
  p_mZ(X,S5,P1,S5,P1,C7);
  
  printf(" Proj(x) =  A * inv(AT*A) * AT * x \n\n"); 
  printf(" Proj(x) =  V                  * x :");  
  p_mZ(mul_mZ(V,X,VX),S5,P4,S5,P4,C7); 
  stop();    
  
  
  f_mZ(A);
  f_mZ(AT);
  f_mZ(ATA);       //         AT*A
  f_mZ(invATA);    //     inv(AT*A)
  f_mZ(invATA_AT); //     inv(AT*A)*AT
  f_mZ(V);         //   A*inv(AT*A)*AT  
  
  f_mZ(X); 
  f_mZ(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 R5              

 Find a transformation matrix for    
 a projection onto R5  :          

 Proj(x) =  A * inv(AT*A) * AT * x 

 A :
 -2.0 -3.0i  -4.0 -2.0i 
 +1.0 +0.0i  -3.0 -5.0i 
 +0.0 +1.0i  -6.0 -4.0i 
 +3.0 +5.0i  -1.0 +0.0i 
 +5.0 +4.0i  -3.0 -2.0i 

 Press return to continue. 


 ------------------------------------ 
 AT :
 -2.0 +3.0i  +1.0 -0.0i  +0.0 -1.0i  +3.0 -5.0i  +5.0 -4.0i 
 -4.0 +2.0i  -3.0 +5.0i  -6.0 +4.0i  -1.0 -0.0i  -3.0 +2.0i 

 ATA :
+90.0 +0.0i -19.0 +0.0i 
-19.0 +0.0i +120.0 +0.0i 

 inv(AT*A) :
+0.0115+0.0000i +0.0018+0.0000i 
+0.0018+0.0000i +0.0086+0.0000i 

 inv(AT*A)*AT :
-0.0303+0.0381i +0.0060+0.0091i -0.0109-0.0042i +0.0327-0.0575i +0.0520-0.0423i 
-0.0381+0.0227i -0.0240+0.0431i -0.0517+0.0327i -0.0032-0.0091i -0.0168+0.0100i 

 V = A*inv(AT*A)*AT :
+0.3728+0.0000i +0.1976-0.1606i +0.2814+0.0140i -0.2433+0.0597i -0.1441-0.0777i 
+0.1976+0.1606i +0.2937+0.0000i +0.3076+0.1564i -0.0034-0.0144i +0.1521+0.0116i 
+0.2814-0.0140i +0.3076-0.1564i +0.4453+0.0000i +0.0400+0.0999i +0.1828+0.0593i 
-0.2433-0.0597i -0.0034+0.0144i +0.0400-0.0999i +0.3885-0.0000i +0.3845+0.1231i 
-0.1441+0.0777i +0.1521-0.0116i +0.1828-0.0593i +0.3845-0.1231i +0.4997-0.0000i 

 Press return to continue. 


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


+0.3728+0.0000i +0.1976-0.1606i +0.2814+0.0140i -0.2433+0.0597i -0.1441-0.0777i 
+0.1976+0.1606i +0.2937+0.0000i +0.3076+0.1564i -0.0034-0.0144i +0.1521+0.0116i 
+0.2814-0.0140i +0.3076-0.1564i +0.4453+0.0000i +0.0400+0.0999i +0.1828+0.0593i 
-0.2433-0.0597i -0.0034+0.0144i +0.0400-0.0999i +0.3885-0.0000i +0.3845+0.1231i 
-0.1441+0.0777i +0.1521-0.0116i +0.1828-0.0593i +0.3845-0.1231i +0.4997-0.0000i 

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

 Proj(x) =  A * inv(AT*A) * AT * x 

 Proj(x) =  V                  * x :
-0.9768-2.6649i 
+0.4362-4.3941i 
-1.6976-5.4468i 
-1.2929-1.2455i 
-1.8398-3.1581i 

 Press return to continue.