Aller au contenu

Mathc complexes/a89

Un livre de Wikilivres.


X Value Decomposition

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


c03c.c
/* ------------------------------------ */
/*  Xave as :   c03c.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define RA              R3
#define CA              C2
#define FACTOR_E        +1.E-2   
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
int r = RA;
int c = CA;  

double a[RA*(CA*C2)] ={ 1,2,  3,4,  
                        5,4,  1,3,
                        7,2,  5,1};
                       
double **A =        ca_A_mZ(a, i_mZ(r,c)); 	

double **A_T = ctranspose_mZ(A,i_mZ(c,r));
double **V =                   i_mZ(r,c);
double **V_T =                 i_mZ(c,r);
double **U =                   i_mZ(r,c);
double **U_T =                 i_mZ(c,r); //            :c,r 
double **U_TA =                i_mZ(c,c); // c,r r,c    :c,c
double **U_TAr =               i_mZ(c,r); // c,r        :c,r 
double **X =                   i_mZ(c,c); // c,r r,c    :c,c    U_TArV

double **invX =                i_mZ(c,c); // c,r r,c    :c,c invX

double **VinvX =               i_mZ(r,c);
double **Pinv =                i_mZ(r,r);

double **PinvA =               i_mZ(r,c); // r,c | r,r

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

  printf(" V :");
  X_V_mZ(A_T,V,FACTOR_E);
  p_mZ(V, S10,P4, S8,P4, C3); 
  
  ctranspose_mZ(U,U_T);
  ctranspose_mZ(V,V_T);  
   
  stop(); 
   
  clrscrn();      
   
  printf(" X = U_T * A * V :");
  mul_mZ(U_T, A, U_TA);             // U_TA  : c,c
    c_mZ(U_TA, U_TAr);              // U_TAr : c,r 
  mul_mZ(U_TAr, V, X);              //     V : r,c   
    p_mZ(X, S11,P4, S9,P4, C3);
   
   printf(" invX :");
   X_inv_mZ(X, invX);
      pE_mZ(invX, S10,P4, S8,P4, C3);     
  stop();
  
  clrscrn();

  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 =  V * invX * U_T:");
   mul_mZ(V,invX,VinvX);
   mul_mZ(VinvX,U_T,Pinv); 
    pE_mZ(Pinv, S10,P4, S8,P4, C2); 
  stop(); 
   
  clrscrn();
     
   printf(" Ide = Pinv * A ");
   mul_mZ(Pinv,A,PinvA); 
     p_mZ(PinvA, S10,P4, S8,P4, C3);  
     
   stop();
   
   f_mZ(A);
   f_mZ(A_T);
   
   f_mZ(V);
   f_mZ(V_T);
     
   f_mZ(U);
   f_mZ(U_T);
   f_mZ(U_TA);
   f_mZ(U_TAr); 
   f_mZ(X);
   
   f_mZ(invX);
   f_mZ(VinvX);
   f_mZ(Pinv);
   f_mZ(PinvA);    
   
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


 Diagonaliser une matrice avec un nombre de lignes supérieur ou égal aux nombres de colonnes


Exemple de sortie écran :
 A :
     +1.00   +2.00i      +3.00   +4.00i 
     +5.00   +4.00i      +1.00   +3.00i 
     +7.00   +2.00i      +5.00   +1.00i 

 U :
   +0.2940 +0.2567i    -0.6119 +0.4960i 
   +0.4702 +0.3112i    +0.1304 -0.5579i 
   +0.7278 +0.0000i    +0.2265 -0.0000i 

 V :
   +0.7964 +0.0735i    -0.5977 -0.0552i 
   +0.6002 -0.0000i    +0.7998 +0.0000i 
   +0.0000 +0.0000i    +0.0000 +0.0000i 

 Press return to continue. 


 X = U_T * A * V :
   +11.5820  +3.7205i     +0.0000  -0.0000i 
    -0.0000  +0.0000i     -0.3277  -3.4507i 

 invX :
+7.8265e-02-2.5141e-02i +0.0000e+00+0.0000e+00i 
+0.0000e+00+0.0000e+00i -2.7275e-02+2.8721e-01i 

 Press return to continue. 


 Copy/Past into the octave window.

 A=[
+1+2*i,+3+4*i;
+5+4*i,+1+3*i;
+7+2*i,+5+1*i]

 format short e
 pinv(A)

 Press return to continue. 


 Pinv =  V * invX * U_T:
-8.8864e-02+6.7492e-02i +1.2486e-01-3.0934e-02i 
+1.3723e-01-1.4623e-01i -1.1361e-01-3.9370e-03i 
+0.0000e+00+0.0000e+00i +0.0000e+00+0.0000e+00i 

+5.3993e-02-4.8931e-02i 
+2.9246e-02+4.1057e-02i 
+0.0000e+00+0.0000e+00i 

 Press return to continue. 


 Ide = Pinv * A 
   +1.0000 +0.0000i    -0.0000 +0.0000i 
   -0.0000 -0.0000i    +1.0000 -0.0000i 
   +0.0000 +0.0000i    +0.0000 +0.0000i 

 Press return to continue.