Aller au contenu

Mathc complexes/045

Un livre de Wikilivres.


X Value Decomposition

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


c00a.c
/* ------------------------------------ */
/*  save as :   c00a.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define FACTOR_E        +1.E+9  
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r,int c)
{                       
double **A   =          rE_mZ(  i_mZ(r,c), 999, 1E-12 );	
double **Acc =                  i_mZ(c,c);

double **V      =               i_mZ(c,r);
double **U      =               i_mZ(c,r); 
double **V_T    =               i_mZ(r,c); 
double **V_TAcc =               i_mZ(r,c);  
double **X      =               i_mZ(r,r);
double **invX   =               i_mZ(r,r); 
double **UinvX  =               i_mZ(c,r);
double **Pinv   =               i_mZ(c,c);
double **APinv  =               i_mZ(r,c);

  clrscrn();
  printf(" A :");
  p_mZ(A, S18,P13, S17,P13, C2);
  stop(); 
  
  clrscrn();
  printf(" A :");
  pE_mZ(A, S12,P3, S11,P3, C3); 
        
  printf(" U :");
  X_U_mZ(A,U,FACTOR_E);
    p_mZ(U, S10,P4, S8,P4, C3);

  printf(" V :");
  X_V_mZ(A,V,FACTOR_E);
    p_mZ(V, S10,P4, S8,P4, C3); 
 
  ctranspose_mZ(V,V_T);
  stop(); 
   
  clrscrn();    
  printf(" X = V_T * A * U :");
  c_mZ(A, Acc);
  mul_mZ(V_T,  Acc, V_TAcc);          
  mul_mZ(V_TAcc, U,  X);             
  pE_mZ(X, S10,P4, S9,P4, C3);
  
  printf(" invX :");
  X_inv_mZ(X, invX);
  pE_mZ(invX, S10,P4, S8,P4, C3);
  stop();  
   
  clrscrn();
  printf(" Pinv =  U * invX * V_T:");
  mul_mZ(U,invX,UinvX);
  mul_mZ(UinvX,V_T,Pinv); 
  pE_mZ(Pinv, S10,P4, S8,P4, C3); 

  printf(" Ide = A * Pinv");
  mul_mZ(A,Pinv,APinv); 
  p_mZ(APinv, S8,P3, S5,P3, C6); 
      
  f_mZ(A);  
  f_mZ(Acc);
  f_mZ(U);      
  f_mZ(V); 
  f_mZ(V_T);
  f_mZ(V_TAcc);  
  f_mZ(X);
  f_mZ(APinv);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
    fun(R3,C5);
    
} while(stop_w());

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


Exemple de sortie écran :
 A :
  +0.0000000002000 +0.0000000006270i   +0.0000000007680 +0.0000000002520i 
  -0.0000000005420 -0.0000000007730i   +0.0000000009610 +0.0000000002520i 
  +0.0000000000700 +0.0000000009210i   -0.0000000003810 +0.0000000001120i 

  -0.0000000009690 -0.0000000000980i   -0.0000000004240 +0.0000000000510i 
  -0.0000000002000 +0.0000000008330i   +0.0000000007230 +0.0000000006540i 
  -0.0000000000240 +0.0000000006450i   -0.0000000007870 +0.0000000007040i 

  -0.0000000006640 +0.0000000008880i 
  -0.0000000003580 -0.0000000001450i 
  +0.0000000000630 -0.0000000004970i 

 Press return to continue. 


 A :
  +2.000e-10 +6.270e-10i   +7.680e-10 +2.520e-10i   -9.690e-10 -9.800e-11i 
  -5.420e-10 -7.730e-10i   +9.610e-10 +2.520e-10i   -2.000e-10 +8.330e-10i 
  +7.000e-11 +9.210e-10i   -3.810e-10 +1.120e-10i   -2.400e-11 +6.450e-10i 

  -4.240e-10 +5.100e-11i   -6.640e-10 +8.880e-10i 
  +7.230e-10 +6.540e-10i   -3.580e-10 -1.450e-10i 
  -7.870e-10 +7.040e-10i   +6.300e-11 -4.970e-10i 

 U :
   -0.4151 -0.1370i    +0.2722 -0.1413i    -0.0499 +0.7093i 
   -0.2189 +0.3904i    -0.2865 +0.4126i    -0.0770 -0.0317i 
   +0.3540 +0.2588i    +0.1951 -0.4559i    -0.4141 +0.1490i 
   +0.1071 +0.6265i    -0.1849 -0.2004i    -0.1281 +0.2248i 
   +0.1110 +0.0000i    +0.5774 +0.0000i    +0.4762 -0.0000i 

 V :
   +0.3805 -0.1529i    -0.4481 +0.7216i    +0.0339 -0.3304i 
   -0.3406 -0.7103i    -0.2769 +0.0276i    +0.3662 +0.4098i 
   +0.4597 -0.0000i    +0.4484 +0.0000i    +0.7666 +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 = V_T * A * U :
-1.2117e-09-1.7749e-09i -6.0229e-24+9.4092e-24i -2.5849e-24-1.1761e-24i 
+4.0584e-24+6.9260e-24i +1.8388e-09-1.5855e-10i -1.5510e-24-5.2345e-25i 
+1.5833e-24+3.8774e-25i -4.3427e-24-1.5510e-25i -9.6213e-10-1.0010e-09i 

 invX :
-2.6237e+08+3.8431e+08i +0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i 
+0.0000e+00+0.0000e+00i +5.3983e+08+4.6549e+07i +0.0000e+00+0.0000e+00i 
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i -4.9913e+08+5.1928e+08i 

 Press return to continue. 


 Pinv =  U * invX * V_T:
+7.9561e+07-2.3099e+08i -2.9297e+08+1.7182e+08i -1.2015e+08-3.7662e+08i 
+2.3214e+08-3.6162e+07i +2.2818e+08-8.6794e+07i -7.8428e+07-1.0407e+07i 
-2.1132e+08+4.4293e+07i -9.5743e+07-2.5668e+08i +6.7449e+07-2.9683e+08i 
-6.9926e+07+6.1323e+06i +1.0834e+08-1.5798e+08i -2.0464e+08-2.4600e+08i 
-2.2764e+08-2.9534e+08i -9.1638e+07+1.3669e+08i -5.5829e+07+2.2122e+08i 

+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i 
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i 
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i 
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i 
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i 

 Ide = A * Pinv
  +1.000-0.000i   +0.000+0.000i   +0.000+0.000i   +0.000+0.000i   +0.000+0.000i 
  -0.000-0.000i   +1.000+0.000i   +0.000-0.000i   +0.000+0.000i   +0.000+0.000i 
  +0.000+0.000i   +0.000-0.000i   +1.000+0.000i   +0.000+0.000i   +0.000+0.000i 


 Press   return to continue
 Press X return to stop