Aller au contenu

Mathc complexes/a65

Un livre de Wikilivres.


X Value Decomposition

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


c02b.c
/* ------------------------------------ */
/*  Xave as :   c02b.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define FACTOR_E        +1.E-2   
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r,int c)
{
double **A =              r_mZ(i_mZ(r,c),99);	
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);  

   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);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
    fun(R5,C3);
    
} while(stop_w());

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


Exemple de sortie écran :
 A :
    +55.00  +44.00i     -79.00  +72.00i      +7.00   -4.00i 
    +40.00  +35.00i     -99.00   -6.00i     -52.00  +89.00i 
    -57.00  -16.00i     -43.00  +80.00i     +72.00  -15.00i 
     -5.00  -18.00i     -61.00  +79.00i     -38.00  -97.00i 
    -16.00  +90.00i     +69.00  -25.00i     +23.00  -65.00i 

 U :
   -0.3486 +0.0910i    +0.1798 -0.4364i    +0.4633 -0.0555i 
   -0.4680 -0.3536i    -0.1614 -0.2021i    +0.3023 +0.3440i 
   -0.2084 +0.4500i    +0.2943 +0.0888i    -0.0657 +0.2885i 
   -0.0832 +0.2352i    +0.3203 -0.6368i    -0.4657 +0.0252i 
   +0.4669 +0.0000i    +0.3282 -0.0000i    +0.5172 +0.0000i 

 V :
   -0.1204 +0.2936i    -0.3871 +0.0050i    +0.8024 -0.3250i 
   -0.0872 -0.8171i    -0.0839 +0.5101i    +0.2398 -0.0061i 
   +0.4733 +0.0000i    +0.7635 +0.0000i    +0.4394 -0.0000i 
   +0.0000 +0.0000i    +0.0000 +0.0000i    +0.0000 +0.0000i 
   +0.0000 +0.0000i    +0.0000 +0.0000i    +0.0000 +0.0000i 

 Press return to continue. 


 X = U_T * A * V :
  -85.8035-215.2608i    +0.0000 +0.0000i    -0.0000 -0.0000i 
   -0.0000 -0.0000i   +92.2239-144.0077i    +0.0000 -0.0000i 
   -0.0000 -0.0000i    +0.0000 +0.0000i   +82.9719+82.0594i 

 A :
  +55 +44i   -79 +72i    +7  -4i 
  +40 +35i   -99  -6i   -52 +89i 
  -57 -16i   -43 +80i   +72 -15i 
   -5 -18i   -61 +79i   -38 -97i 
  -16 +90i   +69 -25i   +23 -65i 

 Ar = U * X * V_T  
  +55 +44i   -79 +72i    +7  -4i    +0  +0i    +0  +0i 
  +40 +35i   -99  -6i   -52 +89i    +0  +0i    +0  +0i 
  -57 -16i   -43 +80i   +72 -15i    +0  +0i    +0  +0i 
   -5 -18i   -61 +79i   -38 -97i    +0  +0i    +0  +0i 
  -16 +90i   +69 -25i   +23 -65i    +0  +0i    +0  +0i 


 Press   return to continue
 Press X return to stop