Aller au contenu

Mathc complexes/a88

Un livre de Wikilivres.


X Value Decomposition

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


c03b.c
/* ------------------------------------ */
/*  Xave as :   c03b.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define RA              R3
#define CA              C2
#define FACTOR_E        +1.E-2   
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
int r = RA;
int c = CA;  

double a[RA*(CA*C2)] ={ 1,2,  3,4,  
                        5,4,  1,3,
                        7,2,  5,1};

double **A =        ca_A_mZ(a, i_mZ(r,c)); 	
                       
double **A_T = ctranspose_mZ(A,i_mZ(c,r));
double **V =                   i_mZ(r,c);
double **V_T =                 i_mZ(c,r);
double **U =                   i_mZ(r,c);
double **U_T =                 i_mZ(c,r); //             :c,r 
double **U_TA =                i_mZ(c,c); // c,r r,c     :c,c
double **U_TAr =               i_mZ(c,r); // c,r         :c,r 
double **X =                   i_mZ(c,c); // c,r r,c     :c,c   U_TUX

double **Ar  =                 i_mZ(r,r); //  A = U * X * V_T 
double **UX =                 i_mZ(r,c);

  clrscrn();
  printf(" A :");
  p_mZ(A, S10,P2, S8,P2, C3);
      
  printf(" U :");
  X_U_mZ(A_T,U,FACTOR_E);
    p_mZ(U, S10,P4, S8,P4, C3);

  printf(" V :");
  X_V_mZ(A_T,V,FACTOR_E);
    p_mZ(V, S10,P4, S8,P4, C3);
  
  ctranspose_mZ(U,U_T);
  ctranspose_mZ(V,V_T);  

   stop();
   
   clrscrn();
      
  printf(" X = U_T * A * V :");
  mul_mZ(U_T, A, U_TA);           // U_TA  : c,c
    c_mZ(U_TA, U_TAr);            // U_TAr : c,r 
  mul_mZ(U_TAr, V, X);            //     V : r,c   
    p_mZ(X, S10,P4, S8,P4, C3);
   
   printf(" A :");
   p_mZ(A, S5,P0, S4,P0, C3); 
     
   printf(" Ar = U * X * V_T  ");
   mul_mZ(U, X, UX);                    
   mul_mZ(UX, V_T, Ar);                 
     p_mZ(Ar, S5,P0, S4,P0, C6);
     
  stop();  

   f_mZ(A);
   f_mZ(A_T);
   f_mZ(V);
   f_mZ(V_T);
   f_mZ(U);
   f_mZ(U_T);
   f_mZ(U_TA);
   f_mZ(U_TAr);
   f_mZ(X);
   f_mZ(UX);
   f_mZ(Ar);

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


 Diagonaliser une matrice avec un nombre de lignes supérieur ou égal aux nombres de colonnes


Exemple de sortie écran :
 A :
     +1.00   +2.00i      +3.00   +4.00i 
     +5.00   +4.00i      +1.00   +3.00i 
     +7.00   +2.00i      +5.00   +1.00i 

 U :
   +0.2940 +0.2567i    -0.6119 +0.4960i 
   +0.4702 +0.3112i    +0.1304 -0.5579i 
   +0.7278 +0.0000i    +0.2265 -0.0000i 

 V :
   +0.7964 +0.0735i    -0.5977 -0.0552i 
   +0.6002 -0.0000i    +0.7998 +0.0000i 
   +0.0000 +0.0000i    +0.0000 +0.0000i 

 Press return to continue. 


 X = U_T * A * V :
  +11.5820 +3.7205i    +0.0000 -0.0000i 
   -0.0000 +0.0000i    -0.3277 -3.4507i 

 A :
   +1  +2i    +3  +4i 
   +5  +4i    +1  +3i 
   +7  +2i    +5  +1i 

 Ar = U * X * V_T  
   +1  +2i    +3  +4i    +0  +0i 
   +5  +4i    +1  +3i    +0  +0i 
   +7  +2i    +5  +1i    +0  +0i 

 Press return to continue.