Aller au contenu

Mathc complexes/00c

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 RA              R3
#define CA              C5
/* ------------------------------------ */
#define FACTOR_E        +1.E-2   
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
int r = RA;
int c = CA;  

double a[RA*(CA*C2)] ={    
   +4, +28,   -82, +58,    -5,  -6,   +30, +46,   -76, -17, 
  +65, -51,   +25, +86,   +78, +53,    +8, +74,   +94, -93, 
  +93, -18,   -38, -50,   -61, +27,   +49, +17,   -98, +43
  };

double **A      = ca_A_mZ(a, i_mZ(r,c));     
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, S5,P0, S4,P0, C6); 
        
  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);             
  p_mZ(X, S10,P4, S9,P4, C3);
  
  printf(" invX :");
  X_inv_mZ(X, invX);
  pE_mZ(invX, S10,P4, S8,P4, C3);

  printf(" Copy/Past into the octave window.\n\n");
  p_Octave_mZ(A,"A",P0, P0);
  printf(" format short e\n");
  printf(" pinv(A)\n\n");
  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, S5,P2, S8,P4, C6);
  stop(); 
      
  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);

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


Exemple de sortie écran :
 A :
   +4 +28i   -82 +58i    -5  -6i   +30 +46i   -76 -17i 
  +65 -51i   +25 +86i   +78 +53i    +8 +74i   +94 -93i 
  +93 -18i   -38 -50i   -61 +27i   +49 +17i   -98 +43i 

 U :
   +0.1099 +0.1622i    -0.4664 -0.3321i    +0.5659 +0.2034i 
   -0.0258 -0.4271i    +0.0870 +0.3941i    +0.4715 +0.5624i 
   +0.2812 -0.3546i    -0.0783 +0.1849i    -0.1710 -0.1862i 
   -0.1782 -0.0962i    -0.4939 +0.2407i    -0.0196 +0.0143i 
   +0.7299 +0.0000i    +0.4088 +0.0000i    +0.1878 -0.0000i 

 V :
   +0.1567 +0.0612i    +0.5488 +0.2104i    -0.7386 -0.2842i 
   -0.8170 -0.1463i    +0.5096 +0.0905i    +0.2045 +0.0375i 
   +0.5318 -0.0000i    +0.6218 +0.0000i    +0.5749 -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 :
 -175.7101+156.9912i    -0.0000  +0.0000i    +0.0000  -0.0000i 
   +0.0000  +0.0000i  -163.2623 -55.0545i    +0.0000  -0.0000i 
   -0.0000  +0.0000i    +0.0000  +0.0000i  +108.4528 -36.5673i 

 invX :
-3.1648e-03-2.8276e-03i +0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i 
+0.0000e+00+0.0000e+00i -5.4997e-03+1.8546e-03i +0.0000e+00+0.0000e+00i 
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i +8.2794e-03+2.7916e-03i 

 Copy/Past into the octave window.

 A=[
+4+28*i,-82+58*i,-5-6*i,+30+46*i,-76-17*i;
+65-51*i,+25+86*i,+78+53*i,+8+74*i,+94-93*i;
+93-18*i,-38-50*i,-61+27*i,+49+17*i,-98+43*i]

 format short e
 pinv(A)

 Press return to continue. 


 Pinv =  U * invX * V_T:
-2.0540e-03-1.5182e-03i +2.7025e-03+1.4048e-03i +4.4042e-03+2.0363e-03i 
-4.5959e-03-4.3020e-03i +6.1475e-04-1.1073e-03i -9.2394e-06+2.9435e-03i 
+7.6242e-04+7.4773e-04i +1.1790e-03-1.5238e-03i -1.4667e-03-1.7095e-03i 
+1.0009e-03-1.7028e-03i +5.5828e-04-1.9438e-03i +1.4506e-03-9.2614e-04i 
-2.8598e-03+7.6160e-04i +1.4498e-03+1.9869e-03i -1.7328e-03-3.2491e-04i 

+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.00 +0.0000i +0.00 +0.0000i +0.00 -0.0000i +0.00 +0.0000i +0.00 +0.0000i 
-0.00 +0.0000i +1.00 +0.0000i -0.00 +0.0000i +0.00 +0.0000i +0.00 +0.0000i 
-0.00 +0.0000i +0.00 +0.0000i +1.00 -0.0000i +0.00 +0.0000i +0.00 +0.0000i 

 Press return to continue.