Aller au contenu

Mathc complexes/019

Un livre de Wikilivres.

Application

Installer et compiler ce fichier dans votre répertoire de travail.

c00a.c
/* ------------------------------------ */
/*  save as :   c00a.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define FACTOR_E        +1.E-2   
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r)
{
double **A =       rupper_mZ(  i_mZ(r,r),99);	
double **A_T = ctranspose_mZ(A,i_mZ(r,r));
double **V =                   i_mZ(r,r);
double **V_T =                 i_mZ(r,r);
double **U =                   i_mZ(r,r);
double **U_T =                 i_mZ(r,r);    
double **X =                   i_mZ(r,r);  

double **T =                   i_mZ(r,r);

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

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

   stop();
   
   clrscrn();
      
  printf(" X = U_T * A * V :");
  mul_mZ(U_T, A, T);           
  mul_mZ(T, V, X);              
    p_mZ(X, S10,P3, S8,P3, C4);
   
   printf(" A :");
   p_mZ(A, S10,P2, S8,P2, C4);
     
   printf(" A = U * X * V_T  ");
   mul_mZ(U, X, T);                    
   mul_mZ(T, V_T, A);                 
     p_mZ(A, S10,P2, S8,P2, C4); 

   f_mZ(A);
   f_mZ(A_T);
   f_mZ(V);
   f_mZ(V_T);
   f_mZ(U);
   f_mZ(U_T);
   f_mZ(X);
   f_mZ(T);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
 fun(rp_I(R3)+R1);
    
} while(stop_w());

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


La X décomposition d'une matrice triangulaire supérieur'


Exemple de sortie écran :

 A :
    +46.00  +87.00i     +47.00  +73.00i     +79.00  -46.00i     -66.00  -89.00i 
     +0.00   +0.00i     -23.00  -58.00i     -98.00  -37.00i     +81.00   -5.00i 
     +0.00   +0.00i      +0.00   +0.00i     -57.00  -82.00i     +68.00  +51.00i 
     +0.00   +0.00i      +0.00   +0.00i      +0.00   +0.00i     +49.00  -56.00i 

 U :
    -0.176  -0.679i     +0.659  -0.056i     -0.147  +0.046i     -0.121  +0.179i 
    +0.144  +0.507i     +0.430  -0.162i     +0.042  -0.512i     -0.282  +0.408i 
    -0.138  +0.415i     +0.442  +0.235i     -0.538  +0.147i     +0.335  -0.367i 
    +0.195  +0.000i     +0.317  +0.000i     +0.633  +0.000i     +0.678  +0.000i 

 V :
    -0.231  +0.164i     -0.203  -0.420i     +0.190  +0.241i     +0.760  +0.176i 
    -0.314  +0.219i     +0.006  -0.246i     +0.751  -0.022i     -0.473  +0.064i 
    -0.549  -0.253i     +0.312  +0.520i     +0.204  -0.352i     +0.320  -0.002i 
    +0.639  +0.000i     +0.595  +0.000i     +0.419  +0.000i     +0.248  +0.000i 

 Press return to continue. 


 X = U_T * A * V :
  +160.469-183.394i     -0.000  +0.000i     -0.000  +0.000i     -0.000  -0.000i 
    +0.000  +0.000i    +91.938-105.072i     +0.000  +0.000i     +0.000  -0.000i 
    +0.000  -0.000i     +0.000  -0.000i    +32.435 -37.069i     -0.000  +0.000i 
    -0.000  +0.000i     -0.000  +0.000i     +0.000  -0.000i    +17.930 -20.491i 

 A :
    +46.00  +87.00i     +47.00  +73.00i     +79.00  -46.00i     -66.00  -89.00i 
     +0.00   +0.00i     -23.00  -58.00i     -98.00  -37.00i     +81.00   -5.00i 
     +0.00   +0.00i      +0.00   +0.00i     -57.00  -82.00i     +68.00  +51.00i 
     +0.00   +0.00i      +0.00   +0.00i      +0.00   +0.00i     +49.00  -56.00i 

 A = U * X * V_T  
    +46.00  +87.00i     +47.00  +73.00i     +79.00  -46.00i     -66.00  -89.00i 
     +0.00   -0.00i     -23.00  -58.00i     -98.00  -37.00i     +81.00   -5.00i 
     +0.00   -0.00i      +0.00   +0.00i     -57.00  -82.00i     +68.00  +51.00i 
     +0.00   +0.00i      -0.00   +0.00i      -0.00   -0.00i     +49.00  -56.00i 


 Press   return to continue
 Press X return to stop