Aller au contenu

Mathc complexes/018

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 =       rlower_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 inférieur


Exemple de sortie écran :

 A :
    -68.00   -8.00i      +0.00   +0.00i      +0.00   +0.00i      +0.00   +0.00i 
    +88.00  -39.00i     +82.00  +31.00i      +0.00   +0.00i      +0.00   +0.00i 
    -89.00  -58.00i     -68.00  -77.00i     +81.00  -53.00i      +0.00   +0.00i 
    +59.00  +81.00i     -68.00  +52.00i     +80.00  +36.00i     +88.00  -36.00i 

 U :
    -0.100  +0.190i     -0.081  -0.062i     +0.628  -0.614i     -0.168  +0.380i 
    -0.039  -0.523i     -0.034  +0.085i     -0.004  +0.259i     +0.212  +0.777i 
    -0.382  +0.436i     +0.437  -0.498i     -0.283  +0.140i     -0.120  +0.333i 
    +0.585  +0.000i     +0.736  +0.000i     +0.250  +0.000i     +0.230  +0.000i 

 V :
    -0.015  -0.755i     +0.236  +0.035i     -0.166  +0.555i     -0.017  -0.191i 
    -0.463  -0.399i     -0.151  +0.312i     -0.208  -0.463i     +0.407  +0.288i 
    -0.037  -0.012i     +0.590  -0.534i     -0.318  -0.172i     -0.116  +0.469i 
    +0.231  +0.000i     +0.434  -0.000i     +0.526  +0.000i     +0.694  +0.000i 

 Press return to continue. 


 X = U_T * A * V :
  +222.775 -91.135i     -0.000  +0.000i     +0.000  -0.000i     -0.000  +0.000i 
    +0.000  +0.000i   +149.194 -61.034i     +0.000  -0.000i     -0.000  +0.000i 
    +0.000  -0.000i     -0.000  -0.000i    +41.800 -17.100i     +0.000  -0.000i 
    +0.000  +0.000i     -0.000  -0.000i     -0.000  +0.000i    +29.179 -11.937i 

 A :
    -68.00   -8.00i      +0.00   +0.00i      +0.00   +0.00i      +0.00   +0.00i 
    +88.00  -39.00i     +82.00  +31.00i      +0.00   +0.00i      +0.00   +0.00i 
    -89.00  -58.00i     -68.00  -77.00i     +81.00  -53.00i      +0.00   +0.00i 
    +59.00  +81.00i     -68.00  +52.00i     +80.00  +36.00i     +88.00  -36.00i 

 A = U * X * V_T  
    -68.00   -8.00i      +0.00   +0.00i      +0.00   +0.00i      -0.00   +0.00i 
    +88.00  -39.00i     +82.00  +31.00i      +0.00   +0.00i      -0.00   -0.00i 
    -89.00  -58.00i     -68.00  -77.00i     +81.00  -53.00i      +0.00   -0.00i 
    +59.00  +81.00i     -68.00  +52.00i     +80.00  +36.00i     +88.00  -36.00i 


 Press   return to continue
 Press X return to stop