Aller au contenu

Mathc complexes/00f

Un livre de Wikilivres.


X Value Decomposition

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


c00a.c
/* ------------------------------------ */
/*  Xave as :   c00a.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 **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); 
      
  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 :
  +79 -95i   -52  -6i   +63 +60i   +39 +49i   -11 -81i 
   -6 +64i   -57 -59i   +33 -68i   -78 -23i   +95 +88i 
   -8  +2i   +24 -91i   -48 +83i   +43 -43i   -33 +72i 

 U :
   +0.2897 -0.3479i    -0.0491 +0.3894i    -0.4029 +0.1109i 
   -0.3576 +0.0845i    -0.4861 -0.0097i    -0.4927 -0.2753i 
   -0.0370 +0.1038i    +0.7613 -0.0747i    -0.4967 -0.2731i 
   -0.4220 -0.1392i    -0.0070 +0.1494i    +0.2231 +0.2956i 
   +0.6711 +0.0000i    +0.0454 -0.0000i    +0.2199 +0.0000i 

 V :
   -0.4101 +0.3288i    +0.2434 -0.6585i    +0.0143 +0.4803i 
   +0.1101 -0.7345i    -0.2447 -0.0933i    +0.1865 +0.5874i 
   +0.4149 -0.0000i    +0.6622 -0.0000i    +0.6239 +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 :
 -134.0841+217.8061i    +0.0000  +0.0000i    -0.0000  -0.0000i 
   -0.0000  +0.0000i   -58.3604+177.5035i    -0.0000  +0.0000i 
   -0.0000  +0.0000i    -0.0000  +0.0000i   +44.3668 +43.8762i 

 invX :
-2.0497e-03-3.3295e-03i +0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i 
+0.0000e+00+0.0000e+00i -1.6716e-03-5.0841e-03i +0.0000e+00+0.0000e+00i 
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i +1.1395e-02-1.1269e-02i 

 Copy/Past into the octave window.

 A=[
+79-95*i,-52-6*i,+63+60*i,+39+49*i,-11-81*i;
-6+64*i,-57-59*i,+33-68*i,-78-23*i,+95+88*i;
-8+2*i,+24-91*i,-48+83*i,+43-43*i,-33+72*i]

 format short e
 pinv(A)

 Press return to continue. 


 Pinv =  U * invX * V_T:
+4.1412e-03+3.6273e-03i +2.3107e-03+2.0210e-03i -1.4464e-03+3.2510e-03i 
-4.9814e-04+4.5782e-03i -1.2604e-03+5.8906e-03i -4.5124e-03+3.5769e-03i 
+2.9307e-03+2.1306e-03i +6.9674e-04+6.6582e-03i -6.3713e-03-9.6693e-04i 
+1.2147e-03-3.1777e-03i +2.3109e-04-2.6850e-03i +4.3416e-03+1.0927e-03i 
-1.1917e-03+2.3334e-05i +5.4113e-04-3.1414e-03i +9.4274e-04-2.6262e-03i 

+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
 Press X return to stop